Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade codehike to v1 #460

Merged
merged 29 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1a254a9
Upgrade docusaurus
gvdongen Sep 10, 2024
6e3a03d
Upgrade codehike and other dependencies
gvdongen Sep 10, 2024
b22260b
Upgrading to codehike v1
gvdongen Sep 11, 2024
128deb0
Minimal working version codehike v1
gvdongen Sep 11, 2024
62450b4
Fix styling of scrollycoding
gvdongen Sep 11, 2024
544deb4
Fix styling of codehike v1
gvdongen Sep 11, 2024
b1ea0ca
Codehike v1 migration
gvdongen Sep 12, 2024
9ac66c1
Add copy button
gvdongen Sep 12, 2024
cc9311b
Upgrade Tour to codehike v1
gvdongen Sep 12, 2024
30bc78e
Upgrade to codehike v1
gvdongen Sep 13, 2024
11b2058
Fix scrollycoding for tabs and steps
gvdongen Sep 16, 2024
6a99f5b
Fix invocations page to codehike v1
gvdongen Sep 16, 2024
d9199e8
Fix services page to codehike v1
gvdongen Sep 16, 2024
22ccf02
Upgrade codehike v1 docs
gvdongen Sep 16, 2024
4d8f83a
make tabs work and update all code snippets
gvdongen Oct 22, 2024
341b20d
fix lists
gvdongen Oct 22, 2024
c79a633
Fix numbered lists and fix clients code snippets
gvdongen Oct 22, 2024
66fc1f9
Fix invocations page
gvdongen Oct 22, 2024
4b9a15b
Make tabs and scrollycoding word properly and add styling
gvdongen Oct 30, 2024
7394859
Cleanu
gvdongen Oct 30, 2024
ca64b27
Cleanup
gvdongen Oct 30, 2024
151f5bd
Fix focus and mark across the docs
gvdongen Oct 31, 2024
fb8088a
Fix terminal animations
gvdongen Oct 31, 2024
84ebd9a
Collapse verbose terminal output in tour and invocations page
gvdongen Oct 31, 2024
c760866
Fix coloring of links in admonitions
gvdongen Oct 31, 2024
a6dcdca
Fix styling of animations
gvdongen Oct 31, 2024
7171d80
Small fixes
gvdongen Oct 31, 2024
5135c4d
Merge branch 'refs/heads/main' into upgrade
gvdongen Oct 31, 2024
4aa680f
Cleanup
gvdongen Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions code_snippets/go/concepts/invocations.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ type MyService struct{}
/*
// <start_rpc_call>
func (MyService) MyRestateHandler(ctx restate.Context) error {
// focus
// !focus
greet, err := restate.
// focus
// !focus
Service[string](ctx, "Greeter", "Greet").
// focus
// !focus
Request("Hi")
return err
}
Expand All @@ -24,11 +24,11 @@ func (MyService) MyRestateHandler(ctx restate.Context) error {

// <start_one_way_call>
func (MyService) MyRestateHandler(ctx restate.Context) error {
// focus
// !focus
restate.
// focus
// !focus
ServiceSend(ctx, "Greeter", "Greet").
// focus
// !focus
Send("Hi")
return nil
}
Expand All @@ -38,11 +38,11 @@ func (MyService) MyRestateHandler(ctx restate.Context) error {

// <start_delayed_call>
func (MyService) MyRestateHandler(ctx restate.Context) error {
// focus
// !focus
restate.
// focus
// !focus
ServiceSend(ctx, "Greeter", "Greet").
// focus
// !focus
Send("Hi", restate.WithDelay(1*time.Second))
return nil
}
Expand Down
1 change: 0 additions & 1 deletion code_snippets/go/develop/codegen/proto/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ syntax = "proto3";
option go_package = "github.com/restatedev/documentation/code_snippets/go/codegen/proto";

// <start_service>
// service.proto
package greeter;

service Greeter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ public class DelayedCalls {
// <start_delayed_call>
@Handler
public void myRestateHandler(Context ctx) {
// focus
// !focus
GreeterServiceClient.fromContext(ctx)
// focus
// !focus
.send(Duration.ofMillis(1000))
// focus
// !focus
.greet("Hi");
}

// <end_delayed_call>

// <start_delayed_call_java>
public void myJavaHandler(Context ctx) {
// focus
public void myJavaHandler() {
// !focus
Client restate = Client.connect("http://localhost:8080");
// focus
// !focus
GreeterServiceClient.fromClient(restate)
// focus
// !focus
.send(Duration.ofMillis(1000))
// focus
// !focus
.greet("Hi");
}
// <end_delayed_call_java>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ public class OneWayCalls {
// <start_one_way_call>
@Handler
public void myRestateHandler(Context ctx) {
// focus
// !focus
GreeterServiceClient.fromContext(ctx)
// focus
// !focus
.send()
// focus
// !focus
.greet("Hi");
}

// <end_one_way_call>

// <start_one_way_call_java>
public void myJavaHandler(Context ctx) {
// focus
public void myJavaHandler() {
// !focus
Client restate = Client.connect("http://localhost:8080");
// focus
// !focus
GreeterServiceClient.fromClient(restate)
// focus
// !focus
.send()
// focus
// !focus
.greet("Hi");
}
// <end_one_way_call_java>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ public class RpcCalls {
// <start_rpc>
@Handler
public void myRestateHandler(Context ctx) {
// focus
// !focus
String greet =
// focus
// !focus
GreeterServiceClient.fromContext(ctx)
// focus
// !focus
.greet("Hi")
// focus
// !focus
.await();
}

// <end_rpc>

// <start_rpc_java>
public void myJavaHandler(Context ctx) {
// focus
public void myJavaHandler() {
// !focus
Client restate = Client.connect("http://localhost:8080");
// focus
// !focus
String greet =
// focus
// !focus
GreeterServiceClient.fromClient(restate)
// focus
// !focus
.greet("Hi");
}
// <end_rpc_java>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void oneWay(Context ctx) {

// <start_one_way>
MyServiceClient.fromContext(ctx)
// mark
// !mark
.send()
.myHandler(request);
// <end_one_way>
Expand All @@ -70,7 +70,7 @@ private void delayedCall(Context ctx) {

// <start_delayed>
MyServiceClient.fromContext(ctx)
// mark
// !mark
.send(Duration.ofSeconds(1))
.myHandler(request);
// <end_delayed>
Expand Down
18 changes: 9 additions & 9 deletions code_snippets/java/src/main/java/develop/clients/Ingress.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public void myOneWayCallHandler() {
// <start_one_way_call_java>
Client rs = Client.connect("http://localhost:8080");
GreeterServiceClient.fromClient(rs)
// mark
// !mark
.send()
.greet("Hi");

GreetCounterObjectClient.fromClient(rs, "Mary")
// mark
// !mark
.send()
.greet("Hi");
// <end_one_way_call_java>
Expand All @@ -38,12 +38,12 @@ public void myDelayedOneWayCallHandler() {
// <start_delayed_call_java>
Client rs = Client.connect("http://localhost:8080");
GreeterServiceClient.fromClient(rs)
// mark
// !mark
.send(Duration.ofMillis(1000))
.greet("Hi");

GreetCounterObjectClient.fromClient(rs, "Mary")
// mark
// !mark
.send(Duration.ofMillis(1000))
.greet("Hi");
// <end_delayed_call_java>
Expand All @@ -67,21 +67,21 @@ public void attach() {
SendResponse handle =
GreeterServiceClient.fromClient(rs)
.send()
// mark
// !mark
.greet("Hi", CallRequestOptions.DEFAULT.withIdempotency("abcde"));

// ... do something else ...

// Option 1: Attach later to retrieve the result
// mark
// !mark
String greeting =
// mark
// !mark
rs.invocationHandle(handle.getInvocationId(), JsonSerdes.STRING).attach();

// Option 2: Peek to see if the result is ready
// mark
// !mark
Output<String> output =
// mark
// !mark
rs.invocationHandle(handle.getInvocationId(), JsonSerdes.STRING).getOutput();
if (output.isReady()) {
String result = output.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ public class UserManagementService {
// <start_here>
@Handler
public void setup(ObjectContext ctx, Email email) {
// focus
// !focus
boolean result =
// focus
// !focus
SignupWorkflowClient.fromContext(ctx, "someone")
// focus
// !focus
.run(email)
// focus
// !focus
.await();
}

@Handler
public void queryStatus(ObjectContext ctx) {
// focus
// !focus
String status =
// focus
// !focus
SignupWorkflowClient.fromContext(ctx, "someone")
// focus
// !focus
.getStatus()
// focus
// !focus
.await();
}
// <end_here>
Expand Down
16 changes: 8 additions & 8 deletions code_snippets/java/src/main/java/get_started/Tour.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public void myFn(Context ctx) {
// <start_uuid>
@Handler
public boolean handle(Context ctx, CheckoutRequest request) {
// mark
// !mark
String idempotencyKey = ctx.random().nextUUID().toString();
// mark
// !mark
System.out.println("My idempotency key: " + idempotencyKey);

// mark
// !mark
throw new IllegalStateException("The handler failed");
}

Expand All @@ -48,18 +48,18 @@ class CheckoutService {
// <start_checkout>
@Handler
public boolean handle(Context ctx, CheckoutRequest request) {
// mark
// !mark
double totalPrice = request.getTickets().size() * 40.0;

String idempotencyKey = ctx.random().nextUUID().toString();

// mark
// !mark
boolean success =
// mark
// !mark
ctx.run(
// mark
// !mark
JsonSerdes.BOOLEAN,
// mark
// !mark
() -> PaymentClient.get().call(idempotencyKey, totalPrice));

return success;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ public void submit(User user) {
// <start_here>
// import dev.restate.sdk.client.Client;
Client rs = Client.connect("http://localhost:8080");
// mark
// !mark
SignupWorkflowClient.fromClient(rs, user.getId())
// mark
// !mark
.submit(user);

// do something else, with workflow running in the background

// attach back to the workflow
// mark
// !mark
boolean result =
SignupWorkflowClient.fromClient(rs, user.getId())
// mark
// !mark
.workflowHandle()
// mark
// !mark
.attach();
// <end_here>
}
Expand Down
10 changes: 5 additions & 5 deletions code_snippets/kotlin/src/main/kotlin/develop/clients/Ingress.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class Ingress {
// <start_one_way_call_kotlin>
val rs = Client.connect("http://localhost:8080")
GreeterServiceClient.fromClient(rs)
// mark
// !mark
.send()
.greet("Hi")

GreetCounterObjectClient.fromClient(rs, "Mary")
// mark
// !mark
.send()
.greet("Hi")
// <end_one_way_call_kotlin>
Expand Down Expand Up @@ -66,18 +66,18 @@ class Ingress {
val handle: SendResponse =
GreeterServiceClient.fromClient(rs)
.send()
// mark
// !mark
.greet("Hi", CallRequestOptions.DEFAULT.withIdempotency("abcde"))

// ... do something else ...

// Option 1: Attach later to retrieve the result
// mark(1:3)
// !mark(1:2)
val greeting: String =
rs.invocationHandle(handle.invocationId, KtSerdes.json<String>()).attach()

// Option 2: Peek to see if the result is ready
// mark(1:3)
// !mark(1:2)
val output: Output<String> =
rs.invocationHandle(handle.invocationId, KtSerdes.json<String>()).output
if (output.isReady) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ class UserManagementService {
// <start_here>
@Handler
suspend fun setup(ctx: ObjectContext, email: Email) {
// focus(1:3)
// !focus
val result = SignupWorkflowClient.fromContext(ctx, "someone").run(email).await()
}

@Handler
suspend fun queryStatus(ctx: ObjectContext) {
// focus(1:3)
// !focus
val status = SignupWorkflowClient.fromContext(ctx, "someone").getStatus().await()
}
// <end_here>
Expand Down
Loading
Loading