From e85bcaa16fe10c82b428696c470e89080adedfa2 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Wed, 31 Jul 2024 15:00:25 +0200 Subject: [PATCH] Implement ping pong test case --- test-services/coordinator.go | 27 +++++++++++++++++++++++++++ test-services/exclusions.yaml | 3 --- test-services/main.go | 3 ++- test-services/receiver.go | 14 ++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 test-services/coordinator.go create mode 100644 test-services/receiver.go diff --git a/test-services/coordinator.go b/test-services/coordinator.go new file mode 100644 index 0000000..628a78b --- /dev/null +++ b/test-services/coordinator.go @@ -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) +} diff --git a/test-services/exclusions.yaml b/test-services/exclusions.yaml index 6feafd7..a3339fd 100644 --- a/test-services/exclusions.yaml +++ b/test-services/exclusions.yaml @@ -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" @@ -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" @@ -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" diff --git a/test-services/main.go b/test-services/main.go index ef62be6..91306f1 100644 --- a/test-services/main.go +++ b/test-services/main.go @@ -10,7 +10,8 @@ import ( ) func init() { - // TODO register services + RegisterCoordinator() + RegisterReceiver() } func main() { diff --git a/test-services/receiver.go b/test-services/receiver.go new file mode 100644 index 0000000..b1c0acd --- /dev/null +++ b/test-services/receiver.go @@ -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 + }))) +}