Skip to content

Commit

Permalink
Implement ping pong test case
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed Jul 31, 2024
1 parent e04e3c3 commit e85bcaa
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
27 changes: 27 additions & 0 deletions test-services/coordinator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
restate "github.com/restatedev/sdk-go"
)

func RegisterCoordinator() {
REGISTRY.AddRouter(
restate.NewServiceRouter("Coordinator").
Handler("proxy", restate.NewServiceHandler(
func(ctx restate.Context, _ restate.Void) (string, error) {
key := ctx.Rand().UUID().String()
return restate.CallAs[string](ctx.Object("Receiver", key, "ping")).Request(nil)
})))
}

type coordinator struct {
}

func (s coordinator) ServiceName() string {
return "Coordinator"
}

func (s coordinator) Proxy(ctx restate.Context, _ restate.Void) (string, error) {
key := ctx.Rand().UUID().String()
return restate.CallAs[string](ctx.Object("Receiver", key, "ping")).Request(nil)
}
3 changes: 0 additions & 3 deletions test-services/exclusions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ exclusions:
- "dev.restate.sdktesting.tests.WorkflowAPI"
- "dev.restate.sdktesting.tests.UserErrors"
- "dev.restate.sdktesting.tests.State"
- "dev.restate.sdktesting.tests.ServiceToServiceCommunication"
- "dev.restate.sdktesting.tests.Sleep"
- "dev.restate.sdktesting.tests.RequestSigning"
- "dev.restate.sdktesting.tests.CancelInvocation"
Expand All @@ -27,7 +26,6 @@ exclusions:
- "dev.restate.sdktesting.tests.WorkflowAPI"
- "dev.restate.sdktesting.tests.UserErrors"
- "dev.restate.sdktesting.tests.State"
- "dev.restate.sdktesting.tests.ServiceToServiceCommunication"
- "dev.restate.sdktesting.tests.Sleep"
"singleThreadSinglePartition":
- "dev.restate.sdktesting.tests.KafkaIngressTest"
Expand All @@ -43,7 +41,6 @@ exclusions:
- "dev.restate.sdktesting.tests.WorkflowAPI"
- "dev.restate.sdktesting.tests.UserErrors"
- "dev.restate.sdktesting.tests.State"
- "dev.restate.sdktesting.tests.ServiceToServiceCommunication"
- "dev.restate.sdktesting.tests.Sleep"
- "dev.restate.sdktesting.tests.RequestSigning"
- "dev.restate.sdktesting.tests.CancelInvocation"
Expand Down
3 changes: 2 additions & 1 deletion test-services/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
)

func init() {
// TODO register services
RegisterCoordinator()
RegisterReceiver()
}

func main() {
Expand Down
14 changes: 14 additions & 0 deletions test-services/receiver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
restate "github.com/restatedev/sdk-go"
)

func RegisterReceiver() {
REGISTRY.AddRouter(
restate.NewObjectRouter("Receiver").
Handler("ping", restate.NewObjectHandler(
func(ctx restate.ObjectContext, _ restate.Void) (string, error) {
return "pong", nil
})))
}

0 comments on commit e85bcaa

Please sign in to comment.