From e46733c814409212c4c40178e0fe212425fc574a Mon Sep 17 00:00:00 2001 From: David Farr Date: Mon, 30 Sep 2024 22:19:02 -0700 Subject: [PATCH] Add poll plugin (#425) * Add poll plugin * Add create task and create callback to create promise request * Refactor http and grpc apis * Add seperate routes for create promise and task/callback * Add dst for createpromiseandtask and createpromiseandcallback * Add grpc implementation for - createpromiseandtask - createpromiseandcallback * Add poll plugin tests --- Makefile | 13 +- cmd/config/config.go | 146 +- cmd/dst/run.go | 20 +- cmd/serve/serve.go | 33 +- go.mod | 2 +- go.sum | 2 + gomod2nix.toml | 4 +- internal/aio/aio.go | 2 +- internal/aio/aio_dst.go | 2 +- internal/aio/plugin.go | 2 +- internal/aio/subsystem.go | 2 +- internal/api/api.go | 11 + internal/api/subsystem.go | 4 +- internal/app/coroutines/claimTask.go | 49 +- internal/app/coroutines/completeTask.go | 16 +- internal/app/coroutines/createCallback.go | 32 +- internal/app/coroutines/createPromise.go | 235 +- internal/app/coroutines/enqueueTasks.go | 6 +- internal/app/coroutines/schedulePromises.go | 6 +- internal/app/plugins/http/http.go | 5 +- internal/app/plugins/http/http_test.go | 2 +- internal/app/plugins/poll/poll.go | 416 +++ internal/app/plugins/poll/poll_test.go | 300 +++ internal/app/subsystems/aio/echo/echo.go | 2 +- internal/app/subsystems/aio/router/router.go | 59 +- internal/app/subsystems/aio/sender/sender.go | 22 +- .../app/subsystems/aio/sender/sender_dst.go | 2 +- .../subsystems/aio/store/postgres/postgres.go | 67 +- .../aio/store/postgres/postgres_test.go | 2 +- .../app/subsystems/aio/store/sqlite/sqlite.go | 55 +- .../aio/store/sqlite/sqlite_test.go | 2 +- .../app/subsystems/aio/store/test/cases.go | 92 +- internal/app/subsystems/api/api.go | 186 ++ .../app/subsystems/api/{service => }/error.go | 27 +- .../subsystems/api/grpc/api/callback.pb.go | 493 ---- .../subsystems/api/grpc/api/callback.proto | 40 - .../app/subsystems/api/grpc/api/lock.pb.go | 652 ----- .../app/subsystems/api/grpc/api/promise.pb.go | 1552 ----------- .../subsystems/api/grpc/api/schedule.pb.go | 1005 ------- .../app/subsystems/api/grpc/api/task.pb.go | 566 ---- internal/app/subsystems/api/grpc/callback.go | 76 +- internal/app/subsystems/api/grpc/grpc.go | 67 +- internal/app/subsystems/api/grpc/grpc_test.go | 2210 +-------------- internal/app/subsystems/api/grpc/lock.go | 126 +- .../app/subsystems/api/grpc/pb/callback.pb.go | 297 +++ .../app/subsystems/api/grpc/pb/callback.proto | 26 + .../api/grpc/{api => pb}/callback_grpc.pb.go | 6 +- .../subsystems/api/grpc/pb/callback_t.pb.go | 353 +++ .../subsystems/api/grpc/pb/callback_t.proto | 24 + .../app/subsystems/api/grpc/pb/lock.pb.go | 557 ++++ .../api/grpc/{api => pb}/lock.proto | 30 +- .../api/grpc/{api => pb}/lock_grpc.pb.go | 58 +- .../app/subsystems/api/grpc/pb/promise.pb.go | 1773 ++++++++++++ .../api/grpc/{api => pb}/promise.proto | 110 +- .../api/grpc/{api => pb}/promise_grpc.pb.go | 120 +- .../subsystems/api/grpc/pb/promise_t.pb.go | 395 +++ .../subsystems/api/grpc/pb/promise_t.proto | 31 + .../app/subsystems/api/grpc/pb/schedule.pb.go | 821 ++++++ .../api/grpc/{api => pb}/schedule.proto | 32 +- .../api/grpc/{api => pb}/schedule_grpc.pb.go | 74 +- .../subsystems/api/grpc/pb/schedule_t.pb.go | 281 ++ .../subsystems/api/grpc/pb/schedule_t.proto | 22 + .../app/subsystems/api/grpc/pb/task.pb.go | 732 +++++ .../api/grpc/{api => pb}/task.proto | 25 +- .../api/grpc/{api => pb}/task_grpc.pb.go | 6 +- internal/app/subsystems/api/grpc/promise.go | 433 +-- internal/app/subsystems/api/grpc/schedule.go | 168 +- internal/app/subsystems/api/grpc/task.go | 136 +- internal/app/subsystems/api/http/callback.go | 56 +- internal/app/subsystems/api/http/http.go | 94 +- internal/app/subsystems/api/http/http_test.go | 1472 +--------- internal/app/subsystems/api/http/lock.go | 134 +- internal/app/subsystems/api/http/promise.go | 302 ++- internal/app/subsystems/api/http/schedule.go | 183 +- internal/app/subsystems/api/http/task.go | 227 +- .../app/subsystems/api/service/callback.go | 45 - internal/app/subsystems/api/service/lock.go | 120 - .../app/subsystems/api/service/promise.go | 198 -- .../app/subsystems/api/service/request.go | 118 - .../app/subsystems/api/service/schedule.go | 193 -- .../app/subsystems/api/service/service.go | 35 - internal/app/subsystems/api/service/task.go | 104 - internal/app/subsystems/api/test/api.go | 5 - internal/app/subsystems/api/test/cases.go | 2368 +++++++++++++++++ internal/kernel/system/system.go | 4 + internal/kernel/t_aio/router.go | 2 +- internal/kernel/t_aio/sender.go | 5 +- internal/kernel/t_aio/store.go | 24 +- internal/kernel/t_api/api.go | 6 + internal/kernel/t_api/request.go | 260 +- internal/kernel/t_api/response.go | 235 +- internal/metrics/metrics.go | 7 + internal/util/util.go | 11 + pkg/callback/callback.go | 20 +- pkg/callback/record.go | 21 - pkg/message/message.go | 31 +- pkg/promise/promise.go | 13 +- pkg/receiver/recv.go | 4 - pkg/schedule/schedule.go | 2 +- pkg/task/task.go | 26 +- test/dst/dst.go | 54 +- test/dst/dst_test.go | 4 +- test/dst/generator.go | 125 +- test/dst/validator.go | 126 +- 104 files changed, 11330 insertions(+), 10427 deletions(-) create mode 100644 internal/app/plugins/poll/poll.go create mode 100644 internal/app/plugins/poll/poll_test.go create mode 100644 internal/app/subsystems/api/api.go rename internal/app/subsystems/api/{service => }/error.go (81%) delete mode 100644 internal/app/subsystems/api/grpc/api/callback.pb.go delete mode 100644 internal/app/subsystems/api/grpc/api/callback.proto delete mode 100644 internal/app/subsystems/api/grpc/api/lock.pb.go delete mode 100644 internal/app/subsystems/api/grpc/api/promise.pb.go delete mode 100644 internal/app/subsystems/api/grpc/api/schedule.pb.go delete mode 100644 internal/app/subsystems/api/grpc/api/task.pb.go create mode 100644 internal/app/subsystems/api/grpc/pb/callback.pb.go create mode 100644 internal/app/subsystems/api/grpc/pb/callback.proto rename internal/app/subsystems/api/grpc/{api => pb}/callback_grpc.pb.go (96%) create mode 100644 internal/app/subsystems/api/grpc/pb/callback_t.pb.go create mode 100644 internal/app/subsystems/api/grpc/pb/callback_t.proto create mode 100644 internal/app/subsystems/api/grpc/pb/lock.pb.go rename internal/app/subsystems/api/grpc/{api => pb}/lock.proto (77%) rename internal/app/subsystems/api/grpc/{api => pb}/lock_grpc.pb.go (98%) create mode 100644 internal/app/subsystems/api/grpc/pb/promise.pb.go rename internal/app/subsystems/api/grpc/{api => pb}/promise.proto (54%) rename internal/app/subsystems/api/grpc/{api => pb}/promise_grpc.pb.go (72%) create mode 100644 internal/app/subsystems/api/grpc/pb/promise_t.pb.go create mode 100644 internal/app/subsystems/api/grpc/pb/promise_t.proto create mode 100644 internal/app/subsystems/api/grpc/pb/schedule.pb.go rename internal/app/subsystems/api/grpc/{api => pb}/schedule.proto (67%) rename internal/app/subsystems/api/grpc/{api => pb}/schedule_grpc.pb.go (98%) create mode 100644 internal/app/subsystems/api/grpc/pb/schedule_t.pb.go create mode 100644 internal/app/subsystems/api/grpc/pb/schedule_t.proto create mode 100644 internal/app/subsystems/api/grpc/pb/task.pb.go rename internal/app/subsystems/api/grpc/{api => pb}/task.proto (65%) rename internal/app/subsystems/api/grpc/{api => pb}/task_grpc.pb.go (98%) delete mode 100644 internal/app/subsystems/api/service/callback.go delete mode 100644 internal/app/subsystems/api/service/lock.go delete mode 100644 internal/app/subsystems/api/service/promise.go delete mode 100644 internal/app/subsystems/api/service/request.go delete mode 100644 internal/app/subsystems/api/service/schedule.go delete mode 100644 internal/app/subsystems/api/service/service.go delete mode 100644 internal/app/subsystems/api/service/task.go create mode 100644 internal/app/subsystems/api/test/cases.go delete mode 100644 pkg/callback/record.go diff --git a/Makefile b/Makefile index f2180a7e..a721081c 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,13 @@ .PHONY: gen-proto gen-proto: - protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/api/promise.proto - protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/api/callback.proto - protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/api/schedule.proto - protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/api/lock.proto - protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/api/task.proto + protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/pb/promise_t.proto + protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/pb/promise.proto + protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/pb/callback_t.proto + protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/pb/callback.proto + protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/pb/schedule_t.proto + protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/pb/schedule.proto + protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/pb/lock.proto + protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/app/subsystems/api/grpc/pb/task.proto .PHONY: deps deps: diff --git a/cmd/config/config.go b/cmd/config/config.go index 80b40272..8da2aa75 100644 --- a/cmd/config/config.go +++ b/cmd/config/config.go @@ -41,7 +41,7 @@ type config[T t_api, U t_aio] struct { System system.Config `flag:"system"` API T `flag:"api"` AIO U `flag:"aio"` - MetricsPort int `flag:"metrics-port" desc:"prometheus metrics server port" default:"9090"` + MetricsAddr string `flag:"metrics-addr" desc:"prometheus metrics server address" default:":9090"` LogLevel string `flag:"log-level" desc:"can be one of: debug, info, warn, error" default:"info"` } @@ -64,35 +64,6 @@ func (c *Config) Parse() error { return err } - // TODO: rethink defaults - - if c.System.Url == "" { - host := c.API.Subsystems.Http.Config.Host - if host == "0.0.0.0" { - host = "127.0.0.1" - } - c.System.Url = fmt.Sprintf("http://%s:%d", host, c.API.Subsystems.Http.Config.Port) - } - - if c.AIO.Subsystems.Router.Enabled { - var found bool - - for _, source := range c.AIO.Subsystems.Router.Config.Sources { - if source.Name == "default" { - found = true - break - } - } - - if !found { - c.AIO.Subsystems.Router.Config.Sources = append(c.AIO.Subsystems.Router.Config.Sources, router.SourceConfig{ - Name: "default", - Type: "tag", - Data: []byte(`{"key": "resonate:invoke"}`), - }) - } - } - return nil } @@ -109,27 +80,6 @@ func (c *ConfigDST) Parse(r *rand.Rand) error { return err } - // TODO: rethink defaults - - if c.AIO.Subsystems.Router.Enabled { - var found bool - - for _, source := range c.AIO.Subsystems.Router.Config.Sources { - if source.Name == "default" { - found = true - break - } - } - - if !found { - c.AIO.Subsystems.Router.Config.Sources = append(c.AIO.Subsystems.Router.Config.Sources, router.SourceConfig{ - Name: "default", - Type: "tag", - Data: []byte(`{"key": "resonate:invoke"}`), - }) - } - } - return nil } @@ -176,38 +126,48 @@ type DisabledSubsystem[T any] struct { Config T `flag:"-"` } -func (s *APISubsystems) Instantiate(a api.API) []api.Subsystem { +func (c *Config) APISubsystems(a api.API) ([]api.Subsystem, error) { subsystems := []api.Subsystem{} - if s.Http.Enabled { - subsystems = append(subsystems, http.New(a, &s.Http.Config)) + if c.API.Subsystems.Http.Enabled { + subsystem, err := http.New(a, &c.API.Subsystems.Http.Config) + if err != nil { + return nil, err + } + + subsystems = append(subsystems, subsystem) } - if s.Grpc.Enabled { - subsystems = append(subsystems, grpc.New(a, &s.Grpc.Config)) + if c.API.Subsystems.Grpc.Enabled { + subsystem, err := grpc.New(a, &c.API.Subsystems.Grpc.Config) + if err != nil { + return nil, err + } + + subsystems = append(subsystems, subsystem) } - return subsystems + return subsystems, nil } -func (s *AIOSubsystems) Instantiate(a aio.AIO, metrics *metrics.Metrics) ([]aio.Subsystem, error) { +func (c *Config) AIOSubsystems(a aio.AIO, metrics *metrics.Metrics) ([]aio.Subsystem, error) { subsystems := []aio.Subsystem{} - if s.Echo.Enabled { - subsystem, err := echo.New(a, metrics, &s.Echo.Config) + if c.AIO.Subsystems.Echo.Enabled { + subsystem, err := echo.New(a, metrics, &c.AIO.Subsystems.Echo.Config) if err != nil { return nil, err } subsystems = append(subsystems, subsystem) } - if s.Router.Enabled { - subsystem, err := router.New(a, metrics, &s.Router.Config) + if c.AIO.Subsystems.Router.Enabled { + subsystem, err := router.New(a, metrics, &c.AIO.Subsystems.Router.Config) if err != nil { return nil, err } subsystems = append(subsystems, subsystem) } - if s.Sender.Enabled { - subsystem, err := sender.New(a, metrics, &s.Sender.Config) + if c.AIO.Subsystems.Sender.Enabled { + subsystem, err := sender.New(a, metrics, &c.AIO.Subsystems.Sender.Config) if err != nil { return nil, err } @@ -215,7 +175,7 @@ func (s *AIOSubsystems) Instantiate(a aio.AIO, metrics *metrics.Metrics) ([]aio. subsystems = append(subsystems, subsystem) } - subsystem, err := s.instantiateStore(a, metrics) + subsystem, err := c.store(a, metrics) if err != nil { return nil, err } @@ -224,12 +184,13 @@ func (s *AIOSubsystems) Instantiate(a aio.AIO, metrics *metrics.Metrics) ([]aio. return subsystems, nil } -func (s *AIOSubsystems) instantiateStore(a aio.AIO, metrics *metrics.Metrics) (aio.Subsystem, error) { - if s.StorePostgres.Enabled { - return postgres.New(a, metrics, &s.StorePostgres.Config) - } else if s.StoreSqlite.Enabled { - return sqlite.New(a, metrics, &s.StoreSqlite.Config) +func (c *Config) store(a aio.AIO, metrics *metrics.Metrics) (aio.Subsystem, error) { + if c.AIO.Subsystems.StorePostgres.Enabled { + return postgres.New(a, metrics, &c.AIO.Subsystems.StorePostgres.Config) + } else if c.AIO.Subsystems.StoreSqlite.Enabled { + return sqlite.New(a, metrics, &c.AIO.Subsystems.StoreSqlite.Config) } + return nil, fmt.Errorf("no store enabled") } @@ -245,30 +206,40 @@ type AIODSTSubsystems struct { StoreSqlite EnabledSubsystem[sqlite.Config] `flag:"store-sqlite"` } -func (s *APIDSTSubsystems) Instantiate(a api.API) []api.Subsystem { +func (c *ConfigDST) APISubsystems(a api.API) ([]api.Subsystem, error) { subsystems := []api.Subsystem{} - if s.Http.Enabled { - subsystems = append(subsystems, http.New(a, &s.Http.Config)) + if c.API.Subsystems.Http.Enabled { + subsystem, err := http.New(a, &c.API.Subsystems.Http.Config) + if err != nil { + return nil, err + } + + subsystems = append(subsystems, subsystem) } - if s.Grpc.Enabled { - subsystems = append(subsystems, grpc.New(a, &s.Grpc.Config)) + if c.API.Subsystems.Grpc.Enabled { + subsystem, err := grpc.New(a, &c.API.Subsystems.Grpc.Config) + if err != nil { + return nil, err + } + + subsystems = append(subsystems, subsystem) } - return subsystems + return subsystems, nil } -func (s *AIODSTSubsystems) Instantiate(a aio.AIO, metrics *metrics.Metrics, r *rand.Rand, backchannel chan interface{}) ([]aio.SubsystemDST, error) { +func (c *ConfigDST) AIOSubsystems(a aio.AIO, metrics *metrics.Metrics, r *rand.Rand, backchannel chan interface{}) ([]aio.SubsystemDST, error) { subsystems := []aio.SubsystemDST{} - if s.Router.Enabled { - subsystem, err := router.New(a, metrics, &s.Router.Config) + if c.AIO.Subsystems.Router.Enabled { + subsystem, err := router.New(a, metrics, &c.AIO.Subsystems.Router.Config) if err != nil { return nil, err } subsystems = append(subsystems, subsystem) } - if s.Sender.Enabled { - subsystem, err := sender.NewDST(r, backchannel, &s.Sender.Config) + if c.AIO.Subsystems.Sender.Enabled { + subsystem, err := sender.NewDST(r, backchannel, &c.AIO.Subsystems.Sender.Config) if err != nil { return nil, err } @@ -276,7 +247,7 @@ func (s *AIODSTSubsystems) Instantiate(a aio.AIO, metrics *metrics.Metrics, r *r subsystems = append(subsystems, subsystem) } - subsystem, err := s.instantiateStore(a, metrics) + subsystem, err := c.store(a, metrics) if err != nil { return nil, err } @@ -285,12 +256,13 @@ func (s *AIODSTSubsystems) Instantiate(a aio.AIO, metrics *metrics.Metrics, r *r return subsystems, nil } -func (s *AIODSTSubsystems) instantiateStore(a aio.AIO, metrics *metrics.Metrics) (aio.SubsystemDST, error) { - if s.StorePostgres.Enabled { - return postgres.New(a, metrics, &s.StorePostgres.Config) - } else if s.StoreSqlite.Enabled { - return sqlite.New(a, metrics, &s.StoreSqlite.Config) +func (c *ConfigDST) store(a aio.AIO, metrics *metrics.Metrics) (aio.SubsystemDST, error) { + if c.AIO.Subsystems.StorePostgres.Enabled { + return postgres.New(a, metrics, &c.AIO.Subsystems.StorePostgres.Config) + } else if c.AIO.Subsystems.StoreSqlite.Enabled { + return sqlite.New(a, metrics, &c.AIO.Subsystems.StoreSqlite.Config) } + return nil, fmt.Errorf("no store enabled") } diff --git a/cmd/dst/run.go b/cmd/dst/run.go index 88b3934a..c904c860 100644 --- a/cmd/dst/run.go +++ b/cmd/dst/run.go @@ -40,7 +40,6 @@ func RunDSTCmd() *cobra.Command { headers = util.NewRangeIntFlag(1, 25) data = util.NewRangeIntFlag(1, 25) tags = util.NewRangeIntFlag(1, 25) - searches = util.NewRangeIntFlag(1, 10) backchannelSize = util.NewRangeIntFlag(1, 1000) ) @@ -80,10 +79,7 @@ func RunDSTCmd() *cobra.Command { mux := netHttp.NewServeMux() mux.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{})) - metricsServer := &netHttp.Server{ - Addr: ":9090", - Handler: mux, - } + metricsServer := &netHttp.Server{Addr: ":9090", Handler: mux} go metricsServer.ListenAndServe() // nolint: errcheck @@ -113,16 +109,20 @@ func RunDSTCmd() *cobra.Command { aio := aio.NewDST(r, p, metrics) // api subsystems - for _, subsystem := range config.API.Subsystems.Instantiate(api) { + apiSubsystems, err := config.APISubsystems(api) + if err != nil { + return err + } + for _, subsystem := range apiSubsystems { api.AddSubsystem(subsystem) } // aio subsystems - subsystems, err := config.AIO.Subsystems.Instantiate(aio, metrics, r, backchannel) + aioSubsystems, err := config.AIOSubsystems(aio, metrics, r, backchannel) if err != nil { return err } - for _, subsystem := range subsystems { + for _, subsystem := range aioSubsystems { aio.AddSubsystem(subsystem) } @@ -141,6 +141,8 @@ func RunDSTCmd() *cobra.Command { system.AddOnRequest(t_api.ReadPromise, coroutines.ReadPromise) system.AddOnRequest(t_api.SearchPromises, coroutines.SearchPromises) system.AddOnRequest(t_api.CreatePromise, coroutines.CreatePromise) + system.AddOnRequest(t_api.CreatePromiseAndTask, coroutines.CreatePromiseAndTask) + system.AddOnRequest(t_api.CreatePromiseAndCallback, coroutines.CreatePromiseAndCallback) system.AddOnRequest(t_api.CompletePromise, coroutines.CompletePromise) system.AddOnRequest(t_api.CreateCallback, coroutines.CreateCallback) system.AddOnRequest(t_api.ReadSchedule, coroutines.ReadSchedule) @@ -176,7 +178,6 @@ func RunDSTCmd() *cobra.Command { Headers: headers.Resolve(r), Data: data.Resolve(r), Tags: tags.Resolve(r), - Searches: searches.Resolve(r), FaultInjection: p != 0, Backchannel: backchannel, }) @@ -213,7 +214,6 @@ func RunDSTCmd() *cobra.Command { cmd.Flags().Var(headers, "headers", "promise header set size") cmd.Flags().Var(data, "data", "promise data set size") cmd.Flags().Var(tags, "tags", "promise tags set size") - cmd.Flags().Var(searches, "searches", "search set size") cmd.Flags().Var(backchannelSize, "backchannel-size", "backchannel size") // bind config diff --git a/cmd/serve/serve.go b/cmd/serve/serve.go index a2c178f9..7460afe1 100644 --- a/cmd/serve/serve.go +++ b/cmd/serve/serve.go @@ -54,16 +54,20 @@ func ServeCmd() *cobra.Command { aio := aio.New(config.AIO.Size, metrics) // api subsystems - for _, subsystem := range config.API.Subsystems.Instantiate(api) { + apiSubsystems, err := config.APISubsystems(api) + if err != nil { + return err + } + for _, subsystem := range apiSubsystems { api.AddSubsystem(subsystem) } // aio subsystems - subsystems, err := config.AIO.Subsystems.Instantiate(aio, metrics) + aioSubsystems, err := config.AIOSubsystems(aio, metrics) if err != nil { return err } - for _, subsystem := range subsystems { + for _, subsystem := range aioSubsystems { aio.AddSubsystem(subsystem) } @@ -77,6 +81,11 @@ func ServeCmd() *cobra.Command { return err } + // set default url + if config.System.Url == "" { + config.System.Url = fmt.Sprintf("http://%s", api.Addr()) + } + // instantiate system system := system.New(api, aio, &config.System, metrics) @@ -84,6 +93,8 @@ func ServeCmd() *cobra.Command { system.AddOnRequest(t_api.ReadPromise, coroutines.ReadPromise) system.AddOnRequest(t_api.SearchPromises, coroutines.SearchPromises) system.AddOnRequest(t_api.CreatePromise, coroutines.CreatePromise) + system.AddOnRequest(t_api.CreatePromiseAndTask, coroutines.CreatePromiseAndTask) + system.AddOnRequest(t_api.CreatePromiseAndCallback, coroutines.CreatePromiseAndCallback) system.AddOnRequest(t_api.CreateCallback, coroutines.CreateCallback) system.AddOnRequest(t_api.CompletePromise, coroutines.CompletePromise) system.AddOnRequest(t_api.ReadSchedule, coroutines.ReadSchedule) @@ -107,24 +118,16 @@ func ServeCmd() *cobra.Command { // metrics server mux := http.NewServeMux() mux.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{})) - - metricsServer := &http.Server{ - Addr: fmt.Sprintf(":%d", config.MetricsPort), - Handler: mux, - } + metricsServer := &http.Server{Addr: config.MetricsAddr, Handler: mux} go func() { for { slog.Info("starting metrics server", "addr", metricsServer.Addr) - - if err := metricsServer.ListenAndServe(); err != nil { - if err == http.ErrServerClosed { - return - } - - slog.Error("error starting metrics server", "error", err) + if err := metricsServer.ListenAndServe(); err != nil && err == http.ErrServerClosed { + return } + slog.Error("restarting metrics server...", "error", err) time.Sleep(5 * time.Second) } }() diff --git a/go.mod b/go.mod index 9b5af3bd..8044d6d6 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/oapi-codegen/runtime v1.1.1 github.com/prometheus/client_golang v1.20.2 - github.com/resonatehq/gocoro v0.0.0-20240826185351-0a04f9fd5761 + github.com/resonatehq/gocoro v0.0.0-20240928015848-78539a59dab0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 diff --git a/go.sum b/go.sum index a5fd88b5..7d68408c 100644 --- a/go.sum +++ b/go.sum @@ -105,6 +105,8 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/resonatehq/gocoro v0.0.0-20240826185351-0a04f9fd5761 h1:SgiU7IlcLMxipFSx9SiSBTo1vOqkMNQTFRpzPCdTvds= github.com/resonatehq/gocoro v0.0.0-20240826185351-0a04f9fd5761/go.mod h1:MiSQNx9BVIPobnUhUrf83L43RteI/m+NIYT9CXMFQHw= +github.com/resonatehq/gocoro v0.0.0-20240928015848-78539a59dab0 h1:VctdW61gs6QxU1f3McnF1vz7IrhyJtLpCYBBuPny3tM= +github.com/resonatehq/gocoro v0.0.0-20240928015848-78539a59dab0/go.mod h1:MiSQNx9BVIPobnUhUrf83L43RteI/m+NIYT9CXMFQHw= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= diff --git a/gomod2nix.toml b/gomod2nix.toml index 7538fd7a..04c6a061 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -125,8 +125,8 @@ schema = 3 version = "v0.15.1" hash = "sha256-H+WXJemFFwdoglmD6p7JRjrJJZmIVAmJwYmLbZ8Q9sw=" [mod."github.com/resonatehq/gocoro"] - version = "v0.0.0-20240826185351-0a04f9fd5761" - hash = "sha256-5WPQojJvkXBIhoAX8uTPLFYxgBVKG0LoA3nKhmJYPuE=" + version = "v0.0.0-20240928015848-78539a59dab0" + hash = "sha256-4hDOb1dx+jl0EvruOcgVJF17fFeGLsFNM9yhpw5jyHw=" [mod."github.com/robfig/cron/v3"] version = "v3.0.1" hash = "sha256-FUdqNbWYi5biQc/tjCeqzxu4iy4ot1ZvDU1M1wRf/6k=" diff --git a/internal/aio/aio.go b/internal/aio/aio.go index 692e14b7..ab4eed84 100644 --- a/internal/aio/aio.go +++ b/internal/aio/aio.go @@ -66,7 +66,7 @@ func (a *aio) AddSubsystem(subsystem Subsystem) { func (a *aio) Start() error { for _, subsystem := range util.OrderedRange(a.subsystems) { - if err := subsystem.Start(); err != nil { + if err := subsystem.Start(a.errors); err != nil { return err } } diff --git a/internal/aio/aio_dst.go b/internal/aio/aio_dst.go index cf040468..bd7852d8 100644 --- a/internal/aio/aio_dst.go +++ b/internal/aio/aio_dst.go @@ -46,7 +46,7 @@ func (a *aioDST) AddSubsystem(subsystem SubsystemDST) { func (a *aioDST) Start() error { for _, subsystem := range util.OrderedRange(a.subsystems) { - if err := subsystem.Start(); err != nil { + if err := subsystem.Start(nil); err != nil { return err } } diff --git a/internal/aio/plugin.go b/internal/aio/plugin.go index 3e4e6cc7..1389cee9 100644 --- a/internal/aio/plugin.go +++ b/internal/aio/plugin.go @@ -9,7 +9,7 @@ type Message struct { type Plugin interface { String() string Type() string - Start() error + Start(chan<- error) error Stop() error Enqueue(*Message) bool } diff --git a/internal/aio/subsystem.go b/internal/aio/subsystem.go index 053c6881..1199aa74 100644 --- a/internal/aio/subsystem.go +++ b/internal/aio/subsystem.go @@ -8,7 +8,7 @@ import ( type subsystem interface { String() string Kind() t_aio.Kind - Start() error + Start(chan<- error) error Stop() error } diff --git a/internal/api/api.go b/internal/api/api.go index ab9815cd..41481873 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -61,6 +61,17 @@ func (a *api) AddSubsystem(subsystem Subsystem) { a.subsystems = append(a.subsystems, subsystem) } +func (a *api) Addr() string { + // advertise only the http address, if available + for _, subsystem := range a.subsystems { + if subsystem.Kind() == "http" { + return subsystem.Addr() + } + } + + return "" +} + // Lifecycle functions func (a *api) Start() error { diff --git a/internal/api/subsystem.go b/internal/api/subsystem.go index 7468435f..6f4b6d88 100644 --- a/internal/api/subsystem.go +++ b/internal/api/subsystem.go @@ -2,6 +2,8 @@ package api type Subsystem interface { String() string - Start(errors chan<- error) + Kind() string + Addr() string + Start(chan<- error) Stop() error } diff --git a/internal/app/coroutines/claimTask.go b/internal/app/coroutines/claimTask.go index b4f4e25d..3c130b3b 100644 --- a/internal/app/coroutines/claimTask.go +++ b/internal/app/coroutines/claimTask.go @@ -1,9 +1,11 @@ package coroutines import ( + "fmt" "log/slog" "github.com/resonatehq/gocoro" + "github.com/resonatehq/resonate/internal/kernel/system" "github.com/resonatehq/resonate/internal/kernel/t_aio" "github.com/resonatehq/resonate/internal/kernel/t_api" "github.com/resonatehq/resonate/internal/util" @@ -16,8 +18,15 @@ func ClaimTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r util.Assert(r.ClaimTask.ProcessId != "", "process id must be set") util.Assert(r.ClaimTask.Frequency > 0, "frequency must be greater than 0") + config, ok := c.Get("config").(*system.Config) + if !ok { + panic("coroutine must have config dependency") + } + var status t_api.StatusCode - var mesg *message.Mesg + var t *task.Task + var rp, lp *promise.Promise + var rh, lh string completion, err := gocoro.YieldAndAwait(c, &t_aio.Submission{ Kind: t_aio.Store, @@ -45,7 +54,7 @@ func ClaimTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r util.Assert(result.RowsReturned == 0 || result.RowsReturned == 1, "result must return 0 or 1 rows") if result.RowsReturned == 1 { - t, err := result.Records[0].Task() + t, err = result.Records[0].Task() if err != nil { slog.Error("failed to parse task", "req", r, "err", err) return nil, t_api.NewError(t_api.StatusAIOStoreError, err) @@ -125,27 +134,35 @@ func ClaimTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r util.Assert(completion.Store.Results[0].ReadPromise != nil, "result must not be nil") util.Assert(t.Mesg.Type != message.Resume || completion.Store.Results[1].ReadPromise != nil, "if resume, result must not be nil") - var root, leaf *promise.Promise + // set promises + rh = fmt.Sprintf("%s/promises/%s", config.Url, t.Mesg.Root) + + if t.Mesg.Type == message.Resume { + lh = fmt.Sprintf("%s/promises/%s", config.Url, t.Mesg.Leaf) + } if completion.Store.Results[0].ReadPromise.RowsReturned == 1 { - root, err = completion.Store.Results[0].ReadPromise.Records[0].Promise() + rp, err = completion.Store.Results[0].ReadPromise.Records[0].Promise() if err != nil { - slog.Error("failed to parse promises", "err", err) + slog.Error("failed to parse promise", "err", err) } } if t.Mesg.Type == message.Resume && completion.Store.Results[1].ReadPromise.RowsReturned == 1 { - leaf, err = completion.Store.Results[1].ReadPromise.Records[0].Promise() + lp, err = completion.Store.Results[1].ReadPromise.Records[0].Promise() if err != nil { - slog.Error("failed to parse promises", "err", err) + slog.Error("failed to parse promise", "err", err) } } - // set promises for response - t.Mesg.SetPromises(root, leaf) - + // set status status = t_api.StatusCreated - mesg = t.Mesg + + // update task + t.ProcessId = &r.ClaimTask.ProcessId + t.State = task.Claimed + t.Frequency = r.ClaimTask.Frequency + t.Expiration = expiration } else { // It's possible that the task was modified by another coroutine // while we were trying to claim. In that case, we should just retry. @@ -157,14 +174,18 @@ func ClaimTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r } util.Assert(status != 0, "status must be set") - util.Assert(status != t_api.StatusCreated || mesg != nil, "mesg must be non nil if status created") + util.Assert(status != t_api.StatusCreated || t != nil, "task must be non nil if status created") return &t_api.Response{ Kind: t_api.ClaimTask, Tags: r.Tags, ClaimTask: &t_api.ClaimTaskResponse{ - Status: status, - Mesg: mesg, + Status: status, + Task: t, + RootPromise: rp, + LeafPromise: lp, + RootPromiseHref: rh, + LeafPromiseHref: lh, }, }, nil } diff --git a/internal/app/coroutines/completeTask.go b/internal/app/coroutines/completeTask.go index d4bfdd0e..95ac7227 100644 --- a/internal/app/coroutines/completeTask.go +++ b/internal/app/coroutines/completeTask.go @@ -12,6 +12,7 @@ import ( func CompleteTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r *t_api.Request) (*t_api.Response, error) { var status t_api.StatusCode + var t *task.Task completion, err := gocoro.YieldAndAwait(c, &t_aio.Submission{ Kind: t_aio.Store, @@ -39,7 +40,7 @@ func CompleteTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], util.Assert(result.RowsReturned == 0 || result.RowsReturned == 1, "result must return 0 or 1 rows") if result.RowsReturned == 1 { - t, err := result.Records[0].Task() + t, err = result.Records[0].Task() if err != nil { slog.Error("failed to parse task", "req", r, "err", err) return nil, t_api.NewError(t_api.StatusAIOStoreError, err) @@ -88,7 +89,16 @@ func CompleteTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], util.Assert(result.RowsAffected == 0 || result.RowsAffected == 1, "result must return 0 or 1 rows") if result.RowsAffected == 1 { + // set status status = t_api.StatusCreated + + // update task + t.ProcessId = nil + t.State = task.Completed + t.Attempt = 0 + t.Frequency = 0 + t.Expiration = 0 + t.CompletedOn = &completedOn } else { // It's possible that the task was modified by another coroutine // while we were trying to complete. In that case, we should just retry. @@ -99,11 +109,15 @@ func CompleteTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], status = t_api.StatusTaskNotFound } + util.Assert(status != 0, "status must be set") + util.Assert(status != t_api.StatusCreated || t != nil, "task must be non nil if status created") + return &t_api.Response{ Kind: t_api.CompleteTask, Tags: r.Tags, CompleteTask: &t_api.CompleteTaskResponse{ Status: status, + Task: t, }, }, nil } diff --git a/internal/app/coroutines/createCallback.go b/internal/app/coroutines/createCallback.go index a9b26712..58b16a93 100644 --- a/internal/app/coroutines/createCallback.go +++ b/internal/app/coroutines/createCallback.go @@ -1,7 +1,6 @@ package coroutines import ( - "encoding/json" "log/slog" "github.com/resonatehq/gocoro" @@ -53,19 +52,15 @@ func CreateCallback(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any return nil, t_api.NewError(t_api.StatusAIOStoreError, err) } - mesg, err := json.Marshal(&message.Mesg{ - Type: message.Resume, - Root: r.CreateCallback.RootPromiseId, - Leaf: r.CreateCallback.PromiseId, - }) - - if err != nil { - slog.Error("failed to marshal message", "err", err) - return nil, t_api.NewError(t_api.StatusAIOStoreError, err) - } - if p.State == promise.Pending { + mesg := &message.Mesg{ + Type: message.Resume, + Root: r.CreateCallback.RootPromiseId, + Leaf: r.CreateCallback.PromiseId, + } + createdOn := c.Time() + completion, err := gocoro.YieldAndAwait(c, &t_aio.Submission{ Kind: t_aio.Store, Tags: r.Tags, @@ -76,9 +71,9 @@ func CreateCallback(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: r.CreateCallback.PromiseId, - Timeout: r.CreateCallback.Timeout, Recv: r.CreateCallback.Recv, Mesg: mesg, + Timeout: r.CreateCallback.Timeout, CreatedOn: createdOn, }, }, @@ -106,11 +101,12 @@ func CreateCallback(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any CreateCallback: &t_api.CreateCallbackResponse{ Status: t_api.StatusCreated, Callback: &callback.Callback{ - Id: result.LastInsertId, - PromiseId: r.CreateCallback.PromiseId, - RootPromiseId: r.CreateCallback.RootPromiseId, - Recv: r.CreateCallback.Recv, - CreatedOn: createdOn, + Id: result.LastInsertId, + PromiseId: r.CreateCallback.PromiseId, + Recv: r.CreateCallback.Recv, + Mesg: mesg, + Timeout: r.CreateCallback.Timeout, + CreatedOn: createdOn, }, Promise: p, }, diff --git a/internal/app/coroutines/createPromise.go b/internal/app/coroutines/createPromise.go index 6d0a78eb..ceeee592 100644 --- a/internal/app/coroutines/createPromise.go +++ b/internal/app/coroutines/createPromise.go @@ -7,10 +7,70 @@ import ( "github.com/resonatehq/resonate/internal/kernel/t_aio" "github.com/resonatehq/resonate/internal/kernel/t_api" "github.com/resonatehq/resonate/internal/util" + "github.com/resonatehq/resonate/pkg/callback" + "github.com/resonatehq/resonate/pkg/message" "github.com/resonatehq/resonate/pkg/promise" + "github.com/resonatehq/resonate/pkg/task" ) func CreatePromise(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r *t_api.Request) (*t_api.Response, error) { + util.Assert(r.Kind == t_api.CreatePromise, "must be create promise") + + return createPromiseAndTaskOrCallback(c, r, r.CreatePromise) +} + +func CreatePromiseAndTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r *t_api.Request) (*t_api.Response, error) { + util.Assert(r.Kind == t_api.CreatePromiseAndTask, "must be create promise and task") + util.Assert(r.CreatePromiseAndTask.Promise.Id == r.CreatePromiseAndTask.Task.PromiseId, "promise ids must match") + util.Assert(r.CreatePromiseAndTask.Promise.Timeout == r.CreatePromiseAndTask.Task.Timeout, "timeouts must match") + + return createPromiseAndTaskOrCallback(c, r, r.CreatePromiseAndTask.Promise, &t_aio.Command{ + Kind: t_aio.CreateTask, + CreateTask: &t_aio.CreateTaskCommand{ + Recv: r.CreatePromiseAndTask.Task.Recv, + Mesg: &message.Mesg{Type: message.Invoke, Root: r.CreatePromiseAndTask.Task.PromiseId, Leaf: r.CreatePromiseAndTask.Task.PromiseId}, + Timeout: r.CreatePromiseAndTask.Task.Timeout, + ProcessId: &r.CreatePromiseAndTask.Task.ProcessId, + State: task.Claimed, + Frequency: r.CreatePromiseAndTask.Task.Frequency, + Expiration: c.Time() + int64(r.CreatePromiseAndTask.Task.Frequency), + CreatedOn: c.Time(), + }, + }) +} + +func CreatePromiseAndCallback(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r *t_api.Request) (*t_api.Response, error) { + util.Assert(r.Kind == t_api.CreatePromiseAndCallback, "must be create promise and callback") + util.Assert(r.CreatePromiseAndCallback.Promise.Id == r.CreatePromiseAndCallback.Callback.PromiseId, "promise ids must match") + + return createPromiseAndTaskOrCallback(c, r, r.CreatePromiseAndCallback.Promise, &t_aio.Command{ + Kind: t_aio.CreateCallback, + CreateCallback: &t_aio.CreateCallbackCommand{ + PromiseId: r.CreatePromiseAndCallback.Callback.PromiseId, + Recv: r.CreatePromiseAndCallback.Callback.Recv, + Mesg: &message.Mesg{Type: message.Resume, Root: r.CreatePromiseAndCallback.Callback.RootPromiseId, Leaf: r.CreatePromiseAndCallback.Callback.PromiseId}, + Timeout: r.CreatePromiseAndCallback.Callback.Timeout, + CreatedOn: c.Time(), + }, + }) +} + +func createPromiseAndTaskOrCallback( + c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], + r *t_api.Request, + createPromiseReq *t_api.CreatePromiseRequest, + additionalCmds ...*t_aio.Command, +) (*t_api.Response, error) { + util.Assert(r.Kind == t_api.CreatePromise || r.Kind == t_api.CreatePromiseAndTask || r.Kind == t_api.CreatePromiseAndCallback, "must be create promise or variant") + + // response status + var status t_api.StatusCode + + // response data + var p *promise.Promise + var t *task.Task + var cb *callback.Callback + // first read the promise to see if it already exists completion, err := gocoro.YieldAndAwait(c, &t_aio.Submission{ Kind: t_aio.Store, @@ -21,7 +81,7 @@ func CreatePromise(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any] { Kind: t_aio.ReadPromise, ReadPromise: &t_aio.ReadPromiseCommand{ - Id: r.CreatePromise.Id, + Id: createPromiseReq.Id, }, }, }, @@ -39,59 +99,85 @@ func CreatePromise(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any] result := completion.Store.Results[0].ReadPromise util.Assert(result.RowsReturned == 0 || result.RowsReturned == 1, "result must return 0 or 1 rows") - var res *t_api.Response - if result.RowsReturned == 0 { cmd := &t_aio.CreatePromiseCommand{ - Id: r.CreatePromise.Id, - Param: r.CreatePromise.Param, - Timeout: r.CreatePromise.Timeout, - IdempotencyKey: r.CreatePromise.IdempotencyKey, - Tags: r.CreatePromise.Tags, + Id: createPromiseReq.Id, + Param: createPromiseReq.Param, + Timeout: createPromiseReq.Timeout, + IdempotencyKey: createPromiseReq.IdempotencyKey, + Tags: createPromiseReq.Tags, CreatedOn: c.Time(), } // if the promise does not exist, create it - ok, err := gocoro.SpawnAndAwait(c, createPromise(r.Tags, cmd)) + completion, err := gocoro.SpawnAndAwait(c, createPromise(r.Tags, cmd, additionalCmds...)) if err != nil { return nil, err } - if !ok { + if completion.Store.Results[0].CreatePromise.RowsAffected == 0 { // It's possible that the promise was created by another coroutine // while we were creating. In that case, we should just retry. - return CreatePromise(c, r) + return createPromiseAndTaskOrCallback(c, r, createPromiseReq, additionalCmds...) } - res = &t_api.Response{ - Kind: t_api.CreatePromise, - Tags: r.Tags, - CreatePromise: &t_api.CreatePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: cmd.Id, - State: promise.Pending, - Param: cmd.Param, - Timeout: cmd.Timeout, - IdempotencyKeyForCreate: cmd.IdempotencyKey, - Tags: cmd.Tags, - CreatedOn: &cmd.CreatedOn, - }, - }, + // set status + status = t_api.StatusCreated + + // set promise + p = &promise.Promise{ + Id: cmd.Id, + State: promise.Pending, + Param: cmd.Param, + Timeout: cmd.Timeout, + IdempotencyKeyForCreate: cmd.IdempotencyKey, + Tags: cmd.Tags, + CreatedOn: &cmd.CreatedOn, + } + + switch r.Kind { + case t_api.CreatePromiseAndTask: + util.Assert(additionalCmds[0].Kind == t_aio.CreateTask, "command must be create task") + util.Assert(completion.Store.Results[1].Kind == t_aio.CreateTask, "completion must be create task") + cmd := additionalCmds[0].CreateTask + + t = &task.Task{ + Id: completion.Store.Results[1].CreateTask.LastInsertId, + ProcessId: cmd.ProcessId, + State: cmd.State, + Recv: cmd.Recv, + Mesg: cmd.Mesg, + Timeout: cmd.Timeout, + Counter: 0, + Attempt: 0, + Frequency: cmd.Frequency, + Expiration: cmd.Expiration, + CreatedOn: &cmd.CreatedOn, + } + case t_api.CreatePromiseAndCallback: + util.Assert(additionalCmds[0].Kind == t_aio.CreateCallback, "command must be create callback") + util.Assert(completion.Store.Results[1].Kind == t_aio.CreateCallback, "completion must be create callback") + cmd := additionalCmds[0].CreateCallback + + cb = &callback.Callback{ + Id: completion.Store.Results[1].CreateCallback.LastInsertId, + PromiseId: cmd.PromiseId, + Recv: cmd.Recv, + Mesg: cmd.Mesg, + Timeout: cmd.Timeout, + CreatedOn: cmd.CreatedOn, + } } } else { - p, err := result.Records[0].Promise() + p, err = result.Records[0].Promise() if err != nil { slog.Error("failed to parse promise record", "record", result.Records[0], "err", err) return nil, t_api.NewError(t_api.StatusAIOStoreError, err) } - // initial status - status := t_api.StatusPromiseAlreadyExists - if p.State == promise.Pending && p.Timeout <= c.Time() { cmd := &t_aio.UpdatePromiseCommand{ - Id: r.CreatePromise.Id, + Id: createPromiseReq.Id, State: promise.GetTimedoutState(p), Value: promise.Value{}, IdempotencyKey: nil, @@ -106,56 +192,44 @@ func CreatePromise(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any] if !ok { // It's possible that the promise was created by another coroutine // while we were timing out. In that case, we should just retry. - return CreatePromise(c, r) + return createPromiseAndTaskOrCallback(c, r, createPromiseReq, additionalCmds...) } - // switch status to ok if not strict and idempotency keys match - if !r.CreatePromise.Strict && p.IdempotencyKeyForCreate.Match(r.CreatePromise.IdempotencyKey) { + // set status to ok if not strict and idempotency keys match + if !createPromiseReq.Strict && p.IdempotencyKeyForCreate.Match(createPromiseReq.IdempotencyKey) { status = t_api.StatusOK + } else { + status = t_api.StatusPromiseAlreadyExists } - res = &t_api.Response{ - Kind: r.Kind, - Tags: r.Tags, - CreatePromise: &t_api.CreatePromiseResponse{ - Status: status, - Promise: &promise.Promise{ - Id: p.Id, - State: cmd.State, - Param: p.Param, - Value: cmd.Value, - Timeout: p.Timeout, - IdempotencyKeyForCreate: p.IdempotencyKeyForCreate, - IdempotencyKeyForComplete: cmd.IdempotencyKey, - Tags: p.Tags, - CreatedOn: p.CreatedOn, - CompletedOn: &cmd.CompletedOn, - }, - }, - } - } else { + // update promise + p.State = cmd.State + p.Value = cmd.Value + p.IdempotencyKeyForComplete = cmd.IdempotencyKey + p.CompletedOn = &cmd.CompletedOn + } else if !(createPromiseReq.Strict && p.State != promise.Pending) && p.IdempotencyKeyForCreate.Match(createPromiseReq.IdempotencyKey) { // switch status to ok if not strict and idempotency keys match - strict := r.CreatePromise.Strict && p.State != promise.Pending - if !strict && p.IdempotencyKeyForCreate.Match(r.CreatePromise.IdempotencyKey) { - status = t_api.StatusOK - } - - res = &t_api.Response{ - Kind: t_api.CreatePromise, - Tags: r.Tags, - CreatePromise: &t_api.CreatePromiseResponse{ - Status: status, - Promise: p, - }, - } + status = t_api.StatusOK + } else { + status = t_api.StatusPromiseAlreadyExists } } - util.Assert(res != nil, "response must not be nil") + res := &t_api.Response{Kind: r.Kind, Tags: r.Tags} + + switch r.Kind { + case t_api.CreatePromise: + res.CreatePromise = &t_api.CreatePromiseResponse{Status: status, Promise: p} + case t_api.CreatePromiseAndTask: + res.CreatePromiseAndTask = &t_api.CreatePromiseAndTaskResponse{Status: status, Promise: p, Task: t} + case t_api.CreatePromiseAndCallback: + res.CreatePromiseAndCallback = &t_api.CreatePromiseAndCallbackResponse{Status: status, Promise: p, Callback: cb} + } + return res, nil } -func createPromise(tags map[string]string, cmd *t_aio.CreatePromiseCommand, additionalCmds ...*t_aio.Command) gocoro.CoroutineFunc[*t_aio.Submission, *t_aio.Completion, bool] { +func createPromise(tags map[string]string, cmd *t_aio.CreatePromiseCommand, additionalCmds ...*t_aio.Command) gocoro.CoroutineFunc[*t_aio.Submission, *t_aio.Completion, *t_aio.Completion] { if cmd.Param.Headers == nil { cmd.Param.Headers = map[string]string{} } @@ -166,7 +240,7 @@ func createPromise(tags map[string]string, cmd *t_aio.CreatePromiseCommand, addi cmd.Tags = map[string]string{} } - return func(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, bool]) (bool, error) { + return func(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, *t_aio.Completion]) (*t_aio.Completion, error) { // add create promise command commands := []*t_aio.Command{{ Kind: t_aio.CreatePromise, @@ -176,7 +250,7 @@ func createPromise(tags map[string]string, cmd *t_aio.CreatePromiseCommand, addi // add additional commands commands = append(commands, additionalCmds...) - // check matcher to see if a task needs to be created + // check router to see if a task needs to be created completion, err := gocoro.YieldAndAwait(c, &t_aio.Submission{ Kind: t_aio.Router, Tags: tags, @@ -194,17 +268,22 @@ func createPromise(tags map[string]string, cmd *t_aio.CreatePromiseCommand, addi }) if err != nil { - slog.Warn("failed to match promise", "req", cmd, "err", err) + slog.Warn("failed to match promise", "cmd", cmd, "err", err) } if err == nil && completion.Router.Matched { - util.Assert(completion.Router.Command != nil, "command must not be nil") - completion.Router.Command.CreatedOn = cmd.CreatedOn + util.Assert(completion.Router.Recv != nil, "recv must not be nil") // add create task command if matched commands = append(commands, &t_aio.Command{ - Kind: t_aio.CreateTask, - CreateTask: completion.Router.Command, + Kind: t_aio.CreateTask, + CreateTask: &t_aio.CreateTaskCommand{ + Recv: completion.Router.Recv, + Mesg: &message.Mesg{Type: message.Invoke, Root: cmd.Id, Leaf: cmd.Id}, + Timeout: cmd.Timeout, + State: task.Init, + CreatedOn: cmd.CreatedOn, + }, }) } @@ -221,13 +300,13 @@ func createPromise(tags map[string]string, cmd *t_aio.CreatePromiseCommand, addi if err != nil { slog.Error("failed to create promise", "err", err) - return false, t_api.NewError(t_api.StatusAIOStoreError, err) + return nil, t_api.NewError(t_api.StatusAIOStoreError, err) } util.Assert(completion.Store != nil, "completion must not be nil") util.Assert(len(completion.Store.Results) == len(commands), "completion must have same number of results as commands") util.Assert(completion.Store.Results[0].CreatePromise.RowsAffected == 0 || completion.Store.Results[0].CreatePromise.RowsAffected == 1, "result must return 0 or 1 rows") - return completion.Store.Results[0].CreatePromise.RowsAffected == 1, nil + return completion, nil } } diff --git a/internal/app/coroutines/enqueueTasks.go b/internal/app/coroutines/enqueueTasks.go index cee05e65..0c8fb382 100644 --- a/internal/app/coroutines/enqueueTasks.go +++ b/internal/app/coroutines/enqueueTasks.go @@ -1,6 +1,7 @@ package coroutines import ( + "fmt" "log/slog" "github.com/resonatehq/gocoro" @@ -60,7 +61,10 @@ func EnqueueTasks(config *system.Config, tags map[string]string) gocoro.Coroutin Kind: t_aio.Sender, Tags: tags, Sender: &t_aio.SenderSubmission{ - Task: t, + Task: t, + ClaimHref: fmt.Sprintf("%s/tasks/claim/%s/%d", config.Url, t.Id, t.Counter), + CompleteHref: fmt.Sprintf("%s/tasks/complete/%s/%d", config.Url, t.Id, t.Counter), + HeartbeatHref: fmt.Sprintf("%s/tasks/heartbeat/%s/%d", config.Url, t.Id, t.Counter), }, }) } else { diff --git a/internal/app/coroutines/schedulePromises.go b/internal/app/coroutines/schedulePromises.go index 90aa3ebf..bc5ecd40 100644 --- a/internal/app/coroutines/schedulePromises.go +++ b/internal/app/coroutines/schedulePromises.go @@ -46,7 +46,7 @@ func SchedulePromises(config *system.Config, tags map[string]string) gocoro.Coro result := completion.Store.Results[0].ReadSchedules util.Assert(result != nil, "result must not be nil") - awaiting := make([]gocoroPromise.Awaitable[bool], len(result.Records)) + awaiting := make([]gocoroPromise.Awaitable[*t_aio.Completion], len(result.Records)) commands := make([]*t_aio.CreatePromiseCommand, len(result.Records)) for i, r := range result.Records { @@ -101,13 +101,13 @@ func SchedulePromises(config *system.Config, tags map[string]string) gocoro.Coro continue } - ok, err := gocoro.Await(c, awaiting[i]) + completion, err := gocoro.Await(c, awaiting[i]) if err != nil { slog.Error("failed to schedule promise", "err", err) continue } - if !ok { + if completion.Store.Results[0].CreatePromise.RowsAffected == 0 { slog.Warn("promise '%s' for schedule '%s' already exists", commands[i].Id, result.Records[i].Id) } } diff --git a/internal/app/plugins/http/http.go b/internal/app/plugins/http/http.go index 4a9999b5..42b5b8c5 100644 --- a/internal/app/plugins/http/http.go +++ b/internal/app/plugins/http/http.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "net/http" + "strconv" "time" "github.com/resonatehq/resonate/internal/aio" @@ -56,7 +57,7 @@ func (h *Http) Type() string { return "http" } -func (h *Http) Start() error { +func (h *Http) Start(chan<- error) error { for _, worker := range h.workers { go worker.Start() } @@ -93,7 +94,7 @@ func (w *HttpWorker) String() string { } func (w *HttpWorker) Start() { - counter := w.metrics.AioWorkerInFlight.WithLabelValues(w.String(), "0") + counter := w.metrics.AioWorkerInFlight.WithLabelValues(w.String(), strconv.Itoa(w.i)) w.metrics.AioWorker.WithLabelValues(w.String()).Inc() defer w.metrics.AioWorker.WithLabelValues(w.String()).Dec() diff --git a/internal/app/plugins/http/http_test.go b/internal/app/plugins/http/http_test.go index f3b17d4d..a5c2f9f7 100644 --- a/internal/app/plugins/http/http_test.go +++ b/internal/app/plugins/http/http_test.go @@ -59,7 +59,7 @@ func TestHttpPlugin(t *testing.T) { data, err := json.Marshal(tc.data) assert.Nil(t, err) - err = http.Start() + err = http.Start(nil) assert.Nil(t, err) ok := http.Enqueue(&aio.Message{ diff --git a/internal/app/plugins/poll/poll.go b/internal/app/plugins/poll/poll.go new file mode 100644 index 00000000..3b5007bb --- /dev/null +++ b/internal/app/plugins/poll/poll.go @@ -0,0 +1,416 @@ +package poll + +import ( + "context" + "encoding/json" + "fmt" + "log/slog" + "math/rand" // nosemgrep + "net" + "strings" + "time" + + "net/http" + + "github.com/prometheus/client_golang/prometheus" + "github.com/resonatehq/resonate/internal/aio" + "github.com/resonatehq/resonate/internal/kernel/t_aio" + "github.com/resonatehq/resonate/internal/metrics" + "github.com/resonatehq/resonate/internal/util" +) + +type Config struct { + Size int `flag:"size" desc:"submission buffered channel size" default:"100"` + BufferSize int `flag:"buffer-size" desc:"connection buffer size" default:"100"` + MaxConnections int `flag:"max-connections" desc:"maximum number of connections" default:"1000"` + Addr string `flag:"addr" desc:"http server address" default:":8002"` + Timeout time.Duration `flag:"timeout" desc:"http server graceful shutdown timeout" default:"10s"` +} + +type Poll struct { + sq chan *aio.Message + connect chan *connection + disconnect chan *connection + worker *PollWorker + server *PollServer +} + +type Data struct { + Group string `json:"group"` + Id string `json:"id"` +} + +type connection struct { + group string + id string + ch chan []byte +} + +type connections struct { + max int + len int + cnt prometheus.Gauge + conns map[string][]*connection +} + +func (cs *connections) get(group string, id string) (*connection, bool) { + if len(cs.conns[group]) == 0 { + return nil, false + } + + for _, conn := range cs.conns[group] { + if conn.id == id { + return conn, true + } + } + + // if there is no connection with the same id, choose a + // connection at random + return cs.conns[group][rand.Intn(len(cs.conns[group]))], true +} + +func (cs *connections) add(conn *connection) { + util.Assert(conn.ch != nil, "channel must not be nil") + + // first remove the current connection + cs.rmv(conn, false) + + // immediately close the connection if max connections is reached + if cs.len >= cs.max { + close(conn.ch) + return + } + + // then add the new connection + cs.conns[conn.group] = append(cs.conns[conn.group], conn) + cs.len++ + cs.cnt.Inc() +} + +func (cs *connections) rmv(conn *connection, match bool) { + util.Assert(conn.ch != nil, "channel must not be nil") + + // remove the connection iff the channels match, if the channels + // don't match then the connection has been usurped (and already + // closed) + for i, c := range cs.conns[conn.group] { + if c.id == conn.id && (c.ch == conn.ch || !match) { + close(c.ch) + cs.conns[conn.group] = append(cs.conns[conn.group][:i], cs.conns[conn.group][i+1:]...) + cs.len-- + cs.cnt.Dec() + return + } + } +} + +func New(a aio.AIO, metrics *metrics.Metrics, config *Config) (*Poll, error) { + sq := make(chan *aio.Message, config.Size) + + // connect channel is used to register new connections with the + // connection manager (worker) + connect := make(chan *connection, config.MaxConnections) + + // disconnect channel is used to unregister connections with the + // connection manager (worker) + disconnect := make(chan *connection, config.MaxConnections) + + handler := &PollHandler{ + config: config, + metrics: metrics, + connect: connect, + disconnect: disconnect, + } + + listen, err := net.Listen("tcp", config.Addr) + if err != nil { + return nil, err + } + + server := &PollServer{ + config: config, + listen: listen, + server: &http.Server{Handler: handler}, + } + + counter := metrics.AioConnection.WithLabelValues((&Poll{}).String()) + + worker := &PollWorker{ + sq: sq, + metrics: metrics, + counter: counter, + connect: connect, + disconnect: disconnect, + connections: connections{ + max: config.MaxConnections, + cnt: counter, + conns: map[string][]*connection{}, + }, + } + + return &Poll{ + sq: sq, + connect: connect, + disconnect: disconnect, + server: server, + worker: worker, + }, nil +} + +func (p *Poll) String() string { + return fmt.Sprintf("%s:poll", t_aio.Sender.String()) +} + +func (p *Poll) Type() string { + return "poll" +} + +func (p *Poll) Addr() string { + return p.server.listen.Addr().String() +} + +func (p *Poll) Start(errors chan<- error) error { + go p.server.Start(errors) + go p.worker.Start() + + return nil +} + +func (p *Poll) Stop() error { + // wait to close the connection channels, this can be done safely + // once the server has been stopped + defer close(p.connect) + defer close(p.disconnect) + + // immediately close the sq, this will signal the worker to start + // closing connections + close(p.sq) + + // stop the server + return p.server.Stop() +} + +func (p *Poll) Enqueue(msg *aio.Message) bool { + select { + case p.sq <- msg: + return true + default: + return false + } +} + +// Worker + +type PollWorker struct { + sq <-chan *aio.Message + metrics *metrics.Metrics + counter prometheus.Gauge + connect <-chan *connection + disconnect <-chan *connection + connections connections +} + +func (w *PollWorker) String() string { + return fmt.Sprintf("%s:poll", t_aio.Sender.String()) +} + +func (w *PollWorker) Start() { + counter := w.metrics.AioWorkerInFlight.WithLabelValues(w.String(), "0") + w.metrics.AioWorker.WithLabelValues(w.String()).Inc() + defer w.metrics.AioWorker.WithLabelValues(w.String()).Dec() + + var closed bool + + for { + select { + case conn, ok := <-w.connect: + if !ok { + return + } + + // register a connection + w.connections.add(conn) + case conn, ok := <-w.disconnect: + if !ok { + return + } + + // unregister a connection + w.connections.rmv(conn, true) + default: + // Note: this select occurs under the default case in order to + // prioritize the connect/disconnect channels, this minimizes the + // chance of attempting to send a message before a connection has + // been registered or after a connection has been closed + + if closed { + break + } + + select { + case conn, ok := <-w.connect: + if !ok { + return + } + w.connections.add(conn) + case conn, ok := <-w.disconnect: + if !ok { + return + } + w.connections.rmv(conn, true) + case mesg, ok := <-w.sq: + if !ok { + closed = true + break + } + + counter.Inc() + w.Process(mesg) + counter.Dec() + } + } + + if closed { + // when the server is closed don't immediately return because + // additional connections may still be established, the + // connect/disconnect channels will be closed once the server has + // been stopped, return then + for group, conns := range w.connections.conns { + for _, conn := range conns { + close(conn.ch) + w.connections.len-- + w.counter.Dec() + } + delete(w.connections.conns, group) + } + } + } +} + +func (w *PollWorker) Process(mesg *aio.Message) { + // unmarshal message + var data *Data + if err := json.Unmarshal(mesg.Data, &data); err != nil { + mesg.Done(false, err) + return + } + + // check if we have a connection + conn, ok := w.connections.get(data.Group, data.Id) + if !ok { + mesg.Done(false, fmt.Errorf("no connection found for group %s", data.Group)) + return + } + + // send message to connection + select { + case conn.ch <- mesg.Body: + mesg.Done(true, nil) + default: + mesg.Done(false, fmt.Errorf("connection full for group %s", data.Group)) + } +} + +// Server + +type PollServer struct { + config *Config + listen net.Listener + server *http.Server +} + +func (s *PollServer) Start(errors chan<- error) { + slog.Info("starting poll server", "addr", s.config.Addr) + if err := s.server.Serve(s.listen); err != nil && err != http.ErrServerClosed { + errors <- err + } +} + +func (s *PollServer) Stop() error { + ctx, cancel := context.WithTimeout(context.Background(), s.config.Timeout) + defer cancel() + + return s.server.Shutdown(ctx) +} + +type PollHandler struct { + config *Config + metrics *metrics.Metrics + connect chan<- *connection + disconnect chan<- *connection +} + +func (h *PollHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + // only GET requests are allowed + if r.Method != http.MethodGet { + http.Error(w, "method not allowed", http.StatusMethodNotAllowed) + return + } + + // extract group and id + parts := strings.Split(r.URL.Path, "/") + if len(parts) != 3 { + http.Error(w, "invalid request", http.StatusBadRequest) + return + } + + // request must support flushing + f, ok := w.(http.Flusher) + if !ok { + http.Error(w, "streaming not supported", http.StatusInternalServerError) + return + } + + conn := &connection{ + group: parts[1], + id: parts[2], + ch: make(chan []byte, h.config.BufferSize), + } + + if !h.Connect(conn) { + http.Error(w, "too many requests", http.StatusTooManyRequests) + return + } + + // now we can write headers and flush + w.Header().Set("Content-Type", "text/event-stream") + w.Header().Set("Cache-Control", "no-cache") + w.Header().Set("Connection", "keep-alive") + f.Flush() + + for { + select { + case data, ok := <-conn.ch: + if !ok { + return + } + + if _, err := w.Write([]byte("data: " + string(data) + "\n\n")); err != nil { // nosemgrep: no-direct-write-to-responsewriter + h.Disconnect(conn) + return + } + + f.Flush() + case <-r.Context().Done(): + h.Disconnect(conn) + return + } + } +} + +func (h *PollHandler) Connect(conn *connection) bool { + select { + case h.connect <- conn: + return true + default: + return false + } +} + +func (h *PollHandler) Disconnect(conn *connection) { + select { + case h.disconnect <- conn: + default: + panic("disconnect buffered channel must never be full") + } +} diff --git a/internal/app/plugins/poll/poll_test.go b/internal/app/plugins/poll/poll_test.go new file mode 100644 index 00000000..42d2a79e --- /dev/null +++ b/internal/app/plugins/poll/poll_test.go @@ -0,0 +1,300 @@ +package poll + +import ( + "bufio" + "fmt" + "io" + "net/http" + "strings" + "sync" + "testing" + "time" + + "github.com/prometheus/client_golang/prometheus" + "github.com/resonatehq/resonate/internal/aio" + "github.com/resonatehq/resonate/internal/metrics" + "github.com/stretchr/testify/assert" +) + +type Conn struct { + group string + id string +} + +type Mesg struct { + ok bool + mesg *aio.Message +} + +type Resp struct { + group string + id []string + data string +} + +func TestPollPlugin(t *testing.T) { + metrics := metrics.New(prometheus.NewRegistry()) + + for _, tc := range []struct { + name string + mc int + connections []*Conn + messages []*Mesg + expected []*Resp + }{ + { + name: "SameGroupAndId", + mc: 5, + connections: []*Conn{ + {"foo", "a"}, + {"foo", "b"}, + }, + messages: []*Mesg{ + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"a"}`), Body: []byte("ok1")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"a"}`), Body: []byte("ok2")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"a"}`), Body: []byte("ok3")}}, + }, + expected: []*Resp{ + {"foo", []string{"a"}, "data: ok1"}, + {"foo", []string{"a"}, "data: ok2"}, + {"foo", []string{"a"}, "data: ok3"}, + }, + }, + { + name: "SameGroup", + mc: 5, + connections: []*Conn{ + {"foo", "a"}, + {"foo", "b"}, + }, + messages: []*Mesg{ + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"c"}`), Body: []byte("ok1")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"c"}`), Body: []byte("ok2")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"c"}`), Body: []byte("ok3")}}, + }, + expected: []*Resp{ + {"foo", []string{"a", "b"}, "data: ok1"}, + {"foo", []string{"a", "b"}, "data: ok2"}, + {"foo", []string{"a", "b"}, "data: ok3"}, + }, + }, + { + name: "MultipleGroups", + mc: 5, + connections: []*Conn{ + {"foo", "a"}, + {"foo", "b"}, + {"bar", "a"}, + {"bar", "b"}, + }, + messages: []*Mesg{ + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"a"}`), Body: []byte("ok1")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"b"}`), Body: []byte("ok2")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"c"}`), Body: []byte("ok3")}}, + {true, &aio.Message{Data: []byte(`{"group":"bar","id":"a"}`), Body: []byte("ok1")}}, + {true, &aio.Message{Data: []byte(`{"group":"bar","id":"b"}`), Body: []byte("ok2")}}, + {true, &aio.Message{Data: []byte(`{"group":"bar","id":"c"}`), Body: []byte("ok3")}}, + {false, &aio.Message{Data: []byte(`{"group":"baz","id":"a"}`), Body: []byte("ko1")}}, + {false, &aio.Message{Data: []byte(`{"group":"baz","id":"b"}`), Body: []byte("ko2")}}, + {false, &aio.Message{Data: []byte(`{"group":"baz","id":"c"}`), Body: []byte("ko3")}}, + }, + expected: []*Resp{ + {"foo", []string{"a"}, "data: ok1"}, + {"foo", []string{"b"}, "data: ok2"}, + {"foo", []string{"a", "b"}, "data: ok3"}, + {"bar", []string{"a"}, "data: ok1"}, + {"bar", []string{"b"}, "data: ok2"}, + {"bar", []string{"a", "b"}, "data: ok3"}, + }, + }, + { + name: "NoConnection", + mc: 5, + messages: []*Mesg{ + {false, &aio.Message{Data: []byte(`{"group":"foo","id":"a"}`), Body: []byte("ko1")}}, + {false, &aio.Message{Data: []byte(`{"group":"foo","id":"b"}`), Body: []byte("ko2")}}, + {false, &aio.Message{Data: []byte(`{"group":"foo","id":"c"}`), Body: []byte("ko3")}}, + }, + }, + { + name: "ConnectionReplacesConnection", + mc: 5, + connections: []*Conn{ + {"foo", "a"}, + {"foo", "a"}, + }, + messages: []*Mesg{ + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"a"}`), Body: []byte("ok1")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"b"}`), Body: []byte("ok2")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"c"}`), Body: []byte("ok3")}}, + }, + expected: []*Resp{ + {"foo", []string{"a"}, "data: ok1"}, + {"foo", []string{"a"}, "data: ok2"}, + {"foo", []string{"a"}, "data: ok3"}, + }, + }, + { + name: "CannotExceedMaxConnections", + mc: 3, + connections: []*Conn{ + {"foo", "a"}, + {"foo", "b"}, + {"foo", "c"}, + {"foo", "d"}, + }, + messages: []*Mesg{ + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"d"}`), Body: []byte("ok1")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"d"}`), Body: []byte("ok2")}}, + {true, &aio.Message{Data: []byte(`{"group":"foo","id":"d"}`), Body: []byte("ok3")}}, + }, + expected: []*Resp{ + {"foo", []string{"a", "b", "c"}, "data: ok1"}, + {"foo", []string{"a", "b", "c"}, "data: ok2"}, + {"foo", []string{"a", "b", "c"}, "data: ok3"}, + }, + }, + } { + t.Run(tc.name, func(t *testing.T) { + config := &Config{ + Size: 100, + BufferSize: 100, + MaxConnections: tc.mc, + Addr: ":0", + Timeout: 1 * time.Second, + } + + poll, err := New(nil, metrics, config) + assert.Nil(t, err) + + errors := make(chan error, 100) + if err := poll.Start(errors); err != nil { + t.Fatal(err) + } + + backchannel := make(chan struct{ group, id, data string }, len(tc.messages)) + var disconnected sync.WaitGroup + + // establish connections + for _, conn := range tc.connections { + disconnected.Add(1) + + res, err := http.Get(fmt.Sprintf("http://%s/%s/%s", poll.Addr(), conn.group, conn.id)) + if err != nil { + t.Fatal(err) + } + + reader := bufio.NewReader(res.Body) + defer res.Body.Close() + + go func() { + defer disconnected.Done() + + for { + // read each SSE message + data, err := reader.ReadBytes('\n') + if err == io.EOF { + return + } else if err != nil { + // panic because we are in a goroutine + panic(err) + } + + // SSE messages are terminated by two newlines but ReadBytes + // requires a single byte delimiter, so skip the second read + if string(data) == "\n" { + continue + } + + // send the message to the backchannel + backchannel <- struct{ group, id, data string }{conn.group, conn.id, strings.TrimSpace(string(data))} + } + }() + } + + // count and assert active connections + ac := 0 + for _, c := range poll.worker.connections.conns { + ac = ac + len(c) + } + assert.Equal(t, ac, poll.worker.connections.len) + + // assert max connections is not exceeded + assert.LessOrEqual(t, ac, config.MaxConnections) + + // count unique connections + uc := unique(tc.connections) + + // assert ac is equal to min of uc/mc + assert.Equal(t, min(uc, config.MaxConnections), ac) + + // send messages + for _, mesg := range tc.messages { + mesg.mesg.Done = func(ok bool, err error) { + assert.Equal(t, mesg.ok, ok) + if ok { + assert.Nil(t, err) + } else { + assert.NotNil(t, err) + } + } + assert.True(t, poll.Enqueue(mesg.mesg)) + } + + // close the poll server + if err := poll.Stop(); err != nil { + t.Fatal(err) + } + + // wait until all connections have disconnected + disconnected.Wait() + + // close the channels + close(errors) + close(backchannel) + + // assert no active connections + assert.Zero(t, poll.worker.connections.len) + + // assert no errors + for err := range errors { + assert.Fail(t, err.Error()) + } + + // assert backchannel messages + for mesg := range backchannel { + assert.Condition(t, func() bool { + for i, expected := range tc.expected { + if mesg.group == expected.group && contains(expected.id, mesg.id) && mesg.data == expected.data { + // remove from expected + tc.expected = append(tc.expected[:i], tc.expected[i+1:]...) + return true + } + } + return false + }) + } + + // all expected messages should have been received + assert.Empty(t, tc.expected, "expected messages not received") + }) + } +} + +func contains[T comparable](arr []T, val T) bool { + for _, v := range arr { + if v == val { + return true + } + } + return false +} + +func unique(conns []*Conn) int { + set := make(map[string]struct{}) + for _, c := range conns { + set[fmt.Sprintf("%s.%s", c.group, c.id)] = struct{}{} + } + + return len(set) +} diff --git a/internal/app/subsystems/aio/echo/echo.go b/internal/app/subsystems/aio/echo/echo.go index 64ab06be..709d5795 100644 --- a/internal/app/subsystems/aio/echo/echo.go +++ b/internal/app/subsystems/aio/echo/echo.go @@ -56,7 +56,7 @@ func (e *Echo) Kind() t_aio.Kind { return t_aio.Echo } -func (e *Echo) Start() error { +func (e *Echo) Start(chan<- error) error { for _, worker := range e.workers { go worker.Start() } diff --git a/internal/app/subsystems/aio/router/router.go b/internal/app/subsystems/aio/router/router.go index 4bc73736..cbe70afe 100644 --- a/internal/app/subsystems/aio/router/router.go +++ b/internal/app/subsystems/aio/router/router.go @@ -7,13 +7,13 @@ import ( "log/slog" "net/url" "strconv" + "strings" "github.com/resonatehq/resonate/internal/aio" "github.com/resonatehq/resonate/internal/kernel/bus" "github.com/resonatehq/resonate/internal/kernel/t_aio" "github.com/resonatehq/resonate/internal/metrics" "github.com/resonatehq/resonate/internal/util" - "github.com/resonatehq/resonate/pkg/message" "github.com/resonatehq/resonate/pkg/promise" "github.com/resonatehq/resonate/pkg/receiver" ) @@ -47,7 +47,12 @@ func New(aio aio.AIO, metrics *metrics.Metrics, config *Config) (*Router, error) workers := make([]*RouterWorker, config.Workers) sources := make([]func(*promise.Promise) (any, bool), len(config.Sources)) + var found bool for i, source := range config.Sources { + if source.Name == "default" { + found = true + } + switch source.Type { case "tag": var config *TagSourceConfig @@ -61,6 +66,11 @@ func New(aio aio.AIO, metrics *metrics.Metrics, config *Config) (*Router, error) } } + if !found { + // add default source if none found + sources = append(sources, TagSource(&TagSourceConfig{Key: "resonate:invoke"})) + } + for i := 0; i < config.Workers; i++ { workers[i] = &RouterWorker{ i: i, @@ -86,7 +96,7 @@ func (r *Router) Kind() t_aio.Kind { return t_aio.Router } -func (r *Router) Start() error { +func (r *Router) Start(chan<- error) error { for _, worker := range r.workers { go worker.Start() } @@ -178,26 +188,12 @@ func (w *RouterWorker) Process(sqe *bus.SQE[t_aio.Submission, t_aio.Completion]) break } - mesg, err := json.Marshal(&message.Mesg{ - Type: message.Invoke, - Root: sqe.Submission.Router.Promise.Id, - Leaf: sqe.Submission.Router.Promise.Id, - }) - if err != nil { - slog.Error("failed to marshal mesg", "err", err) - break - } - cqe.Completion = &t_aio.Completion{ Kind: t_aio.Router, Tags: sqe.Submission.Tags, Router: &t_aio.RouterCompletion{ Matched: true, - Command: &t_aio.CreateTaskCommand{ - Recv: recv, - Mesg: mesg, - Timeout: sqe.Submission.Router.Promise.Timeout, - }, + Recv: recv, }, } return cqe @@ -253,7 +249,7 @@ func coerce(v any) (any, bool) { case *receiver.Recv: return v, true case string: - if recv, ok := protocolToRecv(v); ok { + if recv, ok := schemeToRecv(v); ok { return recv, true } @@ -265,25 +261,28 @@ func coerce(v any) (any, bool) { } } -func protocolToRecv(v string) (*receiver.Recv, bool) { - switch protocol(v) { +func schemeToRecv(v string) (*receiver.Recv, bool) { + u, err := url.Parse(v) + if err != nil { + return nil, false + } + + switch u.Scheme { case "http", "https": - data, err := json.Marshal(map[string]interface{}{"url": v}) + data, err := json.Marshal(map[string]interface{}{"url": u.String()}) if err != nil { return nil, false } return &receiver.Recv{Type: "http", Data: data}, true + case "poll": + data, err := json.Marshal(map[string]interface{}{"group": u.Host, "id": strings.TrimPrefix(u.Path, "/")}) + if err != nil { + return nil, false + } + + return &receiver.Recv{Type: "poll", Data: data}, true default: return nil, false } } - -func protocol(value string) string { - url, err := url.Parse(value) - if err != nil { - return "" - } - - return url.Scheme -} diff --git a/internal/app/subsystems/aio/sender/sender.go b/internal/app/subsystems/aio/sender/sender.go index c6ded973..a2a2fcfb 100644 --- a/internal/app/subsystems/aio/sender/sender.go +++ b/internal/app/subsystems/aio/sender/sender.go @@ -7,6 +7,7 @@ import ( "github.com/resonatehq/resonate/internal/aio" "github.com/resonatehq/resonate/internal/app/plugins/http" + "github.com/resonatehq/resonate/internal/app/plugins/poll" "github.com/resonatehq/resonate/internal/kernel/bus" "github.com/resonatehq/resonate/internal/kernel/t_aio" "github.com/resonatehq/resonate/internal/metrics" @@ -24,6 +25,7 @@ type Config struct { type PluginConfig struct { Http EnabledPlugin[http.Config] `flag:"http"` + Poll EnabledPlugin[poll.Config] `flag:"poll"` } type EnabledPlugin[T any] struct { @@ -46,6 +48,14 @@ func (c *PluginConfig) Instantiate(a aio.AIO, metrics *metrics.Metrics) ([]aio.P plugins = append(plugins, plugin) } + if c.Poll.Enabled { + plugin, err := poll.New(a, metrics, &c.Poll.Config) + if err != nil { + return nil, err + } + + plugins = append(plugins, plugin) + } return plugins, nil } @@ -106,10 +116,10 @@ func (s *Sender) Kind() t_aio.Kind { return t_aio.Sender } -func (s *Sender) Start() error { +func (s *Sender) Start(errors chan<- error) error { // start plugins for _, plugin := range s.plugins { - if err := plugin.Start(); err != nil { + if err := plugin.Start(errors); err != nil { return err } } @@ -224,8 +234,12 @@ func (w *SenderWorker) Process(sqe *bus.SQE[t_aio.Submission, t_aio.Completion]) } body, err := json.Marshal(map[string]interface{}{ - "id": sqe.Submission.Sender.Task.Id, - "counter": sqe.Submission.Sender.Task.Counter, + "task": sqe.Submission.Sender.Task, + "href": map[string]string{ + "claim": sqe.Submission.Sender.ClaimHref, + "complete": sqe.Submission.Sender.CompleteHref, + "heartbeat": sqe.Submission.Sender.HeartbeatHref, + }, }) if err != nil { cqe.Error = err diff --git a/internal/app/subsystems/aio/sender/sender_dst.go b/internal/app/subsystems/aio/sender/sender_dst.go index f3ab954e..671716b4 100644 --- a/internal/app/subsystems/aio/sender/sender_dst.go +++ b/internal/app/subsystems/aio/sender/sender_dst.go @@ -38,7 +38,7 @@ func (s *SenderDST) Kind() t_aio.Kind { return t_aio.Sender } -func (s *SenderDST) Start() error { +func (s *SenderDST) Start(chan<- error) error { return nil } diff --git a/internal/app/subsystems/aio/store/postgres/postgres.go b/internal/app/subsystems/aio/store/postgres/postgres.go index 91b8f6bd..a9e21aaf 100644 --- a/internal/app/subsystems/aio/store/postgres/postgres.go +++ b/internal/app/subsystems/aio/store/postgres/postgres.go @@ -49,9 +49,9 @@ const ( CREATE TABLE IF NOT EXISTS callbacks ( id SERIAL PRIMARY KEY, promise_id TEXT, - timeout INTEGER, recv BYTEA, mesg BYTEA, + timeout INTEGER, created_on BIGINT ); @@ -80,10 +80,10 @@ const ( recv BYTEA, mesg BYTEA, timeout BIGINT, - counter INTEGER, - attempt INTEGER, - frequency INTEGER, - expiration BIGINT, + counter INTEGER DEFAULT 1, + attempt INTEGER DEFAULT 0, + frequency INTEGER DEFAULT 0, + expiration BIGINT DEFAULT 0, created_on BIGINT, completed_on BIGINT ); @@ -169,7 +169,7 @@ const ( CALLBACK_INSERT_STATEMENT = ` INSERT INTO callbacks - (promise_id, timeout, recv, mesg, created_on) + (promise_id, recv, mesg, timeout, created_on) SELECT $1, $2, $3, $4, $5 WHERE EXISTS @@ -287,15 +287,16 @@ const ( TASK_INSERT_STATEMENT = ` INSERT INTO tasks - (recv, mesg, timeout, counter, attempt, frequency, expiration, created_on) + (recv, mesg, timeout, pid, state, frequency, expiration, created_on) VALUES - ($1, $2, $3, 0, 0, 0, 0, $4)` + ($1, $2, $3, $4, $5, $6, $7, $8) + RETURNING id` TASK_INSERT_ALL_STATEMENT = ` INSERT INTO tasks - (recv, mesg, timeout, counter, attempt, frequency, expiration, created_on) + (recv, mesg, timeout, created_on) SELECT - recv, mesg, timeout, 0, 0, 0, 0, $1 + recv, mesg, timeout, $1 FROM callbacks WHERE @@ -399,7 +400,7 @@ func (s *PostgresStore) Kind() t_aio.Kind { return t_aio.Store } -func (s *PostgresStore) Start() error { +func (s *PostgresStore) Start(chan<- error) error { if _, err := s.db.Exec(CREATE_TABLE_STATEMENT); err != nil { return err } @@ -536,7 +537,6 @@ func (w *PostgresStoreWorker) performCommands(tx *sql.Tx, transactions []*t_aio. var lockReleaseStmt *sql.Stmt var lockHeartbeatStmt *sql.Stmt var lockTimeoutStmt *sql.Stmt - var taskInsertStmt *sql.Stmt var tasksInsertStmt *sql.Stmt var taskUpdateStmt *sql.Stmt var taskHeartbeatStmt *sql.Stmt @@ -702,16 +702,8 @@ func (w *PostgresStoreWorker) performCommands(tx *sql.Tx, transactions []*t_aio. util.Assert(command.ReadTasks != nil, "command must not be nil") results[i][j], err = w.readTasks(tx, command.ReadTasks) case t_aio.CreateTask: - if taskInsertStmt == nil { - taskInsertStmt, err = tx.Prepare(TASK_INSERT_STATEMENT) - if err != nil { - return nil, err - } - defer taskInsertStmt.Close() - } - util.Assert(command.CreateTask != nil, "command must not be nil") - results[i][j], err = w.createTask(tx, taskInsertStmt, command.CreateTask) + results[i][j], err = w.createTask(tx, command.CreateTask) case t_aio.CreateTasks: if tasksInsertStmt == nil { tasksInsertStmt, err = tx.Prepare(TASK_INSERT_ALL_STATEMENT) @@ -995,9 +987,17 @@ func (w *PostgresStoreWorker) updatePromise(tx *sql.Tx, stmt *sql.Stmt, cmd *t_a // Callbacks func (w *PostgresStoreWorker) createCallback(tx *sql.Tx, cmd *t_aio.CreateCallbackCommand) (*t_aio.Result, error) { + util.Assert(cmd.Recv != nil, "recv must not be nil") + util.Assert(cmd.Mesg != nil, "mesg must not be nil") + + mesg, err := json.Marshal(cmd.Mesg) + if err != nil { + return nil, err + } + var lastInsertId string rowsAffected := int64(1) - row := tx.QueryRow(CALLBACK_INSERT_STATEMENT, cmd.PromiseId, cmd.Timeout, cmd.Recv, cmd.Mesg, cmd.CreatedOn) + row := tx.QueryRow(CALLBACK_INSERT_STATEMENT, cmd.PromiseId, cmd.Recv, mesg, cmd.Timeout, cmd.CreatedOn) if err := row.Scan(&lastInsertId); err != nil { if err == sql.ErrNoRows { @@ -1468,21 +1468,34 @@ func (w *PostgresStoreWorker) readTasks(tx *sql.Tx, cmd *t_aio.ReadTasksCommand) }, nil } -func (w *PostgresStoreWorker) createTask(tx *sql.Tx, stmt *sql.Stmt, cmd *t_aio.CreateTaskCommand) (*t_aio.Result, error) { - res, err := stmt.Exec(cmd.Recv, cmd.Mesg, cmd.Timeout, cmd.CreatedOn) +func (w *PostgresStoreWorker) createTask(tx *sql.Tx, cmd *t_aio.CreateTaskCommand) (*t_aio.Result, error) { + util.Assert(cmd.Recv != nil, "recv must not be nil") + util.Assert(cmd.Mesg != nil, "mesg must not be nil") + util.Assert(cmd.State.In(task.Init|task.Claimed), "state must be init or claimed") + util.Assert(cmd.State != task.Claimed || cmd.ProcessId != nil, "pid must be set if state is claimed") + + mesg, err := json.Marshal(cmd.Mesg) if err != nil { return nil, err } - rowsAffected, err := res.RowsAffected() - if err != nil { - return nil, err + var lastInsertId string + rowsAffected := int64(1) + row := tx.QueryRow(TASK_INSERT_STATEMENT, cmd.Recv, mesg, cmd.Timeout, cmd.ProcessId, cmd.State, cmd.Frequency, cmd.Expiration, cmd.CreatedOn) + + if err := row.Scan(&lastInsertId); err != nil { + if err == sql.ErrNoRows { + rowsAffected = 0 + } else { + return nil, err + } } return &t_aio.Result{ Kind: t_aio.CreateTask, CreateTask: &t_aio.AlterTasksResult{ RowsAffected: rowsAffected, + LastInsertId: lastInsertId, }, }, nil } diff --git a/internal/app/subsystems/aio/store/postgres/postgres_test.go b/internal/app/subsystems/aio/store/postgres/postgres_test.go index f9637fdc..b617dce9 100644 --- a/internal/app/subsystems/aio/store/postgres/postgres_test.go +++ b/internal/app/subsystems/aio/store/postgres/postgres_test.go @@ -39,7 +39,7 @@ func TestPostgresStore(t *testing.T) { if err != nil { t.Fatal(err) } - if err := store.Start(); err != nil { + if err := store.Start(nil); err != nil { t.Fatal(err) } diff --git a/internal/app/subsystems/aio/store/sqlite/sqlite.go b/internal/app/subsystems/aio/store/sqlite/sqlite.go index c45d918e..f4402e80 100644 --- a/internal/app/subsystems/aio/store/sqlite/sqlite.go +++ b/internal/app/subsystems/aio/store/sqlite/sqlite.go @@ -48,9 +48,9 @@ const ( CREATE TABLE IF NOT EXISTS callbacks ( id INTEGER PRIMARY KEY AUTOINCREMENT, promise_id TEXT, - timeout INTEGER, recv BLOB, mesg BLOB, + timeout INTEGER, created_on INTEGER ); @@ -93,10 +93,10 @@ const ( recv BLOB, mesg BLOB, timeout INTEGER, - counter INTEGER, - attempt INTEGER, - frequency INTEGER, - expiration INTEGER, + counter INTEGER DEFAULT 1, + attempt INTEGER DEFAULT 0, + frequency INTEGER DEFAULT 0, + expiration INTEGER DEFAULT 0, created_on INTEGER, completed_on INTEGER ); @@ -157,7 +157,7 @@ const ( CALLBACK_INSERT_STATEMENT = ` INSERT INTO callbacks - (promise_id, timeout, recv, mesg, created_on) + (promise_id, recv, mesg, timeout, created_on) SELECT ?, ?, ?, ?, ? WHERE EXISTS @@ -275,15 +275,15 @@ const ( TASK_INSERT_STATEMENT = ` INSERT INTO tasks - (recv, mesg, timeout, counter, attempt, frequency, expiration, created_on) + (recv, mesg, timeout, pid, state, frequency, expiration, created_on) VALUES - (?, ?, ?, 0, 0, 0, 0, ?)` + (?, ?, ?, ?, ?, ?, ?, ?)` TASK_INSERT_ALL_STATEMENT = ` INSERT INTO tasks - (recv, mesg, timeout, counter, attempt, frequency, expiration, created_on) + (recv, mesg, timeout, created_on) SELECT - recv, mesg, timeout, 0, 0, 0, 0, ? + recv, mesg, timeout, ? FROM callbacks WHERE @@ -358,7 +358,7 @@ func (s *SqliteStore) Kind() t_aio.Kind { return t_aio.Store } -func (s *SqliteStore) Start() error { +func (s *SqliteStore) Start(chan<- error) error { if _, err := s.db.Exec(CREATE_TABLE_STATEMENT); err != nil { return err } @@ -962,7 +962,15 @@ func (w *SqliteStoreWorker) updatePromise(tx *sql.Tx, stmt *sql.Stmt, cmd *t_aio // Callbacks func (w *SqliteStoreWorker) createCallback(tx *sql.Tx, stmt *sql.Stmt, cmd *t_aio.CreateCallbackCommand) (*t_aio.Result, error) { - res, err := stmt.Exec(cmd.PromiseId, cmd.Timeout, cmd.Recv, cmd.Mesg, cmd.CreatedOn, cmd.PromiseId) + util.Assert(cmd.Recv != nil, "recv must not be nil") + util.Assert(cmd.Mesg != nil, "mesg must not be nil") + + mesg, err := json.Marshal(cmd.Mesg) + if err != nil { + return nil, err + } + + res, err := stmt.Exec(cmd.PromiseId, cmd.Recv, mesg, cmd.Timeout, cmd.CreatedOn, cmd.PromiseId) if err != nil { return nil, err } @@ -1456,7 +1464,17 @@ func (w *SqliteStoreWorker) readTasks(tx *sql.Tx, cmd *t_aio.ReadTasksCommand) ( } func (w *SqliteStoreWorker) createTask(tx *sql.Tx, stmt *sql.Stmt, cmd *t_aio.CreateTaskCommand) (*t_aio.Result, error) { - res, err := stmt.Exec(cmd.Recv, cmd.Mesg, cmd.Timeout, cmd.CreatedOn) + util.Assert(cmd.Recv != nil, "recv must not be nil") + util.Assert(cmd.Mesg != nil, "mesg must not be nil") + util.Assert(cmd.State.In(task.Init|task.Claimed), "state must be init or claimed") + util.Assert(cmd.State != task.Claimed || cmd.ProcessId != nil, "pid must be set if state is claimed") + + mesg, err := json.Marshal(cmd.Mesg) + if err != nil { + return nil, err + } + + res, err := stmt.Exec(cmd.Recv, mesg, cmd.Timeout, cmd.ProcessId, cmd.State, cmd.Frequency, cmd.Expiration, cmd.CreatedOn) if err != nil { return nil, err } @@ -1466,10 +1484,21 @@ func (w *SqliteStoreWorker) createTask(tx *sql.Tx, stmt *sql.Stmt, cmd *t_aio.Cr return nil, err } + lastInsertId, err := res.LastInsertId() + if err != nil { + return nil, err + } + + var lastInsertIdStr string + if rowsAffected != 0 { + lastInsertIdStr = strconv.FormatInt(lastInsertId, 10) + } + return &t_aio.Result{ Kind: t_aio.CreateTask, CreateTask: &t_aio.AlterTasksResult{ RowsAffected: rowsAffected, + LastInsertId: lastInsertIdStr, }, }, nil } diff --git a/internal/app/subsystems/aio/store/sqlite/sqlite_test.go b/internal/app/subsystems/aio/store/sqlite/sqlite_test.go index 5de4671d..b094c47b 100644 --- a/internal/app/subsystems/aio/store/sqlite/sqlite_test.go +++ b/internal/app/subsystems/aio/store/sqlite/sqlite_test.go @@ -21,7 +21,7 @@ func TestSqliteStore(t *testing.T) { if err != nil { t.Fatal(err) } - if err := store.Start(); err != nil { + if err := store.Start(nil); err != nil { t.Fatal(err) } diff --git a/internal/app/subsystems/aio/store/test/cases.go b/internal/app/subsystems/aio/store/test/cases.go index c271d9d5..e5e4e11b 100644 --- a/internal/app/subsystems/aio/store/test/cases.go +++ b/internal/app/subsystems/aio/store/test/cases.go @@ -8,6 +8,7 @@ import ( "github.com/resonatehq/resonate/internal/util" "github.com/resonatehq/resonate/pkg/idempotency" "github.com/resonatehq/resonate/pkg/lock" + "github.com/resonatehq/resonate/pkg/message" "github.com/resonatehq/resonate/pkg/promise" "github.com/resonatehq/resonate/pkg/schedule" "github.com/resonatehq/resonate/pkg/task" @@ -56,18 +57,18 @@ func (c *testCase) Run(t *testing.T, store store.Store) { } case t_aio.ReadSchedule: for _, record := range result.ReadSchedule.Records { - record.Tags = normalizeJSON(record.Tags) record.PromiseParamHeaders = normalizeJSON(record.PromiseParamHeaders) + record.Tags = normalizeJSON(record.Tags) } case t_aio.ReadSchedules: for _, record := range result.ReadSchedules.Records { - record.Tags = normalizeJSON(record.Tags) record.PromiseParamHeaders = normalizeJSON(record.PromiseParamHeaders) + record.Tags = normalizeJSON(record.Tags) } case t_aio.SearchSchedules: for _, record := range result.SearchSchedules.Records { - record.Tags = normalizeJSON(record.Tags) record.PromiseParamHeaders = normalizeJSON(record.PromiseParamHeaders) + record.Tags = normalizeJSON(record.Tags) } } } @@ -2050,6 +2051,8 @@ var TestCases = []*testCase{ Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", + Recv: []byte("foo"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, }, @@ -2076,6 +2079,8 @@ var TestCases = []*testCase{ Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", + Recv: []byte("foo"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, }, @@ -2111,6 +2116,8 @@ var TestCases = []*testCase{ Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", + Recv: []byte("foo"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, { @@ -2133,6 +2140,8 @@ var TestCases = []*testCase{ Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "bar", + Recv: []byte("bar"), + Mesg: &message.Mesg{Type: message.Resume, Root: "bar", Leaf: "bar"}, }, }, { @@ -2155,6 +2164,8 @@ var TestCases = []*testCase{ Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "baz", + Recv: []byte("baz"), + Mesg: &message.Mesg{Type: message.Resume, Root: "baz", Leaf: "baz"}, }, }, { @@ -2177,6 +2188,8 @@ var TestCases = []*testCase{ Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "qux", + Recv: []byte("qux"), + Mesg: &message.Mesg{Type: message.Resume, Root: "qux", Leaf: "qux"}, }, }, }, @@ -2278,18 +2291,24 @@ var TestCases = []*testCase{ Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", + Recv: []byte("foo1"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, { Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", + Recv: []byte("foo2"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, { Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "bar", + Recv: []byte("bar1"), + Mesg: &message.Mesg{Type: message.Resume, Root: "bar", Leaf: "bar"}, }, }, { @@ -2728,8 +2747,9 @@ var TestCases = []*testCase{ Kind: t_aio.CreateTask, CreateTask: &t_aio.CreateTaskCommand{ Recv: []byte("foo"), - Mesg: []byte("foo"), + Mesg: &message.Mesg{Type: message.Invoke, Root: "foo", Leaf: "foo"}, Timeout: 1, + State: task.Init, CreatedOn: 1, }, }, @@ -2737,8 +2757,9 @@ var TestCases = []*testCase{ Kind: t_aio.CreateTask, CreateTask: &t_aio.CreateTaskCommand{ Recv: []byte("bar"), - Mesg: []byte("bar"), + Mesg: &message.Mesg{Type: message.Invoke, Root: "bar", Leaf: "bar"}, Timeout: 2, + State: task.Init, CreatedOn: 2, }, }, @@ -2755,12 +2776,14 @@ var TestCases = []*testCase{ Kind: t_aio.CreateTask, CreateTask: &t_aio.AlterTasksResult{ RowsAffected: 1, + LastInsertId: "1", }, }, { Kind: t_aio.CreateTask, CreateTask: &t_aio.AlterTasksResult{ RowsAffected: 1, + LastInsertId: "2", }, }, { @@ -2770,17 +2793,19 @@ var TestCases = []*testCase{ Records: []*task.TaskRecord{ { Id: "1", + Counter: 1, State: task.Init, Recv: []byte("foo"), - Mesg: []byte("foo"), + Mesg: []byte(`{"type":"invoke","root":"foo","leaf":"foo"}`), Timeout: 1, CreatedOn: util.ToPointer[int64](1), }, { Id: "2", + Counter: 1, State: task.Init, Recv: []byte("bar"), - Mesg: []byte("bar"), + Mesg: []byte(`{"type":"invoke","root":"bar","leaf":"bar"}`), Timeout: 2, CreatedOn: util.ToPointer[int64](2), }, @@ -2805,7 +2830,7 @@ var TestCases = []*testCase{ CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", Recv: []byte("foo"), - Mesg: []byte("foo"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, { @@ -2813,7 +2838,7 @@ var TestCases = []*testCase{ CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", Recv: []byte("bar"), - Mesg: []byte("bar"), + Mesg: &message.Mesg{Type: message.Resume, Root: "bar", Leaf: "bar"}, }, }, { @@ -2821,7 +2846,7 @@ var TestCases = []*testCase{ CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", Recv: []byte("baz"), - Mesg: []byte("baz"), + Mesg: &message.Mesg{Type: message.Resume, Root: "baz", Leaf: "baz"}, }, }, { @@ -2879,23 +2904,26 @@ var TestCases = []*testCase{ Records: []*task.TaskRecord{ { Id: "1", + Counter: 1, State: task.Init, Recv: []byte("foo"), - Mesg: []byte("foo"), + Mesg: []byte(`{"type":"resume","root":"foo","leaf":"foo"}`), CreatedOn: util.ToPointer[int64](0), }, { Id: "2", + Counter: 1, State: task.Init, Recv: []byte("bar"), - Mesg: []byte("bar"), + Mesg: []byte(`{"type":"resume","root":"bar","leaf":"bar"}`), CreatedOn: util.ToPointer[int64](0), }, { Id: "3", + Counter: 1, State: task.Init, Recv: []byte("baz"), - Mesg: []byte("baz"), + Mesg: []byte(`{"type":"resume","root":"baz","leaf":"baz"}`), CreatedOn: util.ToPointer[int64](0), }, }, @@ -2919,7 +2947,7 @@ var TestCases = []*testCase{ CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", Recv: []byte("foo"), - Mesg: []byte("foo"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, { @@ -2934,13 +2962,13 @@ var TestCases = []*testCase{ Id: "1", ProcessId: util.ToPointer("pid"), State: task.Enqueued, - Counter: 1, + Counter: 2, Attempt: 1, Frequency: 1, Expiration: 1, CompletedOn: util.ToPointer[int64](1), CurrentStates: []task.State{task.Init}, - CurrentCounter: 0, + CurrentCounter: 1, }, }, { @@ -2949,13 +2977,13 @@ var TestCases = []*testCase{ Id: "1", ProcessId: util.ToPointer("pid"), State: task.Claimed, - Counter: 2, + Counter: 3, Attempt: 2, Frequency: 2, Expiration: 2, CompletedOn: util.ToPointer[int64](2), CurrentStates: []task.State{task.Enqueued}, - CurrentCounter: 0, // mimatch + CurrentCounter: 1, // mismatch }, }, { @@ -2964,13 +2992,13 @@ var TestCases = []*testCase{ Id: "1", ProcessId: util.ToPointer("pid"), State: task.Claimed, - Counter: 3, + Counter: 4, Attempt: 3, Frequency: 3, Expiration: 3, CompletedOn: util.ToPointer[int64](3), CurrentStates: []task.State{task.Enqueued}, - CurrentCounter: 1, + CurrentCounter: 2, }, }, { @@ -2979,13 +3007,13 @@ var TestCases = []*testCase{ Id: "1", ProcessId: util.ToPointer("pid"), State: task.Completed, - Counter: 4, + Counter: 5, Attempt: 4, Frequency: 4, Expiration: 4, CompletedOn: util.ToPointer[int64](4), CurrentStates: []task.State{task.Enqueued}, // mismatch - CurrentCounter: 3, + CurrentCounter: 4, }, }, { @@ -2994,13 +3022,13 @@ var TestCases = []*testCase{ Id: "1", ProcessId: util.ToPointer("pid"), State: task.Completed, - Counter: 5, + Counter: 6, Attempt: 5, Frequency: 5, Expiration: 5, CompletedOn: util.ToPointer[int64](5), CurrentStates: []task.State{task.Claimed}, - CurrentCounter: 3, + CurrentCounter: 4, }, }, { @@ -3070,8 +3098,8 @@ var TestCases = []*testCase{ ProcessId: util.ToPointer("pid"), State: task.Completed, Recv: []byte("foo"), - Mesg: []byte("foo"), - Counter: 5, + Mesg: []byte(`{"type":"resume","root":"foo","leaf":"foo"}`), + Counter: 6, Attempt: 5, Frequency: 5, Expiration: 5, @@ -3098,18 +3126,24 @@ var TestCases = []*testCase{ Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", + Recv: []byte("foo1"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, { Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", + Recv: []byte("foo2"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, { Kind: t_aio.CreateCallback, CreateCallback: &t_aio.CreateCallbackCommand{ PromiseId: "foo", + Recv: []byte("foo3"), + Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "foo"}, }, }, { @@ -3125,7 +3159,7 @@ var TestCases = []*testCase{ ProcessId: util.ToPointer("bar"), State: task.Claimed, CurrentStates: []task.State{task.Init}, - CurrentCounter: 0, + CurrentCounter: 1, }, }, { @@ -3135,7 +3169,7 @@ var TestCases = []*testCase{ ProcessId: util.ToPointer("bar"), State: task.Claimed, CurrentStates: []task.State{task.Init}, - CurrentCounter: 0, + CurrentCounter: 1, }, }, { @@ -3145,7 +3179,7 @@ var TestCases = []*testCase{ ProcessId: util.ToPointer("bar"), State: task.Completed, CurrentStates: []task.State{task.Init}, - CurrentCounter: 0, + CurrentCounter: 1, }, }, { diff --git a/internal/app/subsystems/api/api.go b/internal/app/subsystems/api/api.go new file mode 100644 index 00000000..898d2636 --- /dev/null +++ b/internal/app/subsystems/api/api.go @@ -0,0 +1,186 @@ +package api + +import ( + "errors" + "fmt" + "strings" + + "github.com/google/uuid" + i_api "github.com/resonatehq/resonate/internal/api" + "github.com/resonatehq/resonate/internal/kernel/bus" + "github.com/resonatehq/resonate/internal/kernel/t_api" + "github.com/resonatehq/resonate/internal/util" + "github.com/resonatehq/resonate/pkg/promise" +) + +type API struct { + i_api.API + protocol string +} + +func New(api i_api.API, protocol string) *API { + return &API{ + API: api, + protocol: protocol, + } +} + +func (a *API) Process(id string, submission *t_api.Request) (*t_api.Response, *Error) { + if id == "" { + id = uuid.New().String() + } + if submission.Tags == nil { + submission.Tags = map[string]string{} + } + + // inject tags + submission.Tags["id"] = id + submission.Tags["name"] = submission.Kind.String() + submission.Tags["protocol"] = a.protocol + + // completion queue + cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) + + a.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ + Id: id, + Submission: submission, + Callback: func(res *t_api.Response, err error) { + defer close(cq) + + select { + case cq <- &bus.CQE[t_api.Request, t_api.Response]{ + Id: id, + Completion: res, + Error: err, + }: + default: + panic("response channel must not block") + } + }, + }) + + // cqe := <-cq + cqe := a.DequeueCQE(cq) + if cqe.Error != nil { + return nil, ServerError(cqe.Error) + } + + if status := cqe.Completion.Status(); !status.IsSuccessful() { + return nil, RequestError(status) + } + + return cqe.Completion, nil +} + +// Helper functions + +func (a *API) SearchPromises(id string, state string, tags map[string]string, limit int, cursor string) (*t_api.SearchPromisesRequest, *Error) { + if cursor != "" { + cursor, err := t_api.NewCursor[t_api.SearchPromisesRequest](cursor) + if err != nil { + return nil, RequestValidationError(err) + } + + return cursor.Next, nil + } + + // validate id + if id == "" { + return nil, RequestValidationError(errors.New("The field id is required.")) + } + + // set states + var states []promise.State + switch strings.ToLower(state) { + case "": + states = []promise.State{ + promise.Pending, + promise.Resolved, + promise.Rejected, + promise.Timedout, + promise.Canceled, + } + case "pending": + states = []promise.State{ + promise.Pending, + } + case "resolved": + states = []promise.State{ + promise.Resolved, + } + case "rejected": + states = []promise.State{ + promise.Rejected, + promise.Timedout, + promise.Canceled, + } + default: + return nil, RequestValidationError(errors.New("The field state must be one of pending, resolved, rejected.")) + } + + // set default tags + if tags == nil { + tags = map[string]string{} + } + + // set default limit + if limit == 0 { + limit = 100 + } + + // validate limit + if limit < 1 || limit > 100 { + return nil, RequestValidationError(errors.New("The field limit must be between 1 and 100.")) + } + + return &t_api.SearchPromisesRequest{ + Id: id, + States: states, + Tags: tags, + Limit: limit, + }, nil +} + +func (a *API) SearchSchedules(id string, tags map[string]string, limit int, cursor string) (*t_api.SearchSchedulesRequest, *Error) { + if cursor != "" { + cursor, err := t_api.NewCursor[t_api.SearchSchedulesRequest](cursor) + if err != nil { + return nil, RequestValidationError(err) + } + + return cursor.Next, nil + } + + // validate id + if id == "" { + return nil, RequestValidationError(errors.New("The field id is required.")) + } + + // set default tags + if tags == nil { + tags = map[string]string{} + } + + // validate limit + if limit < 1 || limit > 100 { + return nil, RequestValidationError(errors.New("The field limit must be between 1 and 100.")) + } + + return &t_api.SearchSchedulesRequest{ + Id: id, + Tags: tags, + Limit: limit, + }, nil +} + +func (a *API) ValidateCron(cron string) *Error { + if _, err := util.ParseCron(cron); err != nil { + return RequestValidationError(errors.New("The field cron must be a valid cron expression.")) + } + + return nil +} + +func (a *API) TaskProcessId(id string, counter int) string { + return fmt.Sprintf("%s/%d", id, counter) +} diff --git a/internal/app/subsystems/api/service/error.go b/internal/app/subsystems/api/error.go similarity index 81% rename from internal/app/subsystems/api/service/error.go rename to internal/app/subsystems/api/error.go index 19c97ec6..839c0aef 100644 --- a/internal/app/subsystems/api/service/error.go +++ b/internal/app/subsystems/api/error.go @@ -1,4 +1,4 @@ -package service +package api import ( "errors" @@ -63,10 +63,6 @@ func ServerError(err error) *Error { } func RequestError(status t_api.StatusCode) *Error { - if status.IsSuccessful() { - return nil - } - return &Error{ Code: status, Message: status.String(), @@ -121,36 +117,35 @@ func parseBindingError(errs ...error) []string { } func parseFieldError(e validator.FieldError) string { - fieldPrefix := fmt.Sprintf("The field %s", e.Field()) - tag := strings.Split(e.Tag(), "|")[0] + field := strings.ToLower(e.Field()) - switch tag { + switch e.Tag() { case "required": - return fmt.Sprintf("%s is required", fieldPrefix) + return fmt.Sprintf("The field %s is required.", field) case "min": param := e.Param() - return fmt.Sprintf("%s must be be at least length %s", fieldPrefix, param) + return fmt.Sprintf("The field %s must be be at least length %s.", field, param) case "max": param := e.Param() - return fmt.Sprintf("%s must be be at most length %s", fieldPrefix, param) + return fmt.Sprintf("The field %s must be be at most length %s.", field, param) case "gt": param := e.Param() - return fmt.Sprintf("%s must be greater than %s", fieldPrefix, param) + return fmt.Sprintf("The field %s must be greater than %s.", field, param) case "gte": param := e.Param() - return fmt.Sprintf("%s must be greater than or equal to %s", fieldPrefix, param) + return fmt.Sprintf("The field %s must be greater than or equal to %s.", field, param) case "lt": param := e.Param() - return fmt.Sprintf("%s must be less than %s", fieldPrefix, param) + return fmt.Sprintf("The field %s must be less than %s.", field, param) case "lte": param := e.Param() - return fmt.Sprintf("%s must be less than or equal to %s", fieldPrefix, param) + return fmt.Sprintf("The field %s must be less than or equal to %s.", field, param) case "oneof", "oneofcaseinsensitive": param := e.Param() paramArr := strings.Split(param, " ") paramArr[len(paramArr)-1] = "or " + paramArr[len(paramArr)-1] param = strings.Join(paramArr, ", ") - return fmt.Sprintf("%s must be either %s", fieldPrefix, param) + return fmt.Sprintf("The field %s must be one of %s.", field, param) default: return e.Error() } diff --git a/internal/app/subsystems/api/grpc/api/callback.pb.go b/internal/app/subsystems/api/grpc/api/callback.pb.go deleted file mode 100644 index f81b4a16..00000000 --- a/internal/app/subsystems/api/grpc/api/callback.pb.go +++ /dev/null @@ -1,493 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/callback.proto - -package api - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Callback struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - PromiseId string `protobuf:"bytes,2,opt,name=promiseId,proto3" json:"promiseId,omitempty"` - Timeout int64 `protobuf:"varint,3,opt,name=timeout,proto3" json:"timeout,omitempty"` - CreatedOn int64 `protobuf:"varint,4,opt,name=createdOn,proto3" json:"createdOn,omitempty"` -} - -func (x *Callback) Reset() { - *x = Callback{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Callback) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Callback) ProtoMessage() {} - -func (x *Callback) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Callback.ProtoReflect.Descriptor instead. -func (*Callback) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescGZIP(), []int{0} -} - -func (x *Callback) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *Callback) GetPromiseId() string { - if x != nil { - return x.PromiseId - } - return "" -} - -func (x *Callback) GetTimeout() int64 { - if x != nil { - return x.Timeout - } - return 0 -} - -func (x *Callback) GetCreatedOn() int64 { - if x != nil { - return x.CreatedOn - } - return 0 -} - -type Recv struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` -} - -func (x *Recv) Reset() { - *x = Recv{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Recv) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Recv) ProtoMessage() {} - -func (x *Recv) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Recv.ProtoReflect.Descriptor instead. -func (*Recv) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescGZIP(), []int{1} -} - -func (x *Recv) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Recv) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -type CreateCallbackRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PromiseId string `protobuf:"bytes,1,opt,name=promiseId,proto3" json:"promiseId,omitempty"` - RootPromiseId string `protobuf:"bytes,2,opt,name=rootPromiseId,proto3" json:"rootPromiseId,omitempty"` - Timeout int64 `protobuf:"varint,3,opt,name=timeout,proto3" json:"timeout,omitempty"` - // Types that are assignable to Recv: - // - // *CreateCallbackRequest_Logical - // *CreateCallbackRequest_Physical - Recv isCreateCallbackRequest_Recv `protobuf_oneof:"recv"` - RequestId string `protobuf:"bytes,6,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *CreateCallbackRequest) Reset() { - *x = CreateCallbackRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateCallbackRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateCallbackRequest) ProtoMessage() {} - -func (x *CreateCallbackRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateCallbackRequest.ProtoReflect.Descriptor instead. -func (*CreateCallbackRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescGZIP(), []int{2} -} - -func (x *CreateCallbackRequest) GetPromiseId() string { - if x != nil { - return x.PromiseId - } - return "" -} - -func (x *CreateCallbackRequest) GetRootPromiseId() string { - if x != nil { - return x.RootPromiseId - } - return "" -} - -func (x *CreateCallbackRequest) GetTimeout() int64 { - if x != nil { - return x.Timeout - } - return 0 -} - -func (m *CreateCallbackRequest) GetRecv() isCreateCallbackRequest_Recv { - if m != nil { - return m.Recv - } - return nil -} - -func (x *CreateCallbackRequest) GetLogical() string { - if x, ok := x.GetRecv().(*CreateCallbackRequest_Logical); ok { - return x.Logical - } - return "" -} - -func (x *CreateCallbackRequest) GetPhysical() *Recv { - if x, ok := x.GetRecv().(*CreateCallbackRequest_Physical); ok { - return x.Physical - } - return nil -} - -func (x *CreateCallbackRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type isCreateCallbackRequest_Recv interface { - isCreateCallbackRequest_Recv() -} - -type CreateCallbackRequest_Logical struct { - Logical string `protobuf:"bytes,4,opt,name=logical,proto3,oneof"` -} - -type CreateCallbackRequest_Physical struct { - Physical *Recv `protobuf:"bytes,5,opt,name=physical,proto3,oneof"` -} - -func (*CreateCallbackRequest_Logical) isCreateCallbackRequest_Recv() {} - -func (*CreateCallbackRequest_Physical) isCreateCallbackRequest_Recv() {} - -type CreateCallbackResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` - Callback *Callback `protobuf:"bytes,2,opt,name=callback,proto3" json:"callback,omitempty"` - Promise *Promise `protobuf:"bytes,3,opt,name=promise,proto3" json:"promise,omitempty"` -} - -func (x *CreateCallbackResponse) Reset() { - *x = CreateCallbackResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateCallbackResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateCallbackResponse) ProtoMessage() {} - -func (x *CreateCallbackResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateCallbackResponse.ProtoReflect.Descriptor instead. -func (*CreateCallbackResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescGZIP(), []int{3} -} - -func (x *CreateCallbackResponse) GetNoop() bool { - if x != nil { - return x.Noop - } - return false -} - -func (x *CreateCallbackResponse) GetCallback() *Callback { - if x != nil { - return x.Callback - } - return nil -} - -func (x *CreateCallbackResponse) GetPromise() *Promise { - if x != nil { - return x.Promise - } - return nil -} - -var File_internal_app_subsystems_api_grpc_api_callback_proto protoreflect.FileDescriptor - -var file_internal_app_subsystems_api_grpc_api_callback_proto_rawDesc = []byte{ - 0x0a, 0x33, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, - 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, - 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x1a, - 0x32, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, - 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, - 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x70, 0x0a, 0x08, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, - 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, - 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x64, 0x4f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x22, 0x2e, 0x0a, 0x04, 0x52, 0x65, 0x63, 0x76, 0x12, 0x12, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xe5, 0x01, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x24, 0x0a, - 0x0d, 0x72, 0x6f, 0x6f, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x6f, 0x6f, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, - 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1a, 0x0a, - 0x07, 0x6c, 0x6f, 0x67, 0x69, 0x63, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, - 0x52, 0x07, 0x6c, 0x6f, 0x67, 0x69, 0x63, 0x61, 0x6c, 0x12, 0x2c, 0x0a, 0x08, 0x70, 0x68, 0x79, - 0x73, 0x69, 0x63, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x63, 0x61, - 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x52, 0x65, 0x63, 0x76, 0x48, 0x00, 0x52, 0x08, 0x70, - 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x49, 0x64, 0x42, 0x06, 0x0a, 0x04, 0x72, 0x65, 0x63, 0x76, 0x22, 0x88, 0x01, - 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x2e, 0x0a, 0x08, - 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, - 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, - 0x63, 0x6b, 0x52, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x2a, 0x0a, 0x07, - 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, - 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, - 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x32, 0x62, 0x0a, 0x09, 0x43, 0x61, 0x6c, 0x6c, - 0x62, 0x61, 0x63, 0x6b, 0x73, 0x12, 0x55, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, - 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x1f, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, - 0x63, 0x6b, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x62, - 0x61, 0x63, 0x6b, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, - 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x5a, 0x43, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, - 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, - 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescOnce sync.Once - file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescData = file_internal_app_subsystems_api_grpc_api_callback_proto_rawDesc -) - -func file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescGZIP() []byte { - file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescOnce.Do(func() { - file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescData) - }) - return file_internal_app_subsystems_api_grpc_api_callback_proto_rawDescData -} - -var file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_internal_app_subsystems_api_grpc_api_callback_proto_goTypes = []interface{}{ - (*Callback)(nil), // 0: callback.Callback - (*Recv)(nil), // 1: callback.Recv - (*CreateCallbackRequest)(nil), // 2: callback.CreateCallbackRequest - (*CreateCallbackResponse)(nil), // 3: callback.CreateCallbackResponse - (*Promise)(nil), // 4: promise.Promise -} -var file_internal_app_subsystems_api_grpc_api_callback_proto_depIdxs = []int32{ - 1, // 0: callback.CreateCallbackRequest.physical:type_name -> callback.Recv - 0, // 1: callback.CreateCallbackResponse.callback:type_name -> callback.Callback - 4, // 2: callback.CreateCallbackResponse.promise:type_name -> promise.Promise - 2, // 3: callback.Callbacks.CreateCallback:input_type -> callback.CreateCallbackRequest - 3, // 4: callback.Callbacks.CreateCallback:output_type -> callback.CreateCallbackResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_internal_app_subsystems_api_grpc_api_callback_proto_init() } -func file_internal_app_subsystems_api_grpc_api_callback_proto_init() { - if File_internal_app_subsystems_api_grpc_api_callback_proto != nil { - return - } - file_internal_app_subsystems_api_grpc_api_promise_proto_init() - if !protoimpl.UnsafeEnabled { - file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Callback); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Recv); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateCallbackRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateCallbackResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes[2].OneofWrappers = []interface{}{ - (*CreateCallbackRequest_Logical)(nil), - (*CreateCallbackRequest_Physical)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_internal_app_subsystems_api_grpc_api_callback_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_internal_app_subsystems_api_grpc_api_callback_proto_goTypes, - DependencyIndexes: file_internal_app_subsystems_api_grpc_api_callback_proto_depIdxs, - MessageInfos: file_internal_app_subsystems_api_grpc_api_callback_proto_msgTypes, - }.Build() - File_internal_app_subsystems_api_grpc_api_callback_proto = out.File - file_internal_app_subsystems_api_grpc_api_callback_proto_rawDesc = nil - file_internal_app_subsystems_api_grpc_api_callback_proto_goTypes = nil - file_internal_app_subsystems_api_grpc_api_callback_proto_depIdxs = nil -} diff --git a/internal/app/subsystems/api/grpc/api/callback.proto b/internal/app/subsystems/api/grpc/api/callback.proto deleted file mode 100644 index 06be8643..00000000 --- a/internal/app/subsystems/api/grpc/api/callback.proto +++ /dev/null @@ -1,40 +0,0 @@ -syntax = "proto3"; - -package callback; - -import "internal/app/subsystems/api/grpc/api/promise.proto"; - -option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api"; - -service Callbacks { - rpc CreateCallback (CreateCallbackRequest) returns (CreateCallbackResponse) {} -} - -message Callback { - string id = 1; - string promiseId = 2; - int64 timeout = 3; - int64 createdOn = 4; -} - -message Recv { - string type = 1; - bytes data = 2; -} - -message CreateCallbackRequest { - string promiseId = 1; - string rootPromiseId = 2; - int64 timeout = 3; - oneof recv { - string logical = 4; - Recv physical = 5; - } - string requestId = 6; -} - -message CreateCallbackResponse { - bool noop = 1; - Callback callback = 2; - promise.Promise promise = 3; -} diff --git a/internal/app/subsystems/api/grpc/api/lock.pb.go b/internal/app/subsystems/api/grpc/api/lock.pb.go deleted file mode 100644 index 69a086dc..00000000 --- a/internal/app/subsystems/api/grpc/api/lock.pb.go +++ /dev/null @@ -1,652 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/lock.proto - -package api - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Lock struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ResourceId string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` - ExecutionId string `protobuf:"bytes,2,opt,name=execution_id,json=executionId,proto3" json:"execution_id,omitempty"` - ProcessId string `protobuf:"bytes,3,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"` - ExpiryInMilliseconds int64 `protobuf:"varint,4,opt,name=expiry_in_milliseconds,json=expiryInMilliseconds,proto3" json:"expiry_in_milliseconds,omitempty"` - ExpiresAt int64 `protobuf:"varint,5,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` -} - -func (x *Lock) Reset() { - *x = Lock{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Lock) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Lock) ProtoMessage() {} - -func (x *Lock) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Lock.ProtoReflect.Descriptor instead. -func (*Lock) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescGZIP(), []int{0} -} - -func (x *Lock) GetResourceId() string { - if x != nil { - return x.ResourceId - } - return "" -} - -func (x *Lock) GetExecutionId() string { - if x != nil { - return x.ExecutionId - } - return "" -} - -func (x *Lock) GetProcessId() string { - if x != nil { - return x.ProcessId - } - return "" -} - -func (x *Lock) GetExpiryInMilliseconds() int64 { - if x != nil { - return x.ExpiryInMilliseconds - } - return 0 -} - -func (x *Lock) GetExpiresAt() int64 { - if x != nil { - return x.ExpiresAt - } - return 0 -} - -type AcquireLockRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ResourceId string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` - ExecutionId string `protobuf:"bytes,2,opt,name=execution_id,json=executionId,proto3" json:"execution_id,omitempty"` - ProcessId string `protobuf:"bytes,3,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"` - ExpiryInMilliseconds int64 `protobuf:"varint,4,opt,name=expiry_in_milliseconds,json=expiryInMilliseconds,proto3" json:"expiry_in_milliseconds,omitempty"` - RequestId string `protobuf:"bytes,5,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` -} - -func (x *AcquireLockRequest) Reset() { - *x = AcquireLockRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AcquireLockRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AcquireLockRequest) ProtoMessage() {} - -func (x *AcquireLockRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AcquireLockRequest.ProtoReflect.Descriptor instead. -func (*AcquireLockRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescGZIP(), []int{1} -} - -func (x *AcquireLockRequest) GetResourceId() string { - if x != nil { - return x.ResourceId - } - return "" -} - -func (x *AcquireLockRequest) GetExecutionId() string { - if x != nil { - return x.ExecutionId - } - return "" -} - -func (x *AcquireLockRequest) GetProcessId() string { - if x != nil { - return x.ProcessId - } - return "" -} - -func (x *AcquireLockRequest) GetExpiryInMilliseconds() int64 { - if x != nil { - return x.ExpiryInMilliseconds - } - return 0 -} - -func (x *AcquireLockRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type AcquireLockResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Lock *Lock `protobuf:"bytes,1,opt,name=lock,proto3" json:"lock,omitempty"` -} - -func (x *AcquireLockResponse) Reset() { - *x = AcquireLockResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AcquireLockResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AcquireLockResponse) ProtoMessage() {} - -func (x *AcquireLockResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AcquireLockResponse.ProtoReflect.Descriptor instead. -func (*AcquireLockResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescGZIP(), []int{2} -} - -func (x *AcquireLockResponse) GetLock() *Lock { - if x != nil { - return x.Lock - } - return nil -} - -type HeartbeatLocksRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProcessId string `protobuf:"bytes,1,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"` - RequestId string `protobuf:"bytes,2,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` -} - -func (x *HeartbeatLocksRequest) Reset() { - *x = HeartbeatLocksRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HeartbeatLocksRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HeartbeatLocksRequest) ProtoMessage() {} - -func (x *HeartbeatLocksRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HeartbeatLocksRequest.ProtoReflect.Descriptor instead. -func (*HeartbeatLocksRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescGZIP(), []int{3} -} - -func (x *HeartbeatLocksRequest) GetProcessId() string { - if x != nil { - return x.ProcessId - } - return "" -} - -func (x *HeartbeatLocksRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type HeartbeatLocksResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - LocksAffected int32 `protobuf:"varint,1,opt,name=locksAffected,proto3" json:"locksAffected,omitempty"` -} - -func (x *HeartbeatLocksResponse) Reset() { - *x = HeartbeatLocksResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HeartbeatLocksResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HeartbeatLocksResponse) ProtoMessage() {} - -func (x *HeartbeatLocksResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HeartbeatLocksResponse.ProtoReflect.Descriptor instead. -func (*HeartbeatLocksResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescGZIP(), []int{4} -} - -func (x *HeartbeatLocksResponse) GetLocksAffected() int32 { - if x != nil { - return x.LocksAffected - } - return 0 -} - -type ReleaseLockRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ResourceId string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` - ExecutionId string `protobuf:"bytes,2,opt,name=execution_id,json=executionId,proto3" json:"execution_id,omitempty"` - RequestId string `protobuf:"bytes,3,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` -} - -func (x *ReleaseLockRequest) Reset() { - *x = ReleaseLockRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReleaseLockRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReleaseLockRequest) ProtoMessage() {} - -func (x *ReleaseLockRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReleaseLockRequest.ProtoReflect.Descriptor instead. -func (*ReleaseLockRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescGZIP(), []int{5} -} - -func (x *ReleaseLockRequest) GetResourceId() string { - if x != nil { - return x.ResourceId - } - return "" -} - -func (x *ReleaseLockRequest) GetExecutionId() string { - if x != nil { - return x.ExecutionId - } - return "" -} - -func (x *ReleaseLockRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type ReleaseLockResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ReleaseLockResponse) Reset() { - *x = ReleaseLockResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReleaseLockResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReleaseLockResponse) ProtoMessage() {} - -func (x *ReleaseLockResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReleaseLockResponse.ProtoReflect.Descriptor instead. -func (*ReleaseLockResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescGZIP(), []int{6} -} - -var File_internal_app_subsystems_api_grpc_api_lock_proto protoreflect.FileDescriptor - -var file_internal_app_subsystems_api_grpc_api_lock_proto_rawDesc = []byte{ - 0x0a, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, - 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, - 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x04, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0xbe, 0x01, 0x0a, 0x04, 0x4c, 0x6f, 0x63, 0x6b, - 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, - 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x5f, - 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, - 0x73, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, 0x69, 0x6e, - 0x5f, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x14, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x49, 0x6e, 0x4d, 0x69, 0x6c, - 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x78, 0x70, - 0x69, 0x72, 0x65, 0x73, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, - 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x22, 0xcc, 0x01, 0x0a, 0x12, 0x41, 0x63, 0x71, - 0x75, 0x69, 0x72, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, - 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, - 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x69, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, - 0x49, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, 0x69, 0x6e, 0x5f, - 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x14, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x49, 0x6e, 0x4d, 0x69, 0x6c, 0x6c, - 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x35, 0x0a, 0x13, 0x41, 0x63, 0x71, 0x75, 0x69, - 0x72, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, - 0x0a, 0x04, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x04, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x55, - 0x0a, 0x15, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x4c, 0x6f, 0x63, 0x6b, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x63, 0x65, - 0x73, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, - 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x3e, 0x0a, 0x16, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, - 0x61, 0x74, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x24, 0x0a, 0x0d, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x41, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x41, 0x66, 0x66, - 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x77, 0x0a, 0x12, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, - 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, - 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x15, - 0x0a, 0x13, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xe2, 0x01, 0x0a, 0x05, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x12, - 0x44, 0x0a, 0x0b, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x12, 0x18, - 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4c, 0x6f, 0x63, - 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, - 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, - 0x61, 0x74, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x12, 0x1b, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x48, - 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x48, 0x65, 0x61, 0x72, - 0x74, 0x62, 0x65, 0x61, 0x74, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, - 0x6f, 0x63, 0x6b, 0x12, 0x18, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, - 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x6f, 0x63, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x5a, 0x43, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, - 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, - 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescOnce sync.Once - file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescData = file_internal_app_subsystems_api_grpc_api_lock_proto_rawDesc -) - -func file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescGZIP() []byte { - file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescOnce.Do(func() { - file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescData) - }) - return file_internal_app_subsystems_api_grpc_api_lock_proto_rawDescData -} - -var file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_internal_app_subsystems_api_grpc_api_lock_proto_goTypes = []interface{}{ - (*Lock)(nil), // 0: lock.Lock - (*AcquireLockRequest)(nil), // 1: lock.AcquireLockRequest - (*AcquireLockResponse)(nil), // 2: lock.AcquireLockResponse - (*HeartbeatLocksRequest)(nil), // 3: lock.HeartbeatLocksRequest - (*HeartbeatLocksResponse)(nil), // 4: lock.HeartbeatLocksResponse - (*ReleaseLockRequest)(nil), // 5: lock.ReleaseLockRequest - (*ReleaseLockResponse)(nil), // 6: lock.ReleaseLockResponse -} -var file_internal_app_subsystems_api_grpc_api_lock_proto_depIdxs = []int32{ - 0, // 0: lock.AcquireLockResponse.lock:type_name -> lock.Lock - 1, // 1: lock.Locks.AcquireLock:input_type -> lock.AcquireLockRequest - 3, // 2: lock.Locks.HeartbeatLocks:input_type -> lock.HeartbeatLocksRequest - 5, // 3: lock.Locks.ReleaseLock:input_type -> lock.ReleaseLockRequest - 2, // 4: lock.Locks.AcquireLock:output_type -> lock.AcquireLockResponse - 4, // 5: lock.Locks.HeartbeatLocks:output_type -> lock.HeartbeatLocksResponse - 6, // 6: lock.Locks.ReleaseLock:output_type -> lock.ReleaseLockResponse - 4, // [4:7] is the sub-list for method output_type - 1, // [1:4] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_internal_app_subsystems_api_grpc_api_lock_proto_init() } -func file_internal_app_subsystems_api_grpc_api_lock_proto_init() { - if File_internal_app_subsystems_api_grpc_api_lock_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Lock); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AcquireLockRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AcquireLockResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HeartbeatLocksRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HeartbeatLocksResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReleaseLockRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReleaseLockResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_internal_app_subsystems_api_grpc_api_lock_proto_rawDesc, - NumEnums: 0, - NumMessages: 7, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_internal_app_subsystems_api_grpc_api_lock_proto_goTypes, - DependencyIndexes: file_internal_app_subsystems_api_grpc_api_lock_proto_depIdxs, - MessageInfos: file_internal_app_subsystems_api_grpc_api_lock_proto_msgTypes, - }.Build() - File_internal_app_subsystems_api_grpc_api_lock_proto = out.File - file_internal_app_subsystems_api_grpc_api_lock_proto_rawDesc = nil - file_internal_app_subsystems_api_grpc_api_lock_proto_goTypes = nil - file_internal_app_subsystems_api_grpc_api_lock_proto_depIdxs = nil -} diff --git a/internal/app/subsystems/api/grpc/api/promise.pb.go b/internal/app/subsystems/api/grpc/api/promise.pb.go deleted file mode 100644 index 9bfa68fa..00000000 --- a/internal/app/subsystems/api/grpc/api/promise.pb.go +++ /dev/null @@ -1,1552 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/promise.proto - -package api - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type State int32 - -const ( - State_PENDING State = 0 - State_RESOLVED State = 1 - State_REJECTED State = 2 - State_REJECTED_TIMEDOUT State = 3 - State_REJECTED_CANCELED State = 4 -) - -// Enum value maps for State. -var ( - State_name = map[int32]string{ - 0: "PENDING", - 1: "RESOLVED", - 2: "REJECTED", - 3: "REJECTED_TIMEDOUT", - 4: "REJECTED_CANCELED", - } - State_value = map[string]int32{ - "PENDING": 0, - "RESOLVED": 1, - "REJECTED": 2, - "REJECTED_TIMEDOUT": 3, - "REJECTED_CANCELED": 4, - } -) - -func (x State) Enum() *State { - p := new(State) - *p = x - return p -} - -func (x State) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (State) Descriptor() protoreflect.EnumDescriptor { - return file_internal_app_subsystems_api_grpc_api_promise_proto_enumTypes[0].Descriptor() -} - -func (State) Type() protoreflect.EnumType { - return &file_internal_app_subsystems_api_grpc_api_promise_proto_enumTypes[0] -} - -func (x State) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use State.Descriptor instead. -func (State) EnumDescriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{0} -} - -type SearchState int32 - -const ( - SearchState_SEARCH_ALL SearchState = 0 - SearchState_SEARCH_PENDING SearchState = 1 - SearchState_SEARCH_RESOLVED SearchState = 2 - SearchState_SEARCH_REJECTED SearchState = 3 -) - -// Enum value maps for SearchState. -var ( - SearchState_name = map[int32]string{ - 0: "SEARCH_ALL", - 1: "SEARCH_PENDING", - 2: "SEARCH_RESOLVED", - 3: "SEARCH_REJECTED", - } - SearchState_value = map[string]int32{ - "SEARCH_ALL": 0, - "SEARCH_PENDING": 1, - "SEARCH_RESOLVED": 2, - "SEARCH_REJECTED": 3, - } -) - -func (x SearchState) Enum() *SearchState { - p := new(SearchState) - *p = x - return p -} - -func (x SearchState) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SearchState) Descriptor() protoreflect.EnumDescriptor { - return file_internal_app_subsystems_api_grpc_api_promise_proto_enumTypes[1].Descriptor() -} - -func (SearchState) Type() protoreflect.EnumType { - return &file_internal_app_subsystems_api_grpc_api_promise_proto_enumTypes[1] -} - -func (x SearchState) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use SearchState.Descriptor instead. -func (SearchState) EnumDescriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{1} -} - -type Promise struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - State State `protobuf:"varint,2,opt,name=state,proto3,enum=promise.State" json:"state,omitempty"` - Param *Value `protobuf:"bytes,3,opt,name=param,proto3" json:"param,omitempty"` - Value *Value `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` - Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` - IdempotencyKeyForCreate string `protobuf:"bytes,6,opt,name=idempotencyKeyForCreate,proto3" json:"idempotencyKeyForCreate,omitempty"` - IdempotencyKeyForComplete string `protobuf:"bytes,7,opt,name=idempotencyKeyForComplete,proto3" json:"idempotencyKeyForComplete,omitempty"` - CreatedOn int64 `protobuf:"varint,8,opt,name=createdOn,proto3" json:"createdOn,omitempty"` - CompletedOn int64 `protobuf:"varint,9,opt,name=completedOn,proto3" json:"completedOn,omitempty"` - Tags map[string]string `protobuf:"bytes,10,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *Promise) Reset() { - *x = Promise{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Promise) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Promise) ProtoMessage() {} - -func (x *Promise) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Promise.ProtoReflect.Descriptor instead. -func (*Promise) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{0} -} - -func (x *Promise) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *Promise) GetState() State { - if x != nil { - return x.State - } - return State_PENDING -} - -func (x *Promise) GetParam() *Value { - if x != nil { - return x.Param - } - return nil -} - -func (x *Promise) GetValue() *Value { - if x != nil { - return x.Value - } - return nil -} - -func (x *Promise) GetTimeout() int64 { - if x != nil { - return x.Timeout - } - return 0 -} - -func (x *Promise) GetIdempotencyKeyForCreate() string { - if x != nil { - return x.IdempotencyKeyForCreate - } - return "" -} - -func (x *Promise) GetIdempotencyKeyForComplete() string { - if x != nil { - return x.IdempotencyKeyForComplete - } - return "" -} - -func (x *Promise) GetCreatedOn() int64 { - if x != nil { - return x.CreatedOn - } - return 0 -} - -func (x *Promise) GetCompletedOn() int64 { - if x != nil { - return x.CompletedOn - } - return 0 -} - -func (x *Promise) GetTags() map[string]string { - if x != nil { - return x.Tags - } - return nil -} - -type Value struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` -} - -func (x *Value) Reset() { - *x = Value{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Value) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Value) ProtoMessage() {} - -func (x *Value) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Value.ProtoReflect.Descriptor instead. -func (*Value) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{1} -} - -func (x *Value) GetHeaders() map[string]string { - if x != nil { - return x.Headers - } - return nil -} - -func (x *Value) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -type ReadPromiseRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *ReadPromiseRequest) Reset() { - *x = ReadPromiseRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReadPromiseRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadPromiseRequest) ProtoMessage() {} - -func (x *ReadPromiseRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadPromiseRequest.ProtoReflect.Descriptor instead. -func (*ReadPromiseRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{2} -} - -func (x *ReadPromiseRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *ReadPromiseRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type ReadPromiseResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Promise *Promise `protobuf:"bytes,1,opt,name=promise,proto3" json:"promise,omitempty"` -} - -func (x *ReadPromiseResponse) Reset() { - *x = ReadPromiseResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReadPromiseResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadPromiseResponse) ProtoMessage() {} - -func (x *ReadPromiseResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadPromiseResponse.ProtoReflect.Descriptor instead. -func (*ReadPromiseResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{3} -} - -func (x *ReadPromiseResponse) GetPromise() *Promise { - if x != nil { - return x.Promise - } - return nil -} - -type SearchPromisesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - State SearchState `protobuf:"varint,2,opt,name=state,proto3,enum=promise.SearchState" json:"state,omitempty"` - Tags map[string]string `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Limit int32 `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"` - Cursor string `protobuf:"bytes,5,opt,name=cursor,proto3" json:"cursor,omitempty"` - RequestId string `protobuf:"bytes,6,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *SearchPromisesRequest) Reset() { - *x = SearchPromisesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SearchPromisesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SearchPromisesRequest) ProtoMessage() {} - -func (x *SearchPromisesRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SearchPromisesRequest.ProtoReflect.Descriptor instead. -func (*SearchPromisesRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{4} -} - -func (x *SearchPromisesRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *SearchPromisesRequest) GetState() SearchState { - if x != nil { - return x.State - } - return SearchState_SEARCH_ALL -} - -func (x *SearchPromisesRequest) GetTags() map[string]string { - if x != nil { - return x.Tags - } - return nil -} - -func (x *SearchPromisesRequest) GetLimit() int32 { - if x != nil { - return x.Limit - } - return 0 -} - -func (x *SearchPromisesRequest) GetCursor() string { - if x != nil { - return x.Cursor - } - return "" -} - -func (x *SearchPromisesRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type SearchPromisesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Cursor string `protobuf:"bytes,1,opt,name=cursor,proto3" json:"cursor,omitempty"` - Promises []*Promise `protobuf:"bytes,2,rep,name=promises,proto3" json:"promises,omitempty"` -} - -func (x *SearchPromisesResponse) Reset() { - *x = SearchPromisesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SearchPromisesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SearchPromisesResponse) ProtoMessage() {} - -func (x *SearchPromisesResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SearchPromisesResponse.ProtoReflect.Descriptor instead. -func (*SearchPromisesResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{5} -} - -func (x *SearchPromisesResponse) GetCursor() string { - if x != nil { - return x.Cursor - } - return "" -} - -func (x *SearchPromisesResponse) GetPromises() []*Promise { - if x != nil { - return x.Promises - } - return nil -} - -type CreatePromiseRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - IdempotencyKey string `protobuf:"bytes,2,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` - Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` - Param *Value `protobuf:"bytes,4,opt,name=param,proto3" json:"param,omitempty"` - Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` - RequestId string `protobuf:"bytes,6,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *CreatePromiseRequest) Reset() { - *x = CreatePromiseRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreatePromiseRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreatePromiseRequest) ProtoMessage() {} - -func (x *CreatePromiseRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreatePromiseRequest.ProtoReflect.Descriptor instead. -func (*CreatePromiseRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{6} -} - -func (x *CreatePromiseRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CreatePromiseRequest) GetIdempotencyKey() string { - if x != nil { - return x.IdempotencyKey - } - return "" -} - -func (x *CreatePromiseRequest) GetStrict() bool { - if x != nil { - return x.Strict - } - return false -} - -func (x *CreatePromiseRequest) GetParam() *Value { - if x != nil { - return x.Param - } - return nil -} - -func (x *CreatePromiseRequest) GetTimeout() int64 { - if x != nil { - return x.Timeout - } - return 0 -} - -func (x *CreatePromiseRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type CreatePromiseResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` - Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` -} - -func (x *CreatePromiseResponse) Reset() { - *x = CreatePromiseResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreatePromiseResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreatePromiseResponse) ProtoMessage() {} - -func (x *CreatePromiseResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreatePromiseResponse.ProtoReflect.Descriptor instead. -func (*CreatePromiseResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{7} -} - -func (x *CreatePromiseResponse) GetNoop() bool { - if x != nil { - return x.Noop - } - return false -} - -func (x *CreatePromiseResponse) GetPromise() *Promise { - if x != nil { - return x.Promise - } - return nil -} - -type CancelPromiseRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - IdempotencyKey string `protobuf:"bytes,2,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` - Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` - Value *Value `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` - RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *CancelPromiseRequest) Reset() { - *x = CancelPromiseRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CancelPromiseRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CancelPromiseRequest) ProtoMessage() {} - -func (x *CancelPromiseRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CancelPromiseRequest.ProtoReflect.Descriptor instead. -func (*CancelPromiseRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{8} -} - -func (x *CancelPromiseRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CancelPromiseRequest) GetIdempotencyKey() string { - if x != nil { - return x.IdempotencyKey - } - return "" -} - -func (x *CancelPromiseRequest) GetStrict() bool { - if x != nil { - return x.Strict - } - return false -} - -func (x *CancelPromiseRequest) GetValue() *Value { - if x != nil { - return x.Value - } - return nil -} - -func (x *CancelPromiseRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type CancelPromiseResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` - Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` -} - -func (x *CancelPromiseResponse) Reset() { - *x = CancelPromiseResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CancelPromiseResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CancelPromiseResponse) ProtoMessage() {} - -func (x *CancelPromiseResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CancelPromiseResponse.ProtoReflect.Descriptor instead. -func (*CancelPromiseResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{9} -} - -func (x *CancelPromiseResponse) GetNoop() bool { - if x != nil { - return x.Noop - } - return false -} - -func (x *CancelPromiseResponse) GetPromise() *Promise { - if x != nil { - return x.Promise - } - return nil -} - -type ResolvePromiseRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - IdempotencyKey string `protobuf:"bytes,2,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` - Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` - Value *Value `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` - RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *ResolvePromiseRequest) Reset() { - *x = ResolvePromiseRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ResolvePromiseRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResolvePromiseRequest) ProtoMessage() {} - -func (x *ResolvePromiseRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ResolvePromiseRequest.ProtoReflect.Descriptor instead. -func (*ResolvePromiseRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{10} -} - -func (x *ResolvePromiseRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *ResolvePromiseRequest) GetIdempotencyKey() string { - if x != nil { - return x.IdempotencyKey - } - return "" -} - -func (x *ResolvePromiseRequest) GetStrict() bool { - if x != nil { - return x.Strict - } - return false -} - -func (x *ResolvePromiseRequest) GetValue() *Value { - if x != nil { - return x.Value - } - return nil -} - -func (x *ResolvePromiseRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type ResolvePromiseResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` - Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` -} - -func (x *ResolvePromiseResponse) Reset() { - *x = ResolvePromiseResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ResolvePromiseResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResolvePromiseResponse) ProtoMessage() {} - -func (x *ResolvePromiseResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ResolvePromiseResponse.ProtoReflect.Descriptor instead. -func (*ResolvePromiseResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{11} -} - -func (x *ResolvePromiseResponse) GetNoop() bool { - if x != nil { - return x.Noop - } - return false -} - -func (x *ResolvePromiseResponse) GetPromise() *Promise { - if x != nil { - return x.Promise - } - return nil -} - -type RejectPromiseRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - IdempotencyKey string `protobuf:"bytes,2,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` - Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` - Value *Value `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` - RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *RejectPromiseRequest) Reset() { - *x = RejectPromiseRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RejectPromiseRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RejectPromiseRequest) ProtoMessage() {} - -func (x *RejectPromiseRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RejectPromiseRequest.ProtoReflect.Descriptor instead. -func (*RejectPromiseRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{12} -} - -func (x *RejectPromiseRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *RejectPromiseRequest) GetIdempotencyKey() string { - if x != nil { - return x.IdempotencyKey - } - return "" -} - -func (x *RejectPromiseRequest) GetStrict() bool { - if x != nil { - return x.Strict - } - return false -} - -func (x *RejectPromiseRequest) GetValue() *Value { - if x != nil { - return x.Value - } - return nil -} - -func (x *RejectPromiseRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type RejectPromiseResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` - Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` -} - -func (x *RejectPromiseResponse) Reset() { - *x = RejectPromiseResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RejectPromiseResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RejectPromiseResponse) ProtoMessage() {} - -func (x *RejectPromiseResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RejectPromiseResponse.ProtoReflect.Descriptor instead. -func (*RejectPromiseResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP(), []int{13} -} - -func (x *RejectPromiseResponse) GetNoop() bool { - if x != nil { - return x.Noop - } - return false -} - -func (x *RejectPromiseResponse) GetPromise() *Promise { - if x != nil { - return x.Promise - } - return nil -} - -var File_internal_app_subsystems_api_grpc_api_promise_proto protoreflect.FileDescriptor - -var file_internal_app_subsystems_api_grpc_api_promise_proto_rawDesc = []byte{ - 0x0a, 0x32, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, - 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, - 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0xc6, 0x03, - 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x05, 0x73, 0x74, 0x61, - 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, - 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, - 0x24, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, - 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, - 0x70, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x38, 0x0a, 0x17, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, - 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, - 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, - 0x3c, 0x0a, 0x19, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, - 0x79, 0x46, 0x6f, 0x72, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x19, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, - 0x65, 0x79, 0x46, 0x6f, 0x72, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1c, 0x0a, - 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x63, - 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x12, 0x2e, 0x0a, - 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x54, 0x61, - 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x1a, 0x37, 0x0a, - 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x8e, 0x01, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x35, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, - 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x42, 0x0a, 0x12, 0x52, 0x65, 0x61, 0x64, 0x50, - 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, - 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x41, 0x0a, 0x13, 0x52, - 0x65, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x50, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0x96, - 0x02, 0x0a, 0x15, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2a, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, - 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x65, 0x61, - 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, - 0x67, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, - 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, - 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x1a, 0x37, - 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x5e, 0x0a, 0x16, 0x53, 0x65, 0x61, 0x72, 0x63, - 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, 0x2c, 0x0a, 0x08, 0x70, 0x72, 0x6f, - 0x6d, 0x69, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x08, 0x70, - 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x22, 0xc4, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, - 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, - 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, - 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, - 0x12, 0x24, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, - 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x57, - 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x2a, 0x0a, 0x07, 0x70, - 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, - 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, - 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0xaa, 0x01, 0x0a, 0x14, 0x43, 0x61, 0x6e, 0x63, - 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, - 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, - 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, - 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, - 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x49, 0x64, 0x22, 0x57, 0x0a, 0x15, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x50, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, - 0x70, 0x12, 0x2a, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x6f, - 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0xab, 0x01, - 0x0a, 0x15, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, - 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x12, - 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, - 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, - 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x58, 0x0a, 0x16, 0x52, - 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x2a, 0x0a, 0x07, 0x70, 0x72, 0x6f, - 0x6d, 0x69, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, - 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0xaa, 0x01, 0x0a, 0x14, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, - 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, - 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, - 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x12, 0x24, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, - 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, - 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x49, 0x64, 0x22, 0x57, 0x0a, 0x15, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x6d, - 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x12, - 0x2a, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, - 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2a, 0x5e, 0x0a, 0x05, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, - 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x10, 0x01, 0x12, - 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x15, 0x0a, - 0x11, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x5f, 0x54, 0x49, 0x4d, 0x45, 0x44, 0x4f, - 0x55, 0x54, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, - 0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x45, 0x44, 0x10, 0x04, 0x2a, 0x5b, 0x0a, 0x0b, 0x53, - 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x45, - 0x41, 0x52, 0x43, 0x48, 0x5f, 0x41, 0x4c, 0x4c, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x45, - 0x41, 0x52, 0x43, 0x48, 0x5f, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x13, - 0x0a, 0x0f, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, 0x5f, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, - 0x44, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, 0x5f, 0x52, 0x45, - 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x03, 0x32, 0xf6, 0x03, 0x0a, 0x08, 0x50, 0x72, 0x6f, - 0x6d, 0x69, 0x73, 0x65, 0x73, 0x12, 0x4a, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x50, 0x72, 0x6f, - 0x6d, 0x69, 0x73, 0x65, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, - 0x65, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, - 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x53, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, - 0x73, 0x65, 0x73, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x65, - 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x65, - 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, - 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x0d, 0x43, 0x61, 0x6e, 0x63, - 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x6d, - 0x69, 0x73, 0x65, 0x2e, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, - 0x73, 0x65, 0x2e, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x0e, 0x52, 0x65, - 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x1e, 0x2e, 0x70, - 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, - 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x50, 0x0a, 0x0d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, - 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x6a, 0x65, 0x63, - 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, - 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x45, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, - 0x61, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x67, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescOnce sync.Once - file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescData = file_internal_app_subsystems_api_grpc_api_promise_proto_rawDesc -) - -func file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescGZIP() []byte { - file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescOnce.Do(func() { - file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescData) - }) - return file_internal_app_subsystems_api_grpc_api_promise_proto_rawDescData -} - -var file_internal_app_subsystems_api_grpc_api_promise_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes = make([]protoimpl.MessageInfo, 17) -var file_internal_app_subsystems_api_grpc_api_promise_proto_goTypes = []interface{}{ - (State)(0), // 0: promise.State - (SearchState)(0), // 1: promise.SearchState - (*Promise)(nil), // 2: promise.Promise - (*Value)(nil), // 3: promise.Value - (*ReadPromiseRequest)(nil), // 4: promise.ReadPromiseRequest - (*ReadPromiseResponse)(nil), // 5: promise.ReadPromiseResponse - (*SearchPromisesRequest)(nil), // 6: promise.SearchPromisesRequest - (*SearchPromisesResponse)(nil), // 7: promise.SearchPromisesResponse - (*CreatePromiseRequest)(nil), // 8: promise.CreatePromiseRequest - (*CreatePromiseResponse)(nil), // 9: promise.CreatePromiseResponse - (*CancelPromiseRequest)(nil), // 10: promise.CancelPromiseRequest - (*CancelPromiseResponse)(nil), // 11: promise.CancelPromiseResponse - (*ResolvePromiseRequest)(nil), // 12: promise.ResolvePromiseRequest - (*ResolvePromiseResponse)(nil), // 13: promise.ResolvePromiseResponse - (*RejectPromiseRequest)(nil), // 14: promise.RejectPromiseRequest - (*RejectPromiseResponse)(nil), // 15: promise.RejectPromiseResponse - nil, // 16: promise.Promise.TagsEntry - nil, // 17: promise.Value.HeadersEntry - nil, // 18: promise.SearchPromisesRequest.TagsEntry -} -var file_internal_app_subsystems_api_grpc_api_promise_proto_depIdxs = []int32{ - 0, // 0: promise.Promise.state:type_name -> promise.State - 3, // 1: promise.Promise.param:type_name -> promise.Value - 3, // 2: promise.Promise.value:type_name -> promise.Value - 16, // 3: promise.Promise.tags:type_name -> promise.Promise.TagsEntry - 17, // 4: promise.Value.headers:type_name -> promise.Value.HeadersEntry - 2, // 5: promise.ReadPromiseResponse.promise:type_name -> promise.Promise - 1, // 6: promise.SearchPromisesRequest.state:type_name -> promise.SearchState - 18, // 7: promise.SearchPromisesRequest.tags:type_name -> promise.SearchPromisesRequest.TagsEntry - 2, // 8: promise.SearchPromisesResponse.promises:type_name -> promise.Promise - 3, // 9: promise.CreatePromiseRequest.param:type_name -> promise.Value - 2, // 10: promise.CreatePromiseResponse.promise:type_name -> promise.Promise - 3, // 11: promise.CancelPromiseRequest.value:type_name -> promise.Value - 2, // 12: promise.CancelPromiseResponse.promise:type_name -> promise.Promise - 3, // 13: promise.ResolvePromiseRequest.value:type_name -> promise.Value - 2, // 14: promise.ResolvePromiseResponse.promise:type_name -> promise.Promise - 3, // 15: promise.RejectPromiseRequest.value:type_name -> promise.Value - 2, // 16: promise.RejectPromiseResponse.promise:type_name -> promise.Promise - 4, // 17: promise.Promises.ReadPromise:input_type -> promise.ReadPromiseRequest - 6, // 18: promise.Promises.SearchPromises:input_type -> promise.SearchPromisesRequest - 8, // 19: promise.Promises.CreatePromise:input_type -> promise.CreatePromiseRequest - 10, // 20: promise.Promises.CancelPromise:input_type -> promise.CancelPromiseRequest - 12, // 21: promise.Promises.ResolvePromise:input_type -> promise.ResolvePromiseRequest - 14, // 22: promise.Promises.RejectPromise:input_type -> promise.RejectPromiseRequest - 5, // 23: promise.Promises.ReadPromise:output_type -> promise.ReadPromiseResponse - 7, // 24: promise.Promises.SearchPromises:output_type -> promise.SearchPromisesResponse - 9, // 25: promise.Promises.CreatePromise:output_type -> promise.CreatePromiseResponse - 11, // 26: promise.Promises.CancelPromise:output_type -> promise.CancelPromiseResponse - 13, // 27: promise.Promises.ResolvePromise:output_type -> promise.ResolvePromiseResponse - 15, // 28: promise.Promises.RejectPromise:output_type -> promise.RejectPromiseResponse - 23, // [23:29] is the sub-list for method output_type - 17, // [17:23] is the sub-list for method input_type - 17, // [17:17] is the sub-list for extension type_name - 17, // [17:17] is the sub-list for extension extendee - 0, // [0:17] is the sub-list for field type_name -} - -func init() { file_internal_app_subsystems_api_grpc_api_promise_proto_init() } -func file_internal_app_subsystems_api_grpc_api_promise_proto_init() { - if File_internal_app_subsystems_api_grpc_api_promise_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Promise); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Value); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadPromiseRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadPromiseResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SearchPromisesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SearchPromisesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreatePromiseRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreatePromiseResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CancelPromiseRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CancelPromiseResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResolvePromiseRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResolvePromiseResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RejectPromiseRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RejectPromiseResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_internal_app_subsystems_api_grpc_api_promise_proto_rawDesc, - NumEnums: 2, - NumMessages: 17, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_internal_app_subsystems_api_grpc_api_promise_proto_goTypes, - DependencyIndexes: file_internal_app_subsystems_api_grpc_api_promise_proto_depIdxs, - EnumInfos: file_internal_app_subsystems_api_grpc_api_promise_proto_enumTypes, - MessageInfos: file_internal_app_subsystems_api_grpc_api_promise_proto_msgTypes, - }.Build() - File_internal_app_subsystems_api_grpc_api_promise_proto = out.File - file_internal_app_subsystems_api_grpc_api_promise_proto_rawDesc = nil - file_internal_app_subsystems_api_grpc_api_promise_proto_goTypes = nil - file_internal_app_subsystems_api_grpc_api_promise_proto_depIdxs = nil -} diff --git a/internal/app/subsystems/api/grpc/api/schedule.pb.go b/internal/app/subsystems/api/grpc/api/schedule.pb.go deleted file mode 100644 index f88e1b64..00000000 --- a/internal/app/subsystems/api/grpc/api/schedule.pb.go +++ /dev/null @@ -1,1005 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/schedule.proto - -package api - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Schedule struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - Cron string `protobuf:"bytes,3,opt,name=cron,proto3" json:"cron,omitempty"` - Tags map[string]string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - PromiseId string `protobuf:"bytes,5,opt,name=promiseId,proto3" json:"promiseId,omitempty"` - PromiseTimeout int64 `protobuf:"varint,6,opt,name=promiseTimeout,proto3" json:"promiseTimeout,omitempty"` - PromiseParam *Value `protobuf:"bytes,7,opt,name=promiseParam,proto3" json:"promiseParam,omitempty"` - PromiseTags map[string]string `protobuf:"bytes,8,rep,name=promiseTags,proto3" json:"promiseTags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - IdempotencyKey string `protobuf:"bytes,9,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` - LastRunTime int64 `protobuf:"varint,10,opt,name=lastRunTime,proto3" json:"lastRunTime,omitempty"` - NextRunTime int64 `protobuf:"varint,11,opt,name=nextRunTime,proto3" json:"nextRunTime,omitempty"` - CreatedOn int64 `protobuf:"varint,12,opt,name=createdOn,proto3" json:"createdOn,omitempty"` -} - -func (x *Schedule) Reset() { - *x = Schedule{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Schedule) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Schedule) ProtoMessage() {} - -func (x *Schedule) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Schedule.ProtoReflect.Descriptor instead. -func (*Schedule) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP(), []int{0} -} - -func (x *Schedule) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *Schedule) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Schedule) GetCron() string { - if x != nil { - return x.Cron - } - return "" -} - -func (x *Schedule) GetTags() map[string]string { - if x != nil { - return x.Tags - } - return nil -} - -func (x *Schedule) GetPromiseId() string { - if x != nil { - return x.PromiseId - } - return "" -} - -func (x *Schedule) GetPromiseTimeout() int64 { - if x != nil { - return x.PromiseTimeout - } - return 0 -} - -func (x *Schedule) GetPromiseParam() *Value { - if x != nil { - return x.PromiseParam - } - return nil -} - -func (x *Schedule) GetPromiseTags() map[string]string { - if x != nil { - return x.PromiseTags - } - return nil -} - -func (x *Schedule) GetIdempotencyKey() string { - if x != nil { - return x.IdempotencyKey - } - return "" -} - -func (x *Schedule) GetLastRunTime() int64 { - if x != nil { - return x.LastRunTime - } - return 0 -} - -func (x *Schedule) GetNextRunTime() int64 { - if x != nil { - return x.NextRunTime - } - return 0 -} - -func (x *Schedule) GetCreatedOn() int64 { - if x != nil { - return x.CreatedOn - } - return 0 -} - -type CreateScheduleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - Cron string `protobuf:"bytes,3,opt,name=cron,proto3" json:"cron,omitempty"` - Tags map[string]string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - PromiseId string `protobuf:"bytes,5,opt,name=promiseId,proto3" json:"promiseId,omitempty"` - PromiseTimeout int64 `protobuf:"varint,6,opt,name=promiseTimeout,proto3" json:"promiseTimeout,omitempty"` - PromiseParam *Value `protobuf:"bytes,7,opt,name=promiseParam,proto3" json:"promiseParam,omitempty"` - PromiseTags map[string]string `protobuf:"bytes,8,rep,name=promiseTags,proto3" json:"promiseTags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - IdempotencyKey string `protobuf:"bytes,9,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` - RequestId string `protobuf:"bytes,10,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *CreateScheduleRequest) Reset() { - *x = CreateScheduleRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateScheduleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateScheduleRequest) ProtoMessage() {} - -func (x *CreateScheduleRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateScheduleRequest.ProtoReflect.Descriptor instead. -func (*CreateScheduleRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP(), []int{1} -} - -func (x *CreateScheduleRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CreateScheduleRequest) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *CreateScheduleRequest) GetCron() string { - if x != nil { - return x.Cron - } - return "" -} - -func (x *CreateScheduleRequest) GetTags() map[string]string { - if x != nil { - return x.Tags - } - return nil -} - -func (x *CreateScheduleRequest) GetPromiseId() string { - if x != nil { - return x.PromiseId - } - return "" -} - -func (x *CreateScheduleRequest) GetPromiseTimeout() int64 { - if x != nil { - return x.PromiseTimeout - } - return 0 -} - -func (x *CreateScheduleRequest) GetPromiseParam() *Value { - if x != nil { - return x.PromiseParam - } - return nil -} - -func (x *CreateScheduleRequest) GetPromiseTags() map[string]string { - if x != nil { - return x.PromiseTags - } - return nil -} - -func (x *CreateScheduleRequest) GetIdempotencyKey() string { - if x != nil { - return x.IdempotencyKey - } - return "" -} - -func (x *CreateScheduleRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type CreatedScheduleResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` - Schedule *Schedule `protobuf:"bytes,2,opt,name=schedule,proto3" json:"schedule,omitempty"` -} - -func (x *CreatedScheduleResponse) Reset() { - *x = CreatedScheduleResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreatedScheduleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreatedScheduleResponse) ProtoMessage() {} - -func (x *CreatedScheduleResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreatedScheduleResponse.ProtoReflect.Descriptor instead. -func (*CreatedScheduleResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP(), []int{2} -} - -func (x *CreatedScheduleResponse) GetNoop() bool { - if x != nil { - return x.Noop - } - return false -} - -func (x *CreatedScheduleResponse) GetSchedule() *Schedule { - if x != nil { - return x.Schedule - } - return nil -} - -type ReadScheduleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *ReadScheduleRequest) Reset() { - *x = ReadScheduleRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReadScheduleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadScheduleRequest) ProtoMessage() {} - -func (x *ReadScheduleRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadScheduleRequest.ProtoReflect.Descriptor instead. -func (*ReadScheduleRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP(), []int{3} -} - -func (x *ReadScheduleRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *ReadScheduleRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type ReadScheduleResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Schedule *Schedule `protobuf:"bytes,1,opt,name=schedule,proto3" json:"schedule,omitempty"` -} - -func (x *ReadScheduleResponse) Reset() { - *x = ReadScheduleResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReadScheduleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadScheduleResponse) ProtoMessage() {} - -func (x *ReadScheduleResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadScheduleResponse.ProtoReflect.Descriptor instead. -func (*ReadScheduleResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP(), []int{4} -} - -func (x *ReadScheduleResponse) GetSchedule() *Schedule { - if x != nil { - return x.Schedule - } - return nil -} - -type SearchSchedulesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Tags map[string]string `protobuf:"bytes,2,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Limit int32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` - Cursor string `protobuf:"bytes,4,opt,name=cursor,proto3" json:"cursor,omitempty"` - RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *SearchSchedulesRequest) Reset() { - *x = SearchSchedulesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SearchSchedulesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SearchSchedulesRequest) ProtoMessage() {} - -func (x *SearchSchedulesRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SearchSchedulesRequest.ProtoReflect.Descriptor instead. -func (*SearchSchedulesRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP(), []int{5} -} - -func (x *SearchSchedulesRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *SearchSchedulesRequest) GetTags() map[string]string { - if x != nil { - return x.Tags - } - return nil -} - -func (x *SearchSchedulesRequest) GetLimit() int32 { - if x != nil { - return x.Limit - } - return 0 -} - -func (x *SearchSchedulesRequest) GetCursor() string { - if x != nil { - return x.Cursor - } - return "" -} - -func (x *SearchSchedulesRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type SearchSchedulesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Cursor string `protobuf:"bytes,1,opt,name=cursor,proto3" json:"cursor,omitempty"` - Schedules []*Schedule `protobuf:"bytes,2,rep,name=schedules,proto3" json:"schedules,omitempty"` -} - -func (x *SearchSchedulesResponse) Reset() { - *x = SearchSchedulesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SearchSchedulesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SearchSchedulesResponse) ProtoMessage() {} - -func (x *SearchSchedulesResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SearchSchedulesResponse.ProtoReflect.Descriptor instead. -func (*SearchSchedulesResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP(), []int{6} -} - -func (x *SearchSchedulesResponse) GetCursor() string { - if x != nil { - return x.Cursor - } - return "" -} - -func (x *SearchSchedulesResponse) GetSchedules() []*Schedule { - if x != nil { - return x.Schedules - } - return nil -} - -type DeleteScheduleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *DeleteScheduleRequest) Reset() { - *x = DeleteScheduleRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteScheduleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteScheduleRequest) ProtoMessage() {} - -func (x *DeleteScheduleRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteScheduleRequest.ProtoReflect.Descriptor instead. -func (*DeleteScheduleRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP(), []int{7} -} - -func (x *DeleteScheduleRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *DeleteScheduleRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type DeleteScheduleResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *DeleteScheduleResponse) Reset() { - *x = DeleteScheduleResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteScheduleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteScheduleResponse) ProtoMessage() {} - -func (x *DeleteScheduleResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteScheduleResponse.ProtoReflect.Descriptor instead. -func (*DeleteScheduleResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP(), []int{8} -} - -var File_internal_app_subsystems_api_grpc_api_schedule_proto protoreflect.FileDescriptor - -var file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDesc = []byte{ - 0x0a, 0x33, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, - 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, - 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x1a, - 0x32, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, - 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, - 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xc6, 0x04, 0x0a, 0x08, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x04, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, - 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6d, - 0x69, 0x73, 0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, - 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, - 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, - 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x32, - 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x56, - 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x50, 0x61, 0x72, - 0x61, 0x6d, 0x12, 0x45, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, - 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, - 0x6c, 0x65, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6d, - 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x70, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, - 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, - 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x75, 0x6e, 0x54, 0x69, 0x6d, 0x65, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x75, 0x6e, 0x54, - 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x65, 0x78, 0x74, 0x52, 0x75, 0x6e, 0x54, 0x69, - 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6e, 0x65, 0x78, 0x74, 0x52, 0x75, - 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, - 0x4f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x4f, 0x6e, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, - 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa9, 0x04, 0x0a, - 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x72, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x12, 0x3d, 0x0a, 0x04, - 0x74, 0x61, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x63, 0x68, - 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, - 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x61, 0x67, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x70, - 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x72, 0x6f, - 0x6d, 0x69, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x12, 0x32, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, - 0x65, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x52, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, - 0x54, 0x61, 0x67, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x73, 0x63, 0x68, - 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, - 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, - 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x70, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, - 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, - 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x1a, - 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x6d, - 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x5d, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x64, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x2e, 0x0a, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, - 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x63, 0x68, 0x65, - 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x08, 0x73, - 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x43, 0x0a, 0x13, 0x52, 0x65, 0x61, 0x64, 0x53, - 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, - 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x46, 0x0a, 0x14, - 0x52, 0x65, 0x61, 0x64, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, - 0x65, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x08, 0x73, 0x63, 0x68, 0x65, - 0x64, 0x75, 0x6c, 0x65, 0x22, 0xed, 0x01, 0x0a, 0x16, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, - 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x3e, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, - 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, - 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, - 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, - 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, - 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, 0x1c, 0x0a, - 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x1a, 0x37, 0x0a, 0x09, 0x54, - 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x22, 0x63, 0x0a, 0x17, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x63, - 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x16, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, 0x30, 0x0a, 0x09, 0x73, 0x63, 0x68, 0x65, 0x64, - 0x75, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x63, 0x68, - 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x09, - 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x45, 0x0a, 0x15, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, - 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, - 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xe5, 0x02, 0x0a, 0x09, 0x53, - 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x56, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1f, 0x2e, 0x73, 0x63, 0x68, - 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, - 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x63, - 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x63, - 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x4f, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, - 0x12, 0x1d, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, - 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1e, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x53, - 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x58, 0x0a, 0x0f, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x63, 0x68, 0x65, 0x64, - 0x75, 0x6c, 0x65, 0x73, 0x12, 0x20, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, - 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, - 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x0e, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1f, 0x2e, - 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, - 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, - 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x42, 0x45, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, - 0x6e, 0x61, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, - 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var ( - file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescOnce sync.Once - file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescData = file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDesc -) - -func file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescGZIP() []byte { - file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescOnce.Do(func() { - file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescData) - }) - return file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDescData -} - -var file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes = make([]protoimpl.MessageInfo, 14) -var file_internal_app_subsystems_api_grpc_api_schedule_proto_goTypes = []interface{}{ - (*Schedule)(nil), // 0: schedule.Schedule - (*CreateScheduleRequest)(nil), // 1: schedule.CreateScheduleRequest - (*CreatedScheduleResponse)(nil), // 2: schedule.CreatedScheduleResponse - (*ReadScheduleRequest)(nil), // 3: schedule.ReadScheduleRequest - (*ReadScheduleResponse)(nil), // 4: schedule.ReadScheduleResponse - (*SearchSchedulesRequest)(nil), // 5: schedule.SearchSchedulesRequest - (*SearchSchedulesResponse)(nil), // 6: schedule.SearchSchedulesResponse - (*DeleteScheduleRequest)(nil), // 7: schedule.DeleteScheduleRequest - (*DeleteScheduleResponse)(nil), // 8: schedule.DeleteScheduleResponse - nil, // 9: schedule.Schedule.TagsEntry - nil, // 10: schedule.Schedule.PromiseTagsEntry - nil, // 11: schedule.CreateScheduleRequest.TagsEntry - nil, // 12: schedule.CreateScheduleRequest.PromiseTagsEntry - nil, // 13: schedule.SearchSchedulesRequest.TagsEntry - (*Value)(nil), // 14: promise.Value -} -var file_internal_app_subsystems_api_grpc_api_schedule_proto_depIdxs = []int32{ - 9, // 0: schedule.Schedule.tags:type_name -> schedule.Schedule.TagsEntry - 14, // 1: schedule.Schedule.promiseParam:type_name -> promise.Value - 10, // 2: schedule.Schedule.promiseTags:type_name -> schedule.Schedule.PromiseTagsEntry - 11, // 3: schedule.CreateScheduleRequest.tags:type_name -> schedule.CreateScheduleRequest.TagsEntry - 14, // 4: schedule.CreateScheduleRequest.promiseParam:type_name -> promise.Value - 12, // 5: schedule.CreateScheduleRequest.promiseTags:type_name -> schedule.CreateScheduleRequest.PromiseTagsEntry - 0, // 6: schedule.CreatedScheduleResponse.schedule:type_name -> schedule.Schedule - 0, // 7: schedule.ReadScheduleResponse.schedule:type_name -> schedule.Schedule - 13, // 8: schedule.SearchSchedulesRequest.tags:type_name -> schedule.SearchSchedulesRequest.TagsEntry - 0, // 9: schedule.SearchSchedulesResponse.schedules:type_name -> schedule.Schedule - 1, // 10: schedule.Schedules.CreateSchedule:input_type -> schedule.CreateScheduleRequest - 3, // 11: schedule.Schedules.ReadSchedule:input_type -> schedule.ReadScheduleRequest - 5, // 12: schedule.Schedules.SearchSchedules:input_type -> schedule.SearchSchedulesRequest - 7, // 13: schedule.Schedules.DeleteSchedule:input_type -> schedule.DeleteScheduleRequest - 2, // 14: schedule.Schedules.CreateSchedule:output_type -> schedule.CreatedScheduleResponse - 4, // 15: schedule.Schedules.ReadSchedule:output_type -> schedule.ReadScheduleResponse - 6, // 16: schedule.Schedules.SearchSchedules:output_type -> schedule.SearchSchedulesResponse - 8, // 17: schedule.Schedules.DeleteSchedule:output_type -> schedule.DeleteScheduleResponse - 14, // [14:18] is the sub-list for method output_type - 10, // [10:14] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name -} - -func init() { file_internal_app_subsystems_api_grpc_api_schedule_proto_init() } -func file_internal_app_subsystems_api_grpc_api_schedule_proto_init() { - if File_internal_app_subsystems_api_grpc_api_schedule_proto != nil { - return - } - file_internal_app_subsystems_api_grpc_api_promise_proto_init() - if !protoimpl.UnsafeEnabled { - file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Schedule); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateScheduleRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreatedScheduleResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadScheduleRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadScheduleResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SearchSchedulesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SearchSchedulesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteScheduleRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteScheduleResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDesc, - NumEnums: 0, - NumMessages: 14, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_internal_app_subsystems_api_grpc_api_schedule_proto_goTypes, - DependencyIndexes: file_internal_app_subsystems_api_grpc_api_schedule_proto_depIdxs, - MessageInfos: file_internal_app_subsystems_api_grpc_api_schedule_proto_msgTypes, - }.Build() - File_internal_app_subsystems_api_grpc_api_schedule_proto = out.File - file_internal_app_subsystems_api_grpc_api_schedule_proto_rawDesc = nil - file_internal_app_subsystems_api_grpc_api_schedule_proto_goTypes = nil - file_internal_app_subsystems_api_grpc_api_schedule_proto_depIdxs = nil -} diff --git a/internal/app/subsystems/api/grpc/api/task.pb.go b/internal/app/subsystems/api/grpc/api/task.pb.go deleted file mode 100644 index f95f691d..00000000 --- a/internal/app/subsystems/api/grpc/api/task.pb.go +++ /dev/null @@ -1,566 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/task.proto - -package api - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ClaimTaskRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - ProcessId string `protobuf:"bytes,2,opt,name=processId,proto3" json:"processId,omitempty"` - Counter int32 `protobuf:"varint,3,opt,name=counter,proto3" json:"counter,omitempty"` - Frequency int32 `protobuf:"varint,4,opt,name=frequency,proto3" json:"frequency,omitempty"` - RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *ClaimTaskRequest) Reset() { - *x = ClaimTaskRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ClaimTaskRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ClaimTaskRequest) ProtoMessage() {} - -func (x *ClaimTaskRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ClaimTaskRequest.ProtoReflect.Descriptor instead. -func (*ClaimTaskRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_task_proto_rawDescGZIP(), []int{0} -} - -func (x *ClaimTaskRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *ClaimTaskRequest) GetProcessId() string { - if x != nil { - return x.ProcessId - } - return "" -} - -func (x *ClaimTaskRequest) GetCounter() int32 { - if x != nil { - return x.Counter - } - return 0 -} - -func (x *ClaimTaskRequest) GetFrequency() int32 { - if x != nil { - return x.Frequency - } - return 0 -} - -func (x *ClaimTaskRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type ClaimTaskResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Promises map[string]*Promise `protobuf:"bytes,2,rep,name=promises,proto3" json:"promises,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *ClaimTaskResponse) Reset() { - *x = ClaimTaskResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ClaimTaskResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ClaimTaskResponse) ProtoMessage() {} - -func (x *ClaimTaskResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ClaimTaskResponse.ProtoReflect.Descriptor instead. -func (*ClaimTaskResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_task_proto_rawDescGZIP(), []int{1} -} - -func (x *ClaimTaskResponse) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *ClaimTaskResponse) GetPromises() map[string]*Promise { - if x != nil { - return x.Promises - } - return nil -} - -type CompleteTaskRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Counter int32 `protobuf:"varint,2,opt,name=counter,proto3" json:"counter,omitempty"` - RequestId string `protobuf:"bytes,3,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *CompleteTaskRequest) Reset() { - *x = CompleteTaskRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CompleteTaskRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CompleteTaskRequest) ProtoMessage() {} - -func (x *CompleteTaskRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CompleteTaskRequest.ProtoReflect.Descriptor instead. -func (*CompleteTaskRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_task_proto_rawDescGZIP(), []int{2} -} - -func (x *CompleteTaskRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CompleteTaskRequest) GetCounter() int32 { - if x != nil { - return x.Counter - } - return 0 -} - -func (x *CompleteTaskRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type CompleteTaskResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *CompleteTaskResponse) Reset() { - *x = CompleteTaskResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CompleteTaskResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CompleteTaskResponse) ProtoMessage() {} - -func (x *CompleteTaskResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CompleteTaskResponse.ProtoReflect.Descriptor instead. -func (*CompleteTaskResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_task_proto_rawDescGZIP(), []int{3} -} - -type HeartbeatTasksRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProcessId string `protobuf:"bytes,1,opt,name=processId,proto3" json:"processId,omitempty"` - RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` -} - -func (x *HeartbeatTasksRequest) Reset() { - *x = HeartbeatTasksRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HeartbeatTasksRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HeartbeatTasksRequest) ProtoMessage() {} - -func (x *HeartbeatTasksRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HeartbeatTasksRequest.ProtoReflect.Descriptor instead. -func (*HeartbeatTasksRequest) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_task_proto_rawDescGZIP(), []int{4} -} - -func (x *HeartbeatTasksRequest) GetProcessId() string { - if x != nil { - return x.ProcessId - } - return "" -} - -func (x *HeartbeatTasksRequest) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -type HeartbeatTasksResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - TasksAffected int64 `protobuf:"varint,1,opt,name=tasksAffected,proto3" json:"tasksAffected,omitempty"` -} - -func (x *HeartbeatTasksResponse) Reset() { - *x = HeartbeatTasksResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HeartbeatTasksResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HeartbeatTasksResponse) ProtoMessage() {} - -func (x *HeartbeatTasksResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HeartbeatTasksResponse.ProtoReflect.Descriptor instead. -func (*HeartbeatTasksResponse) Descriptor() ([]byte, []int) { - return file_internal_app_subsystems_api_grpc_api_task_proto_rawDescGZIP(), []int{5} -} - -func (x *HeartbeatTasksResponse) GetTasksAffected() int64 { - if x != nil { - return x.TasksAffected - } - return 0 -} - -var File_internal_app_subsystems_api_grpc_api_task_proto protoreflect.FileDescriptor - -var file_internal_app_subsystems_api_grpc_api_task_proto_rawDesc = []byte{ - 0x0a, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, - 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, - 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x1a, 0x32, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x96, 0x01, 0x0a, 0x10, - 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x72, 0x65, 0x71, - 0x75, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x66, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x49, 0x64, 0x22, 0xb9, 0x01, 0x0a, 0x11, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, - 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x41, - 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x25, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, - 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, - 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, - 0x73, 0x1a, 0x4d, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x50, 0x72, - 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x22, 0x5d, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, - 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, - 0x16, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x53, 0x0a, 0x15, 0x48, 0x65, 0x61, 0x72, 0x74, - 0x62, 0x65, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x1c, - 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x3e, 0x0a, 0x16, - 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x41, - 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x74, - 0x61, 0x73, 0x6b, 0x73, 0x41, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x32, 0xdf, 0x01, 0x0a, - 0x05, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, - 0x61, 0x73, 0x6b, 0x12, 0x16, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, - 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x74, 0x61, - 0x73, 0x6b, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0c, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, - 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x19, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x43, 0x6f, - 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1a, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, - 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x4d, 0x0a, 0x0e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, - 0x73, 0x12, 0x1b, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, - 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, - 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x54, - 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, - 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x73, - 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, - 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, - 0x63, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_internal_app_subsystems_api_grpc_api_task_proto_rawDescOnce sync.Once - file_internal_app_subsystems_api_grpc_api_task_proto_rawDescData = file_internal_app_subsystems_api_grpc_api_task_proto_rawDesc -) - -func file_internal_app_subsystems_api_grpc_api_task_proto_rawDescGZIP() []byte { - file_internal_app_subsystems_api_grpc_api_task_proto_rawDescOnce.Do(func() { - file_internal_app_subsystems_api_grpc_api_task_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_api_task_proto_rawDescData) - }) - return file_internal_app_subsystems_api_grpc_api_task_proto_rawDescData -} - -var file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_internal_app_subsystems_api_grpc_api_task_proto_goTypes = []interface{}{ - (*ClaimTaskRequest)(nil), // 0: task.ClaimTaskRequest - (*ClaimTaskResponse)(nil), // 1: task.ClaimTaskResponse - (*CompleteTaskRequest)(nil), // 2: task.CompleteTaskRequest - (*CompleteTaskResponse)(nil), // 3: task.CompleteTaskResponse - (*HeartbeatTasksRequest)(nil), // 4: task.HeartbeatTasksRequest - (*HeartbeatTasksResponse)(nil), // 5: task.HeartbeatTasksResponse - nil, // 6: task.ClaimTaskResponse.PromisesEntry - (*Promise)(nil), // 7: promise.Promise -} -var file_internal_app_subsystems_api_grpc_api_task_proto_depIdxs = []int32{ - 6, // 0: task.ClaimTaskResponse.promises:type_name -> task.ClaimTaskResponse.PromisesEntry - 7, // 1: task.ClaimTaskResponse.PromisesEntry.value:type_name -> promise.Promise - 0, // 2: task.Tasks.ClaimTask:input_type -> task.ClaimTaskRequest - 2, // 3: task.Tasks.CompleteTask:input_type -> task.CompleteTaskRequest - 4, // 4: task.Tasks.HeartbeatTasks:input_type -> task.HeartbeatTasksRequest - 1, // 5: task.Tasks.ClaimTask:output_type -> task.ClaimTaskResponse - 3, // 6: task.Tasks.CompleteTask:output_type -> task.CompleteTaskResponse - 5, // 7: task.Tasks.HeartbeatTasks:output_type -> task.HeartbeatTasksResponse - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_internal_app_subsystems_api_grpc_api_task_proto_init() } -func file_internal_app_subsystems_api_grpc_api_task_proto_init() { - if File_internal_app_subsystems_api_grpc_api_task_proto != nil { - return - } - file_internal_app_subsystems_api_grpc_api_promise_proto_init() - if !protoimpl.UnsafeEnabled { - file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ClaimTaskRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ClaimTaskResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CompleteTaskRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CompleteTaskResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HeartbeatTasksRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HeartbeatTasksResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_internal_app_subsystems_api_grpc_api_task_proto_rawDesc, - NumEnums: 0, - NumMessages: 7, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_internal_app_subsystems_api_grpc_api_task_proto_goTypes, - DependencyIndexes: file_internal_app_subsystems_api_grpc_api_task_proto_depIdxs, - MessageInfos: file_internal_app_subsystems_api_grpc_api_task_proto_msgTypes, - }.Build() - File_internal_app_subsystems_api_grpc_api_task_proto = out.File - file_internal_app_subsystems_api_grpc_api_task_proto_rawDesc = nil - file_internal_app_subsystems_api_grpc_api_task_proto_goTypes = nil - file_internal_app_subsystems_api_grpc_api_task_proto_depIdxs = nil -} diff --git a/internal/app/subsystems/api/grpc/callback.go b/internal/app/subsystems/api/grpc/callback.go index 982564f1..3ae7a771 100644 --- a/internal/app/subsystems/api/grpc/callback.go +++ b/internal/app/subsystems/api/grpc/callback.go @@ -4,68 +4,64 @@ import ( "context" "encoding/json" - grpcApi "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb" "github.com/resonatehq/resonate/internal/kernel/t_api" + "github.com/resonatehq/resonate/internal/util" "github.com/resonatehq/resonate/pkg/callback" "github.com/resonatehq/resonate/pkg/receiver" "google.golang.org/grpc/codes" - grpcStatus "google.golang.org/grpc/status" + "google.golang.org/grpc/status" ) -func (s *server) CreateCallback(ctx context.Context, req *grpcApi.CreateCallbackRequest) (*grpcApi.CreateCallbackResponse, error) { - header := &service.Header{ - RequestId: req.RequestId, - } - - if req.PromiseId == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "callback.promiseId must be provided") - } - - var recv []byte - var rErr error - switch r := req.Recv.(type) { - case *grpcApi.CreateCallbackRequest_Logical: - recv, rErr = json.Marshal(&r.Logical) - case *grpcApi.CreateCallbackRequest_Physical: - recv, rErr = json.Marshal(&receiver.Recv{Type: r.Physical.Type, Data: r.Physical.Data}) - } - +func (s *server) CreateCallback(c context.Context, r *pb.CreateCallbackRequest) (*pb.CreateCallbackResponse, error) { + recv, rErr := protoRecv(r.Recv) if rErr != nil { - return nil, grpcStatus.Error(codes.InvalidArgument, rErr.Error()) - } - if recv == nil { - return nil, grpcStatus.Error(codes.InvalidArgument, "callback.recv must be provided") + return nil, rErr } - body := &service.CreateCallbackBody{ - PromiseId: req.PromiseId, - RootPromiseId: req.RootPromiseId, - Timeout: req.Timeout, - Recv: recv, - } - - res, err := s.service.CreateCallback(header, body) + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.CreateCallback, + CreateCallback: &t_api.CreateCallbackRequest{ + PromiseId: r.PromiseId, + RootPromiseId: r.RootPromiseId, + Timeout: r.Timeout, + Recv: recv, + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.CreateCallbackResponse{ - Noop: res.Status == t_api.StatusOK, - Callback: protoCallback(res.Callback), - Promise: protoPromise(res.Promise), + util.Assert(res.CreateCallback != nil, "result must not be nil") + return &pb.CreateCallbackResponse{ + Noop: res.CreateCallback.Status == t_api.StatusOK, + Callback: protoCallback(res.CreateCallback.Callback), + Promise: protoPromise(res.CreateCallback.Promise), }, nil } -func protoCallback(callback *callback.Callback) *grpcApi.Callback { +// Helper functions + +func protoCallback(callback *callback.Callback) *pb.Callback { if callback == nil { return nil } - return &grpcApi.Callback{ + return &pb.Callback{ Id: callback.Id, PromiseId: callback.PromiseId, Timeout: callback.Timeout, CreatedOn: callback.CreatedOn, } } + +func protoRecv(recv *pb.Recv) ([]byte, error) { + switch r := recv.Recv.(type) { + case *pb.Recv_Logical: + return json.Marshal(&r.Logical) + case *pb.Recv_Physical: + return json.Marshal(&receiver.Recv{Type: r.Physical.Type, Data: r.Physical.Data}) + default: + return nil, status.Error(codes.InvalidArgument, "The field recv is required.") + } +} diff --git a/internal/app/subsystems/api/grpc/grpc.go b/internal/app/subsystems/api/grpc/grpc.go index 4f19868c..8e945a3f 100644 --- a/internal/app/subsystems/api/grpc/grpc.go +++ b/internal/app/subsystems/api/grpc/grpc.go @@ -6,58 +6,63 @@ import ( "log/slog" "net" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + i_api "github.com/resonatehq/resonate/internal/api" + "github.com/resonatehq/resonate/internal/app/subsystems/api" + "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb" "github.com/resonatehq/resonate/internal/kernel/t_api" - - "github.com/resonatehq/resonate/internal/api" - grpcApi "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api" "google.golang.org/grpc" "google.golang.org/grpc/codes" ) type Config struct { - Host string `flag:"host" desc:"grpc server host" default:"0.0.0.0"` - Port int `flag:"port" desc:"grpc server port" default:"50051"` + Addr string `flag:"addr" desc:"grpc server address" default:":50051"` } type Grpc struct { config *Config + listen net.Listener server *grpc.Server } -func New(api api.API, config *Config) api.Subsystem { - s := &server{service: service.New(api, "grpc")} +func New(a i_api.API, config *Config) (i_api.Subsystem, error) { + s := &server{api: api.New(a, "grpc")} + + // Create a listener on specified address + listen, err := net.Listen("tcp", config.Addr) + if err != nil { + return nil, err + } server := grpc.NewServer(grpc.UnaryInterceptor(s.log)) // nosemgrep - grpcApi.RegisterPromisesServer(server, s) - grpcApi.RegisterCallbacksServer(server, s) - grpcApi.RegisterSchedulesServer(server, s) - grpcApi.RegisterLocksServer(server, s) - grpcApi.RegisterTasksServer(server, s) + pb.RegisterPromisesServer(server, s) + pb.RegisterCallbacksServer(server, s) + pb.RegisterSchedulesServer(server, s) + pb.RegisterLocksServer(server, s) + pb.RegisterTasksServer(server, s) return &Grpc{ config: config, + listen: listen, server: server, - } + }, nil } func (g *Grpc) String() string { return "grpc" } -func (g *Grpc) Start(errors chan<- error) { - addr := fmt.Sprintf("%s:%d", g.config.Host, g.config.Port) +func (g *Grpc) Kind() string { + return "grpc" +} - // Create a listener on a specific port - listen, err := net.Listen("tcp", addr) - if err != nil { - errors <- err - return - } +func (g *Grpc) Addr() string { + return g.listen.Addr().String() +} - // Start the gRPC server - slog.Info("starting grpc server", "addr", addr) - if err := g.server.Serve(listen); err != nil { +func (g *Grpc) Start(errors chan<- error) { + // Start the grpc server + slog.Info("starting grpc server", "addr", g.config.Addr) + if err := g.server.Serve(g.listen); err != nil { errors <- err } } @@ -68,12 +73,12 @@ func (g *Grpc) Stop() error { } type server struct { - grpcApi.UnimplementedPromisesServer - grpcApi.UnimplementedCallbacksServer - grpcApi.UnimplementedSchedulesServer - grpcApi.UnimplementedLocksServer - grpcApi.UnimplementedTasksServer - service *service.Service + pb.UnimplementedPromisesServer + pb.UnimplementedCallbacksServer + pb.UnimplementedSchedulesServer + pb.UnimplementedLocksServer + pb.UnimplementedTasksServer + api *api.API } func (s *server) code(status t_api.StatusCode) codes.Code { diff --git a/internal/app/subsystems/api/grpc/grpc_test.go b/internal/app/subsystems/api/grpc/grpc_test.go index c436c9a6..3365b230 100644 --- a/internal/app/subsystems/api/grpc/grpc_test.go +++ b/internal/app/subsystems/api/grpc/grpc_test.go @@ -7,21 +7,15 @@ import ( "time" "github.com/resonatehq/resonate/internal/api" - grpcApi "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api" + "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb" "github.com/resonatehq/resonate/internal/app/subsystems/api/test" - "github.com/resonatehq/resonate/internal/util" - "github.com/resonatehq/resonate/pkg/idempotency" - "github.com/resonatehq/resonate/pkg/lock" - "github.com/resonatehq/resonate/pkg/message" - "github.com/resonatehq/resonate/pkg/promise" - "github.com/resonatehq/resonate/pkg/schedule" - "github.com/resonatehq/resonate/internal/kernel/t_api" "github.com/stretchr/testify/assert" "google.golang.org/grpc" - "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" ) type grpcTest struct { @@ -29,26 +23,26 @@ type grpcTest struct { subsystem api.Subsystem errors chan error conn *grpc.ClientConn - promises grpcApi.PromisesClient - callbacks grpcApi.CallbacksClient - schedules grpcApi.SchedulesClient - locks grpcApi.LocksClient - tasks grpcApi.TasksClient + promises pb.PromisesClient + callbacks pb.CallbacksClient + schedules pb.SchedulesClient + locks pb.LocksClient + tasks pb.TasksClient } func setup() (*grpcTest, error) { api := &test.API{} errors := make(chan error) - subsystem := New(api, &Config{ - Host: "127.0.0.1", - Port: 5555, - }) + subsystem, err := New(api, &Config{Addr: ":0"}) + if err != nil { + return nil, err + } // start grpc server go subsystem.Start(errors) time.Sleep(100 * time.Millisecond) - conn, err := grpc.NewClient("127.0.0.1:5555", grpc.WithTransportCredentials(insecure.NewCredentials())) + conn, err := grpc.NewClient(subsystem.Addr(), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return nil, err } @@ -58,11 +52,11 @@ func setup() (*grpcTest, error) { subsystem: subsystem, errors: errors, conn: conn, - promises: grpcApi.NewPromisesClient(conn), - callbacks: grpcApi.NewCallbacksClient(conn), - schedules: grpcApi.NewSchedulesClient(conn), - locks: grpcApi.NewLocksClient(conn), - tasks: grpcApi.NewTasksClient(conn), + promises: pb.NewPromisesClient(conn), + callbacks: pb.NewCallbacksClient(conn), + schedules: pb.NewSchedulesClient(conn), + locks: pb.NewLocksClient(conn), + tasks: pb.NewTasksClient(conn), }, nil } @@ -76,2143 +70,85 @@ func (t *grpcTest) teardown() error { return t.subsystem.Stop() } -// Promises - -func TestReadPromise(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - for _, tc := range []struct { - name string - grpcReq *grpcApi.ReadPromiseRequest - req *t_api.Request - res *t_api.Response - code codes.Code // grpc error code - }{ - { - name: "ReadPromise", - grpcReq: &grpcApi.ReadPromiseRequest{ - RequestId: "ReadPromise", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.ReadPromise, - Tags: map[string]string{ - "id": "ReadPromise", - "name": "ReadPromise", - "protocol": "grpc", - }, - ReadPromise: &t_api.ReadPromiseRequest{ - Id: "foo", - }, - }, - res: &t_api.Response{ - Kind: t_api.ReadPromise, - ReadPromise: &t_api.ReadPromiseResponse{ - Status: t_api.StatusOK, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Pending, - }, - }, - }, - code: codes.OK, - }, - { - name: "ReadPromiseNotFound", - grpcReq: &grpcApi.ReadPromiseRequest{ - RequestId: "ReadPromiseNotFound", - Id: "bar", - }, - req: &t_api.Request{ - Kind: t_api.ReadPromise, - Tags: map[string]string{ - "id": "ReadPromiseNotFound", - "name": "ReadPromise", - "protocol": "grpc", - }, - ReadPromise: &t_api.ReadPromiseRequest{ - Id: "bar", - }, - }, - res: &t_api.Response{ - Kind: t_api.ReadPromise, - ReadPromise: &t_api.ReadPromiseResponse{ - Status: t_api.StatusPromiseNotFound, - Promise: nil, - }, - }, - code: codes.NotFound, - }, - } { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.promises.ReadPromise(ctx, tc.grpcReq) - if err != nil { - // actual grpc error - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.code, s.Code()) - return - } - - assert.Equal(t, tc.code, codes.OK) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestSearchPromises(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - for _, tc := range []struct { - name string - grpcReq *grpcApi.SearchPromisesRequest - req *t_api.Request - res *t_api.Response - }{ - { - name: "SearchPromises", - grpcReq: &grpcApi.SearchPromisesRequest{ - RequestId: "SearchPromises", - Id: "*", - Limit: 10, - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromises", - "name": "SearchPromises", - "protocol": "grpc", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Pending, - promise.Resolved, - promise.Rejected, - promise.Timedout, - promise.Canceled, - }, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - }, - { - name: "SearchPromisesCursor", - grpcReq: &grpcApi.SearchPromisesRequest{ - RequestId: "SearchPromisesCursor", - Cursor: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJOZXh0Ijp7ImlkIjoiKiIsInN0YXRlcyI6WyJQRU5ESU5HIl0sInRhZ3MiOnt9LCJsaW1pdCI6MTAsInNvcnRJZCI6MTAwfX0.XKusWO-Jl4v7QVIwh5Pn3oIElBvtpf0VPOLJkXPvQLk", - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesCursor", - "name": "SearchPromises", - "protocol": "grpc", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Pending, - }, - Tags: map[string]string{}, - Limit: 10, - SortId: util.ToPointer(int64(100)), - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, // not checked - Promises: []*promise.Promise{}, - }, - }, - }, - { - name: "SearchPromisesPending", - grpcReq: &grpcApi.SearchPromisesRequest{ - RequestId: "SearchPromisesPending", - Id: "*", - State: grpcApi.SearchState_SEARCH_PENDING, - Limit: 10, - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesPending", - "name": "SearchPromises", - "protocol": "grpc", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Pending, - }, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - }, - { - name: "SearchPromisesResolved", - grpcReq: &grpcApi.SearchPromisesRequest{ - RequestId: "SearchPromisesResolved", - Id: "*", - State: grpcApi.SearchState_SEARCH_RESOLVED, - Limit: 10, - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesResolved", - "name": "SearchPromises", - "protocol": "grpc", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Resolved, - }, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - }, - { - name: "SearchPromisesRejected", - grpcReq: &grpcApi.SearchPromisesRequest{ - RequestId: "SearchPromisesRejected", - Id: "*", - State: grpcApi.SearchState_SEARCH_REJECTED, - Limit: 10, - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesRejected", - "name": "SearchPromises", - "protocol": "grpc", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Rejected, - promise.Timedout, - promise.Canceled, - }, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - }, - { - name: "SearchPromisesTags", - grpcReq: &grpcApi.SearchPromisesRequest{ - RequestId: "SearchPromisesTags", - Id: "*", - Tags: map[string]string{ - "resonate:invocation": "true", - }, - Limit: 10, - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesTags", - "name": "SearchPromises", - "protocol": "grpc", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Pending, - promise.Resolved, - promise.Rejected, - promise.Timedout, - promise.Canceled, - }, - Tags: map[string]string{ - "resonate:invocation": "true", - }, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - }, - } { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.promises.SearchPromises(ctx, tc.grpcReq) - if err != nil { - t.Fatal(err) - } - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestCreatePromise(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - for _, tc := range []struct { - name string - grpcReq *grpcApi.CreatePromiseRequest - req *t_api.Request - res *t_api.Response - noop bool - expectedErr codes.Code - }{ - { - name: "CreatePromise", - grpcReq: &grpcApi.CreatePromiseRequest{ - RequestId: "CreatePromise", - Id: "foo", - IdempotencyKey: "bar", - Strict: true, - Param: &grpcApi.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("pending"), - }, - Timeout: 1, - }, - req: &t_api.Request{ - Kind: t_api.CreatePromise, - Tags: map[string]string{ - "id": "CreatePromise", - "name": "CreatePromise", - "protocol": "grpc", - }, - CreatePromise: &t_api.CreatePromiseRequest{ - Id: "foo", - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - Strict: true, - Param: promise.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("pending"), - }, - Timeout: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.CreatePromise, - CreatePromise: &t_api.CreatePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Pending, - }, - }, - }, - noop: false, - }, - { - name: "CreatePromiseMinimal", - grpcReq: &grpcApi.CreatePromiseRequest{ - RequestId: "CreatePromiseMinimal", - Id: "foo", - Timeout: 1, - }, - req: &t_api.Request{ - Kind: t_api.CreatePromise, - Tags: map[string]string{ - "id": "CreatePromiseMinimal", - "name": "CreatePromise", - "protocol": "grpc", - }, - CreatePromise: &t_api.CreatePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - Param: promise.Value{ - Headers: nil, - Data: nil, - }, - Timeout: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.CreatePromise, - CreatePromise: &t_api.CreatePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Pending, - }, - }, - }, - noop: false, - }, - { - name: "CreatePromiseNoTimeout", - grpcReq: &grpcApi.CreatePromiseRequest{ - RequestId: "CreatePromiseNoTimeout", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.CreatePromise, - Tags: map[string]string{ - "id": "CreatePromiseNoTimeout", - "name": "CreatePromise", - "protocol": "grpc", - }, - CreatePromise: &t_api.CreatePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - Param: promise.Value{ - Headers: nil, - Data: nil, - }, - Timeout: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.CreatePromise, - CreatePromise: &t_api.CreatePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Pending, - }, - }, - }, - noop: false, - expectedErr: codes.InvalidArgument, - }, - } { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - res, err := grpcTest.promises.CreatePromise(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.expectedErr, s.Code()) - return - } - - assert.Equal(t, tc.noop, res.Noop) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestCancelPromise(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - for _, tc := range []struct { - name string - grpcReq *grpcApi.CancelPromiseRequest - req *t_api.Request - res *t_api.Response - noop bool - expectedErr codes.Code - }{ - { - name: "CancelPromise", - grpcReq: &grpcApi.CancelPromiseRequest{ - RequestId: "CancelPromise", - Id: "foo", - IdempotencyKey: "bar", - Strict: true, - Value: &grpcApi.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("cancel"), - }, - }, - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "CancelPromise", - "name": "CompletePromise", - "protocol": "grpc", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - Strict: true, - State: promise.Canceled, - Value: promise.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("cancel"), - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Canceled, - }, - }, - }, - noop: false, - }, - { - name: "CancelPromiseMinimal", - grpcReq: &grpcApi.CancelPromiseRequest{ - RequestId: "CancelPromiseMinimal", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "CancelPromiseMinimal", - "name": "CompletePromise", - "protocol": "grpc", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - State: promise.Canceled, - Value: promise.Value{ - Headers: nil, - Data: nil, - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Canceled, - }, - }, - }, - noop: false, - }, - { - name: "CancelPromiseAlreadyResolved", - grpcReq: &grpcApi.CancelPromiseRequest{ - RequestId: "CancelPromiseAlreadyResolved", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "CancelPromiseAlreadyResolved", - "name": "CompletePromise", - "protocol": "grpc", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - State: promise.Canceled, - Value: promise.Value{ - Headers: nil, - Data: nil, - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusPromiseAlreadyResolved, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Resolved, - }, - }, - }, - noop: false, - expectedErr: codes.PermissionDenied, - }, - } { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - res, err := grpcTest.promises.CancelPromise(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.expectedErr, s.Code()) - return - } - - assert.Equal(t, tc.noop, res.Noop) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestResolvePromise(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - for _, tc := range []struct { - name string - grpcReq *grpcApi.ResolvePromiseRequest - req *t_api.Request - res *t_api.Response - noop bool - expectedErr codes.Code - }{ - { - name: "ResolvePromise", - grpcReq: &grpcApi.ResolvePromiseRequest{ - RequestId: "ResolvePromise", - Id: "foo", - IdempotencyKey: "bar", - Strict: true, - Value: &grpcApi.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("cancel"), - }, - }, - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "ResolvePromise", - "name": "CompletePromise", - "protocol": "grpc", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - Strict: true, - State: promise.Resolved, - Value: promise.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("cancel"), - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Resolved, - }, - }, - }, - noop: false, - }, - { - name: "ResolvePromiseMinimal", - grpcReq: &grpcApi.ResolvePromiseRequest{ - RequestId: "ResolvePromiseMinimal", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "ResolvePromiseMinimal", - "name": "CompletePromise", - "protocol": "grpc", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - State: promise.Resolved, - Value: promise.Value{ - Headers: nil, - Data: nil, - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Resolved, - }, - }, - }, - noop: false, - }, - { - name: "ResolvePromiseAlreadyRejected", - grpcReq: &grpcApi.ResolvePromiseRequest{ - RequestId: "ResolvePromiseAlreadyRejected", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "ResolvePromiseAlreadyRejected", - "name": "CompletePromise", - "protocol": "grpc", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - State: promise.Resolved, - Value: promise.Value{ - Headers: nil, - Data: nil, - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusPromiseAlreadyRejected, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Rejected, - }, - }, - }, - noop: false, - expectedErr: codes.PermissionDenied, - }, - } { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - res, err := grpcTest.promises.ResolvePromise(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.expectedErr, s.Code()) - return - } - - assert.Equal(t, tc.noop, res.Noop) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestRejectPromise(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - for _, tc := range []struct { - name string - grpcReq *grpcApi.RejectPromiseRequest - req *t_api.Request - res *t_api.Response - noop bool - expectedErr codes.Code - }{ - { - name: "RejectPromise", - grpcReq: &grpcApi.RejectPromiseRequest{ - RequestId: "RejectPromise", - Id: "foo", - IdempotencyKey: "bar", - Strict: true, - Value: &grpcApi.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("cancel"), - }, - }, - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "RejectPromise", - "name": "CompletePromise", - "protocol": "grpc", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - Strict: true, - State: promise.Rejected, - Value: promise.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("cancel"), - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Rejected, - }, - }, - }, - noop: false, - }, - { - name: "RejectPromiseMinimal", - grpcReq: &grpcApi.RejectPromiseRequest{ - RequestId: "RejectPromiseMinimal", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "RejectPromiseMinimal", - "name": "CompletePromise", - "protocol": "grpc", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - State: promise.Rejected, - Value: promise.Value{ - Headers: nil, - Data: nil, - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Rejected, - }, - }, - }, - noop: false, - }, - { - name: "RejectPromiseAlreadyResolved", - grpcReq: &grpcApi.RejectPromiseRequest{ - RequestId: "RejectPromiseAlreadyResolved", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "RejectPromiseAlreadyResolved", - "name": "CompletePromise", - "protocol": "grpc", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - State: promise.Rejected, - Value: promise.Value{ - Headers: nil, - Data: nil, - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusPromiseAlreadyResolved, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Resolved, - }, - }, - }, - noop: false, - expectedErr: codes.PermissionDenied, - }, - } { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - res, err := grpcTest.promises.RejectPromise(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.expectedErr, s.Code()) - return - } - - assert.Equal(t, tc.noop, res.Noop) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -// Callbacks - -func TestCreateCallback(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.CreateCallbackRequest - req *t_api.Request - res *t_api.Response - code codes.Code - }{ - { - name: "CreateCallback", - grpcReq: &grpcApi.CreateCallbackRequest{ - PromiseId: "foo", - RootPromiseId: "bar", - Timeout: 1, - Recv: &grpcApi.CreateCallbackRequest_Logical{Logical: "foo"}, - RequestId: "CreateCallback", - }, - req: &t_api.Request{ - Kind: t_api.CreateCallback, - Tags: map[string]string{ - "id": "CreateCallback", - "name": "CreateCallback", - "protocol": "grpc", - }, - CreateCallback: &t_api.CreateCallbackRequest{ - PromiseId: "foo", - RootPromiseId: "bar", - Timeout: 1, - Recv: []byte(`"foo"`), - }, - }, - res: &t_api.Response{ - Kind: t_api.CreateCallback, - CreateCallback: &t_api.CreateCallbackResponse{ - Status: t_api.StatusCreated, - }, - }, - code: codes.OK, - }, - { - name: "CreateCallbackPhysicalReceiver", - grpcReq: &grpcApi.CreateCallbackRequest{ - PromiseId: "foo", - RootPromiseId: "bar", - Timeout: 1, - Recv: &grpcApi.CreateCallbackRequest_Physical{Physical: &grpcApi.Recv{Type: "http", Data: []byte(`{"url": "http://localhost:3000"}`)}}, - RequestId: "CreateCallbackPhysicalReceiver", - }, - req: &t_api.Request{ - Kind: t_api.CreateCallback, - Tags: map[string]string{ - "id": "CreateCallbackPhysicalReceiver", - "name": "CreateCallback", - "protocol": "grpc", - }, - CreateCallback: &t_api.CreateCallbackRequest{ - PromiseId: "foo", - RootPromiseId: "bar", - Timeout: 1, - Recv: []byte(`{"type":"http","data":{"url":"http://localhost:3000"}}`), - }, - }, - res: &t_api.Response{ - Kind: t_api.CreateCallback, - CreateCallback: &t_api.CreateCallbackResponse{ - Status: t_api.StatusCreated, - }, - }, - code: codes.OK, - }, - { - name: "CreateCallbackNoRecv", - grpcReq: &grpcApi.CreateCallbackRequest{ - PromiseId: "foo", - RootPromiseId: "bar", - Timeout: 1, - RequestId: "CreateCallbackNoRecv", - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - { - name: "CreateCallbackInvalidPhysicalReceiver", - grpcReq: &grpcApi.CreateCallbackRequest{ - PromiseId: "foo", - RootPromiseId: "bar", - Timeout: 1, - Recv: &grpcApi.CreateCallbackRequest_Physical{Physical: &grpcApi.Recv{Type: "http", Data: []byte("nope")}}, - RequestId: "CreateCallbackInvalidPhysicalReceiver", - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - { - name: "CreateCallbackNotFound", - grpcReq: &grpcApi.CreateCallbackRequest{ - PromiseId: "foo", - Timeout: 1, - Recv: &grpcApi.CreateCallbackRequest_Logical{Logical: "foo"}, - RequestId: "CreateCallbackNotFound", - }, - req: &t_api.Request{ - Kind: t_api.CreateCallback, - Tags: map[string]string{ - "id": "CreateCallbackNotFound", - "name": "CreateCallback", - "protocol": "grpc", - }, - CreateCallback: &t_api.CreateCallbackRequest{ - PromiseId: "foo", - Timeout: 1, - Recv: []byte(`"foo"`), - }, - }, - res: &t_api.Response{ - Kind: t_api.CreateCallback, - CreateCallback: &t_api.CreateCallbackResponse{ - Status: t_api.StatusPromiseNotFound, - }, - }, - code: codes.NotFound, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.callbacks.CreateCallback(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.code, s.Code()) - return - } - - assert.Equal(t, tc.code, codes.OK) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -// Schedules - -func TestCreateSchedule(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.CreateScheduleRequest - req *t_api.Request - res *t_api.Response - noop bool - expectedErr codes.Code - }{ - { - name: "CreateSchedule", - grpcReq: &grpcApi.CreateScheduleRequest{ - RequestId: "CreateSchedule", - Id: "foo", - Description: "bar", - Cron: "* * * * *", - Tags: map[string]string{"a": "a", "b": "b", "c": "c"}, - PromiseId: "foo", - PromiseTimeout: 1, - PromiseParam: &grpcApi.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("pending"), - }, - PromiseTags: map[string]string{"a": "a", "b": "b", "c": "c"}, - IdempotencyKey: "bar", - }, - req: &t_api.Request{ - Kind: t_api.CreateSchedule, - Tags: map[string]string{ - "id": "CreateSchedule", - "name": "CreateSchedule", - "protocol": "grpc", - }, - CreateSchedule: &t_api.CreateScheduleRequest{ - Id: "foo", - Description: "bar", - Cron: "* * * * *", - Tags: map[string]string{"a": "a", "b": "b", "c": "c"}, - PromiseId: "foo", - PromiseTimeout: 1, - PromiseParam: promise.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("pending"), - }, - PromiseTags: map[string]string{"a": "a", "b": "b", "c": "c"}, - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - }, - }, - res: &t_api.Response{ - Kind: t_api.CreateSchedule, - CreateSchedule: &t_api.CreateScheduleResponse{ - Status: t_api.StatusCreated, - Schedule: &schedule.Schedule{ - Id: "foo", - Description: "bar", - }, - }, - }, - noop: false, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - res, err := grpcTest.schedules.CreateSchedule(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.expectedErr, s.Code()) - return - } - - assert.Equal(t, tc.noop, res.Noop) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestReadSchedule(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.ReadScheduleRequest - req *t_api.Request - res *t_api.Response - code codes.Code - }{ - { - name: "ReadSchedule", - grpcReq: &grpcApi.ReadScheduleRequest{ - RequestId: "ReadSchedule", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.ReadSchedule, - Tags: map[string]string{ - "id": "ReadSchedule", - "name": "ReadSchedule", - "protocol": "grpc", - }, - ReadSchedule: &t_api.ReadScheduleRequest{ - Id: "foo", - }, - }, - res: &t_api.Response{ - Kind: t_api.ReadSchedule, - ReadSchedule: &t_api.ReadScheduleResponse{ - Status: t_api.StatusOK, - Schedule: &schedule.Schedule{ - Id: "foo", - Description: "bar", - }, - }, - }, - code: codes.OK, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.schedules.ReadSchedule(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.code, s.Code()) - return - } - - assert.Equal(t, tc.code, codes.OK) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestSearchSchedule(t *testing.T) { +func TestGrpc(t *testing.T) { grpcTest, err := setup() if err != nil { t.Fatal(err) } - tcs := []struct { - name string - grpcReq *grpcApi.SearchSchedulesRequest - req *t_api.Request - res *t_api.Response - }{ - { - name: "SearchSchedules", - grpcReq: &grpcApi.SearchSchedulesRequest{ - RequestId: "SearchSchedules", - Id: "*", - Limit: 10, - }, - req: &t_api.Request{ - Kind: t_api.SearchSchedules, - Tags: map[string]string{ - "id": "SearchSchedules", - "name": "SearchSchedules", - "protocol": "grpc", - }, - SearchSchedules: &t_api.SearchSchedulesRequest{ - Id: "*", - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchSchedules, - SearchSchedules: &t_api.SearchSchedulesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Schedules: []*schedule.Schedule{}, - }, - }, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.schedules.SearchSchedules(ctx, tc.grpcReq) - if err != nil { - t.Fatal(err) + for _, tc := range test.TestCases { + t.Run(tc.Name, func(t *testing.T) { + if tc.Req != nil { + // set protocol specific header + tc.Req.Tags["protocol"] = "grpc" } - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestDeleteSchedule(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.DeleteScheduleRequest - req *t_api.Request - res *t_api.Response - code codes.Code - }{ - { - name: "DeleteSchedule", - grpcReq: &grpcApi.DeleteScheduleRequest{ - RequestId: "DeleteSchedule", - Id: "foo", - }, - req: &t_api.Request{ - Kind: t_api.DeleteSchedule, - Tags: map[string]string{ - "id": "DeleteSchedule", - "name": "DeleteSchedule", - "protocol": "grpc", - }, - DeleteSchedule: &t_api.DeleteScheduleRequest{ - Id: "foo", - }, - }, - res: &t_api.Response{ - Kind: t_api.DeleteSchedule, - DeleteSchedule: &t_api.DeleteScheduleResponse{ - Status: t_api.StatusNoContent, - }, - }, - code: codes.OK, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) + grpcTest.Load(t, tc.Req, tc.Res) ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) defer cancel() - _, err := grpcTest.schedules.DeleteSchedule(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.code, s.Code()) - return - } - - assert.Equal(t, tc.code, codes.OK) + var res protoreflect.ProtoMessage + var err error - select { - case err := <-grpcTest.errors: - t.Fatal(err) + switch req := tc.Grpc.Req.(type) { + case *pb.ReadPromiseRequest: + _, err = grpcTest.promises.ReadPromise(ctx, req) + case *pb.SearchPromisesRequest: + _, err = grpcTest.promises.SearchPromises(ctx, req) + case *pb.CreatePromiseRequest: + res, err = grpcTest.promises.CreatePromise(ctx, req) + case *pb.CreatePromiseAndTaskRequest: + res, err = grpcTest.promises.CreatePromiseAndTask(ctx, req) + case *pb.CreatePromiseAndCallbackRequest: + res, err = grpcTest.promises.CreatePromiseAndCallback(ctx, req) + case *pb.ResolvePromiseRequest: + res, err = grpcTest.promises.ResolvePromise(ctx, req) + case *pb.RejectPromiseRequest: + res, err = grpcTest.promises.RejectPromise(ctx, req) + case *pb.CancelPromiseRequest: + res, err = grpcTest.promises.CancelPromise(ctx, req) + case *pb.CreateCallbackRequest: + _, err = grpcTest.callbacks.CreateCallback(ctx, req) + case *pb.ReadScheduleRequest: + _, err = grpcTest.schedules.ReadSchedule(ctx, req) + case *pb.SearchSchedulesRequest: + _, err = grpcTest.schedules.SearchSchedules(ctx, req) + case *pb.CreateScheduleRequest: + res, err = grpcTest.schedules.CreateSchedule(ctx, req) + case *pb.DeleteScheduleRequest: + _, err = grpcTest.schedules.DeleteSchedule(ctx, req) + case *pb.AcquireLockRequest: + _, err = grpcTest.locks.AcquireLock(ctx, req) + case *pb.ReleaseLockRequest: + _, err = grpcTest.locks.ReleaseLock(ctx, req) + case *pb.HeartbeatLocksRequest: + _, err = grpcTest.locks.HeartbeatLocks(ctx, req) + case *pb.ClaimTaskRequest: + res, err = grpcTest.tasks.ClaimTask(ctx, req) + case *pb.CompleteTaskRequest: + _, err = grpcTest.tasks.CompleteTask(ctx, req) + case *pb.HeartbeatTasksRequest: + _, err = grpcTest.tasks.HeartbeatTasks(ctx, req) default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -// Locks - -func TestAcquireLock(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.AcquireLockRequest - req *t_api.Request - res *t_api.Response - code codes.Code - }{ - { - name: "AcquireLock", - grpcReq: &grpcApi.AcquireLockRequest{ - RequestId: "AcquireLock", - ResourceId: "foo", - ProcessId: "bar", - ExecutionId: "baz", - ExpiryInMilliseconds: 1, - }, - req: &t_api.Request{ - Kind: t_api.AcquireLock, - Tags: map[string]string{ - "id": "AcquireLock", - "name": "AcquireLock", - "protocol": "grpc", - }, - AcquireLock: &t_api.AcquireLockRequest{ - ResourceId: "foo", - ProcessId: "bar", - ExecutionId: "baz", - ExpiryInMilliseconds: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.AcquireLock, - AcquireLock: &t_api.AcquireLockResponse{ - Status: t_api.StatusCreated, - Lock: &lock.Lock{ - ResourceId: "foo", - ProcessId: "bar", - ExecutionId: "baz", - ExpiryInMilliseconds: 1, - }, - }, - }, - code: codes.OK, - }, - { - name: "AcquireLockNoResourceId", - grpcReq: &grpcApi.AcquireLockRequest{ - ResourceId: "", - ProcessId: "bar", - ExecutionId: "baz", - ExpiryInMilliseconds: 1, - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - { - name: "AcquireLockNoProcessId", - grpcReq: &grpcApi.AcquireLockRequest{ - ResourceId: "foo", - ProcessId: "", - ExecutionId: "baz", - ExpiryInMilliseconds: 1, - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - { - name: "AcquireLockNoExecutionId", - grpcReq: &grpcApi.AcquireLockRequest{ - ProcessId: "bar", - ExecutionId: "", - ExpiryInMilliseconds: 1, - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - { - name: "AcquireLockNoTimeout", - grpcReq: &grpcApi.AcquireLockRequest{ - ResourceId: "foo", - ProcessId: "bar", - ExecutionId: "baz", - ExpiryInMilliseconds: 0, - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.locks.AcquireLock(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.code, s.Code()) - return + t.Fatalf("unexpected type %T", req) } - assert.Equal(t, tc.code, codes.OK) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: + // assert successful response + if tc.Grpc.Res != nil { + assert.True(t, proto.Equal(tc.Grpc.Res, res), "%v\n%v", tc.Grpc.Res, res) } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} -func TestReleaseLock(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.ReleaseLockRequest - req *t_api.Request - res *t_api.Response - code codes.Code - }{ - { - name: "ReleaseLock", - grpcReq: &grpcApi.ReleaseLockRequest{ - RequestId: "ReleaseLock", - ResourceId: "foo", - ExecutionId: "bar", - }, - req: &t_api.Request{ - Kind: t_api.ReleaseLock, - Tags: map[string]string{ - "id": "ReleaseLock", - "name": "ReleaseLock", - "protocol": "grpc", - }, - ReleaseLock: &t_api.ReleaseLockRequest{ - ResourceId: "foo", - ExecutionId: "bar", - }, - }, - res: &t_api.Response{ - Kind: t_api.ReleaseLock, - ReleaseLock: &t_api.ReleaseLockResponse{ - Status: t_api.StatusOK, - }, - }, - }, - { - name: "ReleaseLockNoResourceId", - grpcReq: &grpcApi.ReleaseLockRequest{ - ResourceId: "", - ExecutionId: "bar", - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - { - name: "ReleaseLockNoExecutionId", - grpcReq: &grpcApi.ReleaseLockRequest{ - ResourceId: "foo", - ExecutionId: "", - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.locks.ReleaseLock(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.code, s.Code()) - return - } - - assert.Equal(t, tc.code, codes.OK) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestHeartbeatLocks(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.HeartbeatLocksRequest - req *t_api.Request - res *t_api.Response - code codes.Code - }{ - { - name: "HeartbeatLocks", - grpcReq: &grpcApi.HeartbeatLocksRequest{ - RequestId: "HeartbeatLocks", - ProcessId: "foo", - }, - req: &t_api.Request{ - Kind: t_api.HeartbeatLocks, - Tags: map[string]string{ - "id": "HeartbeatLocks", - "name": "HeartbeatLocks", - "protocol": "grpc", - }, - HeartbeatLocks: &t_api.HeartbeatLocksRequest{ - ProcessId: "foo", - }, - }, - res: &t_api.Response{ - Kind: t_api.HeartbeatLocks, - HeartbeatLocks: &t_api.HeartbeatLocksResponse{ - Status: t_api.StatusOK, - }, - }, - code: codes.OK, - }, - { - name: "HeartbeatLocksNoProcessId", - grpcReq: &grpcApi.HeartbeatLocksRequest{ - ProcessId: "", - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.locks.HeartbeatLocks(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.code, s.Code()) - return - } - - assert.Equal(t, tc.code, codes.OK) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -// Tasks - -func TestClaimTask(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.ClaimTaskRequest - grpcRes *grpcApi.ClaimTaskResponse - req *t_api.Request - res *t_api.Response - code codes.Code - }{ - { - name: "ClaimTask", - grpcReq: &grpcApi.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 0, - Frequency: 1, - RequestId: "ClaimTask", - }, - req: &t_api.Request{ - Kind: t_api.ClaimTask, - Tags: map[string]string{ - "id": "ClaimTask", - "name": "ClaimTask", - "protocol": "grpc", - }, - ClaimTask: &t_api.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 0, - Frequency: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.ClaimTask, - ClaimTask: &t_api.ClaimTaskResponse{ - Status: t_api.StatusCreated, - Mesg: &message.Mesg{}, - }, - }, - code: codes.OK, - }, - { - name: "ClaimTaskInvoke", - grpcReq: &grpcApi.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 1, - Frequency: 1, - RequestId: "ClaimTaskInvoke", - }, - grpcRes: &grpcApi.ClaimTaskResponse{ - Type: "resume", - Promises: map[string]*grpcApi.Promise{ - "root": {Id: "foo", State: grpcApi.State_PENDING, Param: &grpcApi.Value{}, Value: &grpcApi.Value{}}, - }, - }, - req: &t_api.Request{ - Kind: t_api.ClaimTask, - Tags: map[string]string{ - "id": "ClaimTaskInvoke", - "name": "ClaimTask", - "protocol": "grpc", - }, - ClaimTask: &t_api.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 1, - Frequency: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.ClaimTask, - ClaimTask: &t_api.ClaimTaskResponse{ - Status: t_api.StatusCreated, - Mesg: &message.Mesg{ - Type: message.Resume, - Promises: map[string]*promise.Promise{ - "root": {Id: "foo", State: promise.Pending}, - }, - }, - }, - }, - code: codes.OK, - }, - { - name: "ClaimTaskResume", - grpcReq: &grpcApi.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 2, - Frequency: 1, - RequestId: "ClaimTaskResume", - }, - grpcRes: &grpcApi.ClaimTaskResponse{ - Type: "resume", - Promises: map[string]*grpcApi.Promise{ - "root": {Id: "foo", State: grpcApi.State_PENDING, Param: &grpcApi.Value{}, Value: &grpcApi.Value{}}, - "leaf": {Id: "bar", State: grpcApi.State_RESOLVED, Param: &grpcApi.Value{}, Value: &grpcApi.Value{}}, - }, - }, - req: &t_api.Request{ - Kind: t_api.ClaimTask, - Tags: map[string]string{ - "id": "ClaimTaskResume", - "name": "ClaimTask", - "protocol": "grpc", - }, - ClaimTask: &t_api.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 2, - Frequency: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.ClaimTask, - ClaimTask: &t_api.ClaimTaskResponse{ - Status: t_api.StatusCreated, - Mesg: &message.Mesg{ - Type: message.Resume, - Promises: map[string]*promise.Promise{ - "root": {Id: "foo", State: promise.Pending}, - "leaf": {Id: "bar", State: promise.Resolved}, - }, - }, - }, - }, - code: codes.OK, - }, - { - name: "ClaimTaskNoId", - grpcReq: &grpcApi.ClaimTaskRequest{ - ProcessId: "bar", - Counter: 0, - Frequency: 1, - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - { - name: "ClaimTaskNoProcessId", - grpcReq: &grpcApi.ClaimTaskRequest{ - Id: "foo", - Counter: 0, - Frequency: 1, - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - { - name: "ClaimTaskNoFrequency", - grpcReq: &grpcApi.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 0, - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - res, err := grpcTest.tasks.ClaimTask(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.code, s.Code()) - return - } - - assert.Equal(t, tc.code, codes.OK) - - if tc.grpcRes != nil { - assert.Equal(t, tc.grpcRes.Type, res.Type) - assert.Equal(t, tc.grpcRes.Promises, res.Promises) - } - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: - } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestCompleteTask(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.CompleteTaskRequest - req *t_api.Request - res *t_api.Response - code codes.Code - }{ - { - name: "CompleteTask", - grpcReq: &grpcApi.CompleteTaskRequest{ - Id: "foo", - Counter: 0, - RequestId: "CompleteTask", - }, - req: &t_api.Request{ - Kind: t_api.CompleteTask, - Tags: map[string]string{ - "id": "CompleteTask", - "name": "CompleteTask", - "protocol": "grpc", - }, - CompleteTask: &t_api.CompleteTaskRequest{ - Id: "foo", - Counter: 0, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompleteTask, - CompleteTask: &t_api.CompleteTaskResponse{ - Status: t_api.StatusCreated, - }, - }, - code: codes.OK, - }, - { - name: "CompleteTaskNoId", - grpcReq: &grpcApi.CompleteTaskRequest{ - Counter: 0, - }, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.tasks.CompleteTask(ctx, tc.grpcReq) + // assert error response if err != nil { + // actual grpc error s, ok := status.FromError(err) if !ok { t.Fatal(err) } - assert.Equal(t, tc.code, s.Code()) - return - } - assert.Equal(t, tc.code, codes.OK) - - select { - case err := <-grpcTest.errors: - t.Fatal(err) - default: + assert.Equal(t, tc.Grpc.Code, s.Code(), "%s != %s", tc.Grpc.Code, s.Code()) } - }) - } - - if err := grpcTest.teardown(); err != nil { - t.Fatal(err) - } -} - -func TestHeartbeatTasks(t *testing.T) { - grpcTest, err := setup() - if err != nil { - t.Fatal(err) - } - - tcs := []struct { - name string - grpcReq *grpcApi.HeartbeatTasksRequest - req *t_api.Request - res *t_api.Response - code codes.Code - }{ - { - name: "HeartbeatTasks", - grpcReq: &grpcApi.HeartbeatTasksRequest{ - ProcessId: "bar", - RequestId: "HeartbeatTasks", - }, - req: &t_api.Request{ - Kind: t_api.HeartbeatTasks, - Tags: map[string]string{ - "id": "HeartbeatTasks", - "name": "HeartbeatTasks", - "protocol": "grpc", - }, - HeartbeatTasks: &t_api.HeartbeatTasksRequest{ - ProcessId: "bar", - }, - }, - res: &t_api.Response{ - Kind: t_api.HeartbeatTasks, - HeartbeatTasks: &t_api.HeartbeatTasksResponse{ - Status: t_api.StatusOK, - TasksAffected: 1, - }, - }, - code: codes.OK, - }, - { - name: "HeartbeatTasksNoProcessId", - grpcReq: &grpcApi.HeartbeatTasksRequest{}, - req: nil, - res: nil, - code: codes.InvalidArgument, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - grpcTest.Load(t, tc.req, tc.res) - - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) - defer cancel() - - _, err := grpcTest.tasks.HeartbeatTasks(ctx, tc.grpcReq) - if err != nil { - s, ok := status.FromError(err) - if !ok { - t.Fatal(err) - } - assert.Equal(t, tc.code, s.Code()) - return - } - - assert.Equal(t, tc.code, codes.OK) select { case err := <-grpcTest.errors: diff --git a/internal/app/subsystems/api/grpc/lock.go b/internal/app/subsystems/api/grpc/lock.go index bba7b134..280f9bed 100644 --- a/internal/app/subsystems/api/grpc/lock.go +++ b/internal/app/subsystems/api/grpc/lock.go @@ -3,105 +3,63 @@ package grpc import ( "context" - grpcApi "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" - "github.com/resonatehq/resonate/pkg/lock" - "google.golang.org/grpc/codes" - grpcStatus "google.golang.org/grpc/status" + "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb" + "github.com/resonatehq/resonate/internal/kernel/t_api" + "github.com/resonatehq/resonate/internal/util" + "google.golang.org/grpc/status" ) -func (s *server) AcquireLock(ctx context.Context, req *grpcApi.AcquireLockRequest) (*grpcApi.AcquireLockResponse, error) { - header := &service.Header{ - RequestId: req.RequestId, - } - - if req.ResourceId == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "lock.resource_id must be provided") - } - if req.ExecutionId == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "lock.execution_id must be provided") - } - if req.ProcessId == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "lock.process_id must be provided") - } - if req.ExpiryInMilliseconds == 0 { - return nil, grpcStatus.Error(codes.InvalidArgument, "lock.expiry_in_milliseconds must be provided") - } - - body := &service.AcquireLockBody{ - ResourceId: req.ResourceId, - ExecutionId: req.ExecutionId, - ProcessId: req.ProcessId, - ExpiryInMilliseconds: req.ExpiryInMilliseconds, - } - - res, err := s.service.AcquireLock(header, body) +func (s *server) AcquireLock(c context.Context, r *pb.AcquireLockRequest) (*pb.AcquireLockResponse, error) { + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.AcquireLock, + AcquireLock: &t_api.AcquireLockRequest{ + ResourceId: r.ResourceId, + ExecutionId: r.ExecutionId, + ProcessId: r.ProcessId, + ExpiryInMilliseconds: r.ExpiryInMilliseconds, + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.AcquireLockResponse{ - Lock: protoLock(res.Lock), + util.Assert(res.AcquireLock != nil, "result must not be nil") + return &pb.AcquireLockResponse{ + Acquired: res.AcquireLock.Status == t_api.StatusCreated, }, nil } -func (s *server) ReleaseLock(ctx context.Context, req *grpcApi.ReleaseLockRequest) (*grpcApi.ReleaseLockResponse, error) { - header := &service.Header{ - RequestId: req.RequestId, - } - - if req.ResourceId == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "resource_id must be provided") - } - if req.ExecutionId == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "execution_id must be provided") - } - - body := &service.ReleaseLockBody{ - ResourceId: req.ResourceId, - ExecutionId: req.ExecutionId, - } - - _, err := s.service.ReleaseLock(header, body) +func (s *server) ReleaseLock(c context.Context, r *pb.ReleaseLockRequest) (*pb.ReleaseLockResponse, error) { + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.ReleaseLock, + ReleaseLock: &t_api.ReleaseLockRequest{ + ResourceId: r.ResourceId, + ExecutionId: r.ExecutionId, + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.ReleaseLockResponse{}, nil + util.Assert(res.ReleaseLock != nil, "result must not be nil") + return &pb.ReleaseLockResponse{ + Released: res.ReleaseLock.Status == t_api.StatusCreated, + }, nil } -func (s *server) HeartbeatLocks(ctx context.Context, req *grpcApi.HeartbeatLocksRequest) (*grpcApi.HeartbeatLocksResponse, error) { - header := &service.Header{ - RequestId: req.RequestId, - } - - if req.ProcessId == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "process_id must be provided") - } - - body := &service.HeartbeatBody{ - ProcessId: req.ProcessId, - } - - res, err := s.service.Heartbeat(header, body) +func (s *server) HeartbeatLocks(c context.Context, r *pb.HeartbeatLocksRequest) (*pb.HeartbeatLocksResponse, error) { + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.HeartbeatLocks, + HeartbeatLocks: &t_api.HeartbeatLocksRequest{ + ProcessId: r.ProcessId, + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.HeartbeatLocksResponse{ - LocksAffected: int32(res.LocksAffected), + util.Assert(res.HeartbeatLocks != nil, "result must not be nil") + return &pb.HeartbeatLocksResponse{ + LocksAffected: int32(res.HeartbeatLocks.LocksAffected), }, nil } - -func protoLock(lock *lock.Lock) *grpcApi.Lock { - if lock == nil { - return nil - } - - return &grpcApi.Lock{ - ResourceId: lock.ResourceId, - ExecutionId: lock.ExecutionId, - ProcessId: lock.ProcessId, - ExpiryInMilliseconds: lock.ExpiryInMilliseconds, - } -} diff --git a/internal/app/subsystems/api/grpc/pb/callback.pb.go b/internal/app/subsystems/api/grpc/pb/callback.pb.go new file mode 100644 index 00000000..aa49c80e --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/callback.pb.go @@ -0,0 +1,297 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.3 +// source: internal/app/subsystems/api/grpc/pb/callback.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type CreateCallbackRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PromiseId string `protobuf:"bytes,1,opt,name=promiseId,proto3" json:"promiseId,omitempty"` + RootPromiseId string `protobuf:"bytes,2,opt,name=rootPromiseId,proto3" json:"rootPromiseId,omitempty"` + Timeout int64 `protobuf:"varint,3,opt,name=timeout,proto3" json:"timeout,omitempty"` + Recv *Recv `protobuf:"bytes,4,opt,name=recv,proto3" json:"recv,omitempty"` + RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *CreateCallbackRequest) Reset() { + *x = CreateCallbackRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateCallbackRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateCallbackRequest) ProtoMessage() {} + +func (x *CreateCallbackRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateCallbackRequest.ProtoReflect.Descriptor instead. +func (*CreateCallbackRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateCallbackRequest) GetPromiseId() string { + if x != nil { + return x.PromiseId + } + return "" +} + +func (x *CreateCallbackRequest) GetRootPromiseId() string { + if x != nil { + return x.RootPromiseId + } + return "" +} + +func (x *CreateCallbackRequest) GetTimeout() int64 { + if x != nil { + return x.Timeout + } + return 0 +} + +func (x *CreateCallbackRequest) GetRecv() *Recv { + if x != nil { + return x.Recv + } + return nil +} + +func (x *CreateCallbackRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type CreateCallbackResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` + Callback *Callback `protobuf:"bytes,2,opt,name=callback,proto3" json:"callback,omitempty"` + Promise *Promise `protobuf:"bytes,3,opt,name=promise,proto3" json:"promise,omitempty"` +} + +func (x *CreateCallbackResponse) Reset() { + *x = CreateCallbackResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateCallbackResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateCallbackResponse) ProtoMessage() {} + +func (x *CreateCallbackResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateCallbackResponse.ProtoReflect.Descriptor instead. +func (*CreateCallbackResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateCallbackResponse) GetNoop() bool { + if x != nil { + return x.Noop + } + return false +} + +func (x *CreateCallbackResponse) GetCallback() *Callback { + if x != nil { + return x.Callback + } + return nil +} + +func (x *CreateCallbackResponse) GetPromise() *Promise { + if x != nil { + return x.Promise + } + return nil +} + +var File_internal_app_subsystems_api_grpc_pb_callback_proto protoreflect.FileDescriptor + +var file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDesc = []byte{ + 0x0a, 0x32, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x1a, 0x34, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, + 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, + 0x2f, 0x70, 0x62, 0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x33, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, + 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x5f, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb9, 0x01, 0x0a, 0x15, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, + 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x6f, 0x6f, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x6f, 0x6f, 0x74, 0x50, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, + 0x74, 0x12, 0x24, 0x0a, 0x04, 0x72, 0x65, 0x63, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x10, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x2e, 0x52, 0x65, 0x63, + 0x76, 0x52, 0x04, 0x72, 0x65, 0x63, 0x76, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x8c, 0x01, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, + 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x30, 0x0a, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x5f, 0x74, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x08, 0x63, 0x61, + 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x5f, 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x32, 0x62, 0x0a, 0x09, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x73, 0x12, 0x55, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x6c, 0x6c, 0x62, + 0x61, 0x63, 0x6b, 0x12, 0x1f, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, + 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDescOnce sync.Once + file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDescData = file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDesc +) + +func file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDescGZIP() []byte { + file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDescOnce.Do(func() { + file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDescData) + }) + return file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDescData +} + +var file_internal_app_subsystems_api_grpc_pb_callback_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_internal_app_subsystems_api_grpc_pb_callback_proto_goTypes = []interface{}{ + (*CreateCallbackRequest)(nil), // 0: callback.CreateCallbackRequest + (*CreateCallbackResponse)(nil), // 1: callback.CreateCallbackResponse + (*Recv)(nil), // 2: callback_t.Recv + (*Callback)(nil), // 3: callback_t.Callback + (*Promise)(nil), // 4: promise_t.Promise +} +var file_internal_app_subsystems_api_grpc_pb_callback_proto_depIdxs = []int32{ + 2, // 0: callback.CreateCallbackRequest.recv:type_name -> callback_t.Recv + 3, // 1: callback.CreateCallbackResponse.callback:type_name -> callback_t.Callback + 4, // 2: callback.CreateCallbackResponse.promise:type_name -> promise_t.Promise + 0, // 3: callback.Callbacks.CreateCallback:input_type -> callback.CreateCallbackRequest + 1, // 4: callback.Callbacks.CreateCallback:output_type -> callback.CreateCallbackResponse + 4, // [4:5] is the sub-list for method output_type + 3, // [3:4] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_internal_app_subsystems_api_grpc_pb_callback_proto_init() } +func file_internal_app_subsystems_api_grpc_pb_callback_proto_init() { + if File_internal_app_subsystems_api_grpc_pb_callback_proto != nil { + return + } + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_init() + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_init() + if !protoimpl.UnsafeEnabled { + file_internal_app_subsystems_api_grpc_pb_callback_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateCallbackRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_callback_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateCallbackResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_internal_app_subsystems_api_grpc_pb_callback_proto_goTypes, + DependencyIndexes: file_internal_app_subsystems_api_grpc_pb_callback_proto_depIdxs, + MessageInfos: file_internal_app_subsystems_api_grpc_pb_callback_proto_msgTypes, + }.Build() + File_internal_app_subsystems_api_grpc_pb_callback_proto = out.File + file_internal_app_subsystems_api_grpc_pb_callback_proto_rawDesc = nil + file_internal_app_subsystems_api_grpc_pb_callback_proto_goTypes = nil + file_internal_app_subsystems_api_grpc_pb_callback_proto_depIdxs = nil +} diff --git a/internal/app/subsystems/api/grpc/pb/callback.proto b/internal/app/subsystems/api/grpc/pb/callback.proto new file mode 100644 index 00000000..50debd31 --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/callback.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +package callback; + +import "internal/app/subsystems/api/grpc/pb/callback_t.proto"; +import "internal/app/subsystems/api/grpc/pb/promise_t.proto"; + +option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb"; + +service Callbacks { + rpc CreateCallback (CreateCallbackRequest) returns (CreateCallbackResponse) {} +} + +message CreateCallbackRequest { + string promiseId = 1; + string rootPromiseId = 2; + int64 timeout = 3; + callback_t.Recv recv = 4; + string requestId = 5; +} + +message CreateCallbackResponse { + bool noop = 1; + callback_t.Callback callback = 2; + promise_t.Promise promise = 3; +} diff --git a/internal/app/subsystems/api/grpc/api/callback_grpc.pb.go b/internal/app/subsystems/api/grpc/pb/callback_grpc.pb.go similarity index 96% rename from internal/app/subsystems/api/grpc/api/callback_grpc.pb.go rename to internal/app/subsystems/api/grpc/pb/callback_grpc.pb.go index 383c1840..a8c5ae8f 100644 --- a/internal/app/subsystems/api/grpc/api/callback_grpc.pb.go +++ b/internal/app/subsystems/api/grpc/pb/callback_grpc.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-grpc v1.3.0 // - protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/callback.proto +// source: internal/app/subsystems/api/grpc/pb/callback.proto -package api +package pb import ( context "context" @@ -105,5 +105,5 @@ var Callbacks_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "internal/app/subsystems/api/grpc/api/callback.proto", + Metadata: "internal/app/subsystems/api/grpc/pb/callback.proto", } diff --git a/internal/app/subsystems/api/grpc/pb/callback_t.pb.go b/internal/app/subsystems/api/grpc/pb/callback_t.pb.go new file mode 100644 index 00000000..d2a90206 --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/callback_t.pb.go @@ -0,0 +1,353 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.3 +// source: internal/app/subsystems/api/grpc/pb/callback_t.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Callback struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + PromiseId string `protobuf:"bytes,2,opt,name=promiseId,proto3" json:"promiseId,omitempty"` + Timeout int64 `protobuf:"varint,3,opt,name=timeout,proto3" json:"timeout,omitempty"` + CreatedOn int64 `protobuf:"varint,4,opt,name=createdOn,proto3" json:"createdOn,omitempty"` +} + +func (x *Callback) Reset() { + *x = Callback{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Callback) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Callback) ProtoMessage() {} + +func (x *Callback) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Callback.ProtoReflect.Descriptor instead. +func (*Callback) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescGZIP(), []int{0} +} + +func (x *Callback) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Callback) GetPromiseId() string { + if x != nil { + return x.PromiseId + } + return "" +} + +func (x *Callback) GetTimeout() int64 { + if x != nil { + return x.Timeout + } + return 0 +} + +func (x *Callback) GetCreatedOn() int64 { + if x != nil { + return x.CreatedOn + } + return 0 +} + +type Recv struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Recv: + // + // *Recv_Logical + // *Recv_Physical + Recv isRecv_Recv `protobuf_oneof:"recv"` +} + +func (x *Recv) Reset() { + *x = Recv{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Recv) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Recv) ProtoMessage() {} + +func (x *Recv) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Recv.ProtoReflect.Descriptor instead. +func (*Recv) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescGZIP(), []int{1} +} + +func (m *Recv) GetRecv() isRecv_Recv { + if m != nil { + return m.Recv + } + return nil +} + +func (x *Recv) GetLogical() string { + if x, ok := x.GetRecv().(*Recv_Logical); ok { + return x.Logical + } + return "" +} + +func (x *Recv) GetPhysical() *PhysicalRecv { + if x, ok := x.GetRecv().(*Recv_Physical); ok { + return x.Physical + } + return nil +} + +type isRecv_Recv interface { + isRecv_Recv() +} + +type Recv_Logical struct { + Logical string `protobuf:"bytes,1,opt,name=logical,proto3,oneof"` +} + +type Recv_Physical struct { + Physical *PhysicalRecv `protobuf:"bytes,2,opt,name=physical,proto3,oneof"` +} + +func (*Recv_Logical) isRecv_Recv() {} + +func (*Recv_Physical) isRecv_Recv() {} + +type PhysicalRecv struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *PhysicalRecv) Reset() { + *x = PhysicalRecv{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PhysicalRecv) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PhysicalRecv) ProtoMessage() {} + +func (x *PhysicalRecv) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PhysicalRecv.ProtoReflect.Descriptor instead. +func (*PhysicalRecv) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescGZIP(), []int{2} +} + +func (x *PhysicalRecv) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *PhysicalRecv) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +var File_internal_app_subsystems_api_grpc_pb_callback_t_proto protoreflect.FileDescriptor + +var file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDesc = []byte{ + 0x0a, 0x34, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x74, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x5f, 0x74, 0x22, 0x70, 0x0a, 0x08, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, + 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x64, 0x4f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x4f, 0x6e, 0x22, 0x62, 0x0a, 0x04, 0x52, 0x65, 0x63, 0x76, 0x12, 0x1a, 0x0a, 0x07, + 0x6c, 0x6f, 0x67, 0x69, 0x63, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, + 0x07, 0x6c, 0x6f, 0x67, 0x69, 0x63, 0x61, 0x6c, 0x12, 0x36, 0x0a, 0x08, 0x70, 0x68, 0x79, 0x73, + 0x69, 0x63, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x61, 0x6c, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x2e, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, + 0x52, 0x65, 0x63, 0x76, 0x48, 0x00, 0x52, 0x08, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, + 0x42, 0x06, 0x0a, 0x04, 0x72, 0x65, 0x63, 0x76, 0x22, 0x36, 0x0a, 0x0c, 0x50, 0x68, 0x79, 0x73, + 0x69, 0x63, 0x61, 0x6c, 0x52, 0x65, 0x63, 0x76, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, + 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, + 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, + 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, + 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescOnce sync.Once + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescData = file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDesc +) + +func file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescGZIP() []byte { + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescOnce.Do(func() { + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescData) + }) + return file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDescData +} + +var file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_internal_app_subsystems_api_grpc_pb_callback_t_proto_goTypes = []interface{}{ + (*Callback)(nil), // 0: callback_t.Callback + (*Recv)(nil), // 1: callback_t.Recv + (*PhysicalRecv)(nil), // 2: callback_t.PhysicalRecv +} +var file_internal_app_subsystems_api_grpc_pb_callback_t_proto_depIdxs = []int32{ + 2, // 0: callback_t.Recv.physical:type_name -> callback_t.PhysicalRecv + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_internal_app_subsystems_api_grpc_pb_callback_t_proto_init() } +func file_internal_app_subsystems_api_grpc_pb_callback_t_proto_init() { + if File_internal_app_subsystems_api_grpc_pb_callback_t_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Callback); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Recv); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PhysicalRecv); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes[1].OneofWrappers = []interface{}{ + (*Recv_Logical)(nil), + (*Recv_Physical)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_internal_app_subsystems_api_grpc_pb_callback_t_proto_goTypes, + DependencyIndexes: file_internal_app_subsystems_api_grpc_pb_callback_t_proto_depIdxs, + MessageInfos: file_internal_app_subsystems_api_grpc_pb_callback_t_proto_msgTypes, + }.Build() + File_internal_app_subsystems_api_grpc_pb_callback_t_proto = out.File + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_rawDesc = nil + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_goTypes = nil + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_depIdxs = nil +} diff --git a/internal/app/subsystems/api/grpc/pb/callback_t.proto b/internal/app/subsystems/api/grpc/pb/callback_t.proto new file mode 100644 index 00000000..7732846c --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/callback_t.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package callback_t; + +option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb"; + +message Callback { + string id = 1; + string promiseId = 2; + int64 timeout = 3; + int64 createdOn = 4; +} + +message Recv { + oneof recv { + string logical = 1; + PhysicalRecv physical = 2; + } +} + +message PhysicalRecv { + string type = 1; + bytes data = 2; +} diff --git a/internal/app/subsystems/api/grpc/pb/lock.pb.go b/internal/app/subsystems/api/grpc/pb/lock.pb.go new file mode 100644 index 00000000..a2989d82 --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/lock.pb.go @@ -0,0 +1,557 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.3 +// source: internal/app/subsystems/api/grpc/pb/lock.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AcquireLockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ResourceId string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` + ExecutionId string `protobuf:"bytes,2,opt,name=execution_id,json=executionId,proto3" json:"execution_id,omitempty"` + ProcessId string `protobuf:"bytes,3,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"` + ExpiryInMilliseconds int64 `protobuf:"varint,4,opt,name=expiry_in_milliseconds,json=expiryInMilliseconds,proto3" json:"expiry_in_milliseconds,omitempty"` + RequestId string `protobuf:"bytes,5,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (x *AcquireLockRequest) Reset() { + *x = AcquireLockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AcquireLockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AcquireLockRequest) ProtoMessage() {} + +func (x *AcquireLockRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AcquireLockRequest.ProtoReflect.Descriptor instead. +func (*AcquireLockRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescGZIP(), []int{0} +} + +func (x *AcquireLockRequest) GetResourceId() string { + if x != nil { + return x.ResourceId + } + return "" +} + +func (x *AcquireLockRequest) GetExecutionId() string { + if x != nil { + return x.ExecutionId + } + return "" +} + +func (x *AcquireLockRequest) GetProcessId() string { + if x != nil { + return x.ProcessId + } + return "" +} + +func (x *AcquireLockRequest) GetExpiryInMilliseconds() int64 { + if x != nil { + return x.ExpiryInMilliseconds + } + return 0 +} + +func (x *AcquireLockRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type AcquireLockResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Acquired bool `protobuf:"varint,1,opt,name=acquired,proto3" json:"acquired,omitempty"` +} + +func (x *AcquireLockResponse) Reset() { + *x = AcquireLockResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AcquireLockResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AcquireLockResponse) ProtoMessage() {} + +func (x *AcquireLockResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AcquireLockResponse.ProtoReflect.Descriptor instead. +func (*AcquireLockResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescGZIP(), []int{1} +} + +func (x *AcquireLockResponse) GetAcquired() bool { + if x != nil { + return x.Acquired + } + return false +} + +type ReleaseLockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ResourceId string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` + ExecutionId string `protobuf:"bytes,2,opt,name=execution_id,json=executionId,proto3" json:"execution_id,omitempty"` + RequestId string `protobuf:"bytes,3,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (x *ReleaseLockRequest) Reset() { + *x = ReleaseLockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReleaseLockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReleaseLockRequest) ProtoMessage() {} + +func (x *ReleaseLockRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReleaseLockRequest.ProtoReflect.Descriptor instead. +func (*ReleaseLockRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescGZIP(), []int{2} +} + +func (x *ReleaseLockRequest) GetResourceId() string { + if x != nil { + return x.ResourceId + } + return "" +} + +func (x *ReleaseLockRequest) GetExecutionId() string { + if x != nil { + return x.ExecutionId + } + return "" +} + +func (x *ReleaseLockRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type ReleaseLockResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Released bool `protobuf:"varint,1,opt,name=released,proto3" json:"released,omitempty"` +} + +func (x *ReleaseLockResponse) Reset() { + *x = ReleaseLockResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReleaseLockResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReleaseLockResponse) ProtoMessage() {} + +func (x *ReleaseLockResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReleaseLockResponse.ProtoReflect.Descriptor instead. +func (*ReleaseLockResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescGZIP(), []int{3} +} + +func (x *ReleaseLockResponse) GetReleased() bool { + if x != nil { + return x.Released + } + return false +} + +type HeartbeatLocksRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProcessId string `protobuf:"bytes,1,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"` + RequestId string `protobuf:"bytes,2,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` +} + +func (x *HeartbeatLocksRequest) Reset() { + *x = HeartbeatLocksRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeartbeatLocksRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeartbeatLocksRequest) ProtoMessage() {} + +func (x *HeartbeatLocksRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HeartbeatLocksRequest.ProtoReflect.Descriptor instead. +func (*HeartbeatLocksRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescGZIP(), []int{4} +} + +func (x *HeartbeatLocksRequest) GetProcessId() string { + if x != nil { + return x.ProcessId + } + return "" +} + +func (x *HeartbeatLocksRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type HeartbeatLocksResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LocksAffected int32 `protobuf:"varint,1,opt,name=locksAffected,proto3" json:"locksAffected,omitempty"` +} + +func (x *HeartbeatLocksResponse) Reset() { + *x = HeartbeatLocksResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeartbeatLocksResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeartbeatLocksResponse) ProtoMessage() {} + +func (x *HeartbeatLocksResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HeartbeatLocksResponse.ProtoReflect.Descriptor instead. +func (*HeartbeatLocksResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescGZIP(), []int{5} +} + +func (x *HeartbeatLocksResponse) GetLocksAffected() int32 { + if x != nil { + return x.LocksAffected + } + return 0 +} + +var File_internal_app_subsystems_api_grpc_pb_lock_proto protoreflect.FileDescriptor + +var file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDesc = []byte{ + 0x0a, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x04, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0xcc, 0x01, 0x0a, 0x12, 0x41, 0x63, 0x71, 0x75, 0x69, + 0x72, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, + 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x21, + 0x0a, 0x0c, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x49, + 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, + 0x12, 0x34, 0x0a, 0x16, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, 0x69, 0x6e, 0x5f, 0x6d, 0x69, + 0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x14, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x49, 0x6e, 0x4d, 0x69, 0x6c, 0x6c, 0x69, 0x73, + 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x31, 0x0a, 0x13, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, + 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x61, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, + 0x61, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x77, 0x0a, 0x12, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, + 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, + 0x21, 0x0a, 0x0c, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, + 0x64, 0x22, 0x31, 0x0a, 0x13, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x6f, 0x63, 0x6b, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x64, 0x22, 0x55, 0x0a, 0x15, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, + 0x74, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, + 0x0a, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x3e, 0x0a, 0x16, 0x48, + 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x41, 0x66, + 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6c, 0x6f, + 0x63, 0x6b, 0x73, 0x41, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x32, 0xe2, 0x01, 0x0a, 0x05, + 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x12, 0x44, 0x0a, 0x0b, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, + 0x4c, 0x6f, 0x63, 0x6b, 0x12, 0x18, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x41, 0x63, 0x71, 0x75, + 0x69, 0x72, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, + 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4c, 0x6f, 0x63, + 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0b, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x12, 0x18, 0x2e, 0x6c, 0x6f, 0x63, + 0x6b, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x4d, 0x0a, 0x0e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x4c, 0x6f, + 0x63, 0x6b, 0x73, 0x12, 0x1b, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, + 0x62, 0x65, 0x61, 0x74, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1c, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, + 0x74, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, + 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, + 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, + 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, + 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescOnce sync.Once + file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescData = file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDesc +) + +func file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescGZIP() []byte { + file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescOnce.Do(func() { + file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescData) + }) + return file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDescData +} + +var file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_internal_app_subsystems_api_grpc_pb_lock_proto_goTypes = []interface{}{ + (*AcquireLockRequest)(nil), // 0: lock.AcquireLockRequest + (*AcquireLockResponse)(nil), // 1: lock.AcquireLockResponse + (*ReleaseLockRequest)(nil), // 2: lock.ReleaseLockRequest + (*ReleaseLockResponse)(nil), // 3: lock.ReleaseLockResponse + (*HeartbeatLocksRequest)(nil), // 4: lock.HeartbeatLocksRequest + (*HeartbeatLocksResponse)(nil), // 5: lock.HeartbeatLocksResponse +} +var file_internal_app_subsystems_api_grpc_pb_lock_proto_depIdxs = []int32{ + 0, // 0: lock.Locks.AcquireLock:input_type -> lock.AcquireLockRequest + 2, // 1: lock.Locks.ReleaseLock:input_type -> lock.ReleaseLockRequest + 4, // 2: lock.Locks.HeartbeatLocks:input_type -> lock.HeartbeatLocksRequest + 1, // 3: lock.Locks.AcquireLock:output_type -> lock.AcquireLockResponse + 3, // 4: lock.Locks.ReleaseLock:output_type -> lock.ReleaseLockResponse + 5, // 5: lock.Locks.HeartbeatLocks:output_type -> lock.HeartbeatLocksResponse + 3, // [3:6] is the sub-list for method output_type + 0, // [0:3] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_internal_app_subsystems_api_grpc_pb_lock_proto_init() } +func file_internal_app_subsystems_api_grpc_pb_lock_proto_init() { + if File_internal_app_subsystems_api_grpc_pb_lock_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AcquireLockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AcquireLockResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReleaseLockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReleaseLockResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeartbeatLocksRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeartbeatLocksResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_internal_app_subsystems_api_grpc_pb_lock_proto_goTypes, + DependencyIndexes: file_internal_app_subsystems_api_grpc_pb_lock_proto_depIdxs, + MessageInfos: file_internal_app_subsystems_api_grpc_pb_lock_proto_msgTypes, + }.Build() + File_internal_app_subsystems_api_grpc_pb_lock_proto = out.File + file_internal_app_subsystems_api_grpc_pb_lock_proto_rawDesc = nil + file_internal_app_subsystems_api_grpc_pb_lock_proto_goTypes = nil + file_internal_app_subsystems_api_grpc_pb_lock_proto_depIdxs = nil +} diff --git a/internal/app/subsystems/api/grpc/api/lock.proto b/internal/app/subsystems/api/grpc/pb/lock.proto similarity index 77% rename from internal/app/subsystems/api/grpc/api/lock.proto rename to internal/app/subsystems/api/grpc/pb/lock.proto index 3a311556..658a8010 100644 --- a/internal/app/subsystems/api/grpc/api/lock.proto +++ b/internal/app/subsystems/api/grpc/pb/lock.proto @@ -2,32 +2,34 @@ syntax = "proto3"; package lock; -option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api"; +option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb"; service Locks { rpc AcquireLock (AcquireLockRequest) returns (AcquireLockResponse) {} - rpc HeartbeatLocks (HeartbeatLocksRequest) returns (HeartbeatLocksResponse) {} rpc ReleaseLock (ReleaseLockRequest) returns (ReleaseLockResponse) {} + rpc HeartbeatLocks (HeartbeatLocksRequest) returns (HeartbeatLocksResponse) {} } -message Lock { +message AcquireLockRequest { string resource_id = 1; string execution_id = 2; string process_id = 3; int64 expiry_in_milliseconds = 4; - int64 expires_at = 5; + string request_id = 5; } -message AcquireLockRequest { +message AcquireLockResponse { + bool acquired = 1; +} + +message ReleaseLockRequest { string resource_id = 1; string execution_id = 2; - string process_id = 3; - int64 expiry_in_milliseconds = 4; - string request_id = 5; + string request_id = 3; } -message AcquireLockResponse { - Lock lock = 1; +message ReleaseLockResponse { + bool released = 1; } message HeartbeatLocksRequest { @@ -38,11 +40,3 @@ message HeartbeatLocksRequest { message HeartbeatLocksResponse { int32 locksAffected = 1; } - -message ReleaseLockRequest { - string resource_id = 1; - string execution_id = 2; - string request_id = 3; -} - -message ReleaseLockResponse {} diff --git a/internal/app/subsystems/api/grpc/api/lock_grpc.pb.go b/internal/app/subsystems/api/grpc/pb/lock_grpc.pb.go similarity index 98% rename from internal/app/subsystems/api/grpc/api/lock_grpc.pb.go rename to internal/app/subsystems/api/grpc/pb/lock_grpc.pb.go index 60e01616..36c57b3b 100644 --- a/internal/app/subsystems/api/grpc/api/lock_grpc.pb.go +++ b/internal/app/subsystems/api/grpc/pb/lock_grpc.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-grpc v1.3.0 // - protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/lock.proto +// source: internal/app/subsystems/api/grpc/pb/lock.proto -package api +package pb import ( context "context" @@ -20,8 +20,8 @@ const _ = grpc.SupportPackageIsVersion7 const ( Locks_AcquireLock_FullMethodName = "/lock.Locks/AcquireLock" - Locks_HeartbeatLocks_FullMethodName = "/lock.Locks/HeartbeatLocks" Locks_ReleaseLock_FullMethodName = "/lock.Locks/ReleaseLock" + Locks_HeartbeatLocks_FullMethodName = "/lock.Locks/HeartbeatLocks" ) // LocksClient is the client API for Locks service. @@ -29,8 +29,8 @@ const ( // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type LocksClient interface { AcquireLock(ctx context.Context, in *AcquireLockRequest, opts ...grpc.CallOption) (*AcquireLockResponse, error) - HeartbeatLocks(ctx context.Context, in *HeartbeatLocksRequest, opts ...grpc.CallOption) (*HeartbeatLocksResponse, error) ReleaseLock(ctx context.Context, in *ReleaseLockRequest, opts ...grpc.CallOption) (*ReleaseLockResponse, error) + HeartbeatLocks(ctx context.Context, in *HeartbeatLocksRequest, opts ...grpc.CallOption) (*HeartbeatLocksResponse, error) } type locksClient struct { @@ -50,18 +50,18 @@ func (c *locksClient) AcquireLock(ctx context.Context, in *AcquireLockRequest, o return out, nil } -func (c *locksClient) HeartbeatLocks(ctx context.Context, in *HeartbeatLocksRequest, opts ...grpc.CallOption) (*HeartbeatLocksResponse, error) { - out := new(HeartbeatLocksResponse) - err := c.cc.Invoke(ctx, Locks_HeartbeatLocks_FullMethodName, in, out, opts...) +func (c *locksClient) ReleaseLock(ctx context.Context, in *ReleaseLockRequest, opts ...grpc.CallOption) (*ReleaseLockResponse, error) { + out := new(ReleaseLockResponse) + err := c.cc.Invoke(ctx, Locks_ReleaseLock_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *locksClient) ReleaseLock(ctx context.Context, in *ReleaseLockRequest, opts ...grpc.CallOption) (*ReleaseLockResponse, error) { - out := new(ReleaseLockResponse) - err := c.cc.Invoke(ctx, Locks_ReleaseLock_FullMethodName, in, out, opts...) +func (c *locksClient) HeartbeatLocks(ctx context.Context, in *HeartbeatLocksRequest, opts ...grpc.CallOption) (*HeartbeatLocksResponse, error) { + out := new(HeartbeatLocksResponse) + err := c.cc.Invoke(ctx, Locks_HeartbeatLocks_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -73,8 +73,8 @@ func (c *locksClient) ReleaseLock(ctx context.Context, in *ReleaseLockRequest, o // for forward compatibility type LocksServer interface { AcquireLock(context.Context, *AcquireLockRequest) (*AcquireLockResponse, error) - HeartbeatLocks(context.Context, *HeartbeatLocksRequest) (*HeartbeatLocksResponse, error) ReleaseLock(context.Context, *ReleaseLockRequest) (*ReleaseLockResponse, error) + HeartbeatLocks(context.Context, *HeartbeatLocksRequest) (*HeartbeatLocksResponse, error) mustEmbedUnimplementedLocksServer() } @@ -85,12 +85,12 @@ type UnimplementedLocksServer struct { func (UnimplementedLocksServer) AcquireLock(context.Context, *AcquireLockRequest) (*AcquireLockResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AcquireLock not implemented") } -func (UnimplementedLocksServer) HeartbeatLocks(context.Context, *HeartbeatLocksRequest) (*HeartbeatLocksResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method HeartbeatLocks not implemented") -} func (UnimplementedLocksServer) ReleaseLock(context.Context, *ReleaseLockRequest) (*ReleaseLockResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ReleaseLock not implemented") } +func (UnimplementedLocksServer) HeartbeatLocks(context.Context, *HeartbeatLocksRequest) (*HeartbeatLocksResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HeartbeatLocks not implemented") +} func (UnimplementedLocksServer) mustEmbedUnimplementedLocksServer() {} // UnsafeLocksServer may be embedded to opt out of forward compatibility for this service. @@ -122,38 +122,38 @@ func _Locks_AcquireLock_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } -func _Locks_HeartbeatLocks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HeartbeatLocksRequest) +func _Locks_ReleaseLock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReleaseLockRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(LocksServer).HeartbeatLocks(ctx, in) + return srv.(LocksServer).ReleaseLock(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Locks_HeartbeatLocks_FullMethodName, + FullMethod: Locks_ReleaseLock_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LocksServer).HeartbeatLocks(ctx, req.(*HeartbeatLocksRequest)) + return srv.(LocksServer).ReleaseLock(ctx, req.(*ReleaseLockRequest)) } return interceptor(ctx, in, info, handler) } -func _Locks_ReleaseLock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ReleaseLockRequest) +func _Locks_HeartbeatLocks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HeartbeatLocksRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(LocksServer).ReleaseLock(ctx, in) + return srv.(LocksServer).HeartbeatLocks(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Locks_ReleaseLock_FullMethodName, + FullMethod: Locks_HeartbeatLocks_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LocksServer).ReleaseLock(ctx, req.(*ReleaseLockRequest)) + return srv.(LocksServer).HeartbeatLocks(ctx, req.(*HeartbeatLocksRequest)) } return interceptor(ctx, in, info, handler) } @@ -169,15 +169,15 @@ var Locks_ServiceDesc = grpc.ServiceDesc{ MethodName: "AcquireLock", Handler: _Locks_AcquireLock_Handler, }, - { - MethodName: "HeartbeatLocks", - Handler: _Locks_HeartbeatLocks_Handler, - }, { MethodName: "ReleaseLock", Handler: _Locks_ReleaseLock_Handler, }, + { + MethodName: "HeartbeatLocks", + Handler: _Locks_HeartbeatLocks_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "internal/app/subsystems/api/grpc/api/lock.proto", + Metadata: "internal/app/subsystems/api/grpc/pb/lock.proto", } diff --git a/internal/app/subsystems/api/grpc/pb/promise.pb.go b/internal/app/subsystems/api/grpc/pb/promise.pb.go new file mode 100644 index 00000000..01dfc1c2 --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/promise.pb.go @@ -0,0 +1,1773 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.3 +// source: internal/app/subsystems/api/grpc/pb/promise.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SearchState int32 + +const ( + SearchState_SEARCH_ALL SearchState = 0 + SearchState_SEARCH_PENDING SearchState = 1 + SearchState_SEARCH_RESOLVED SearchState = 2 + SearchState_SEARCH_REJECTED SearchState = 3 +) + +// Enum value maps for SearchState. +var ( + SearchState_name = map[int32]string{ + 0: "SEARCH_ALL", + 1: "SEARCH_PENDING", + 2: "SEARCH_RESOLVED", + 3: "SEARCH_REJECTED", + } + SearchState_value = map[string]int32{ + "SEARCH_ALL": 0, + "SEARCH_PENDING": 1, + "SEARCH_RESOLVED": 2, + "SEARCH_REJECTED": 3, + } +) + +func (x SearchState) Enum() *SearchState { + p := new(SearchState) + *p = x + return p +} + +func (x SearchState) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SearchState) Descriptor() protoreflect.EnumDescriptor { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_enumTypes[0].Descriptor() +} + +func (SearchState) Type() protoreflect.EnumType { + return &file_internal_app_subsystems_api_grpc_pb_promise_proto_enumTypes[0] +} + +func (x SearchState) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SearchState.Descriptor instead. +func (SearchState) EnumDescriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{0} +} + +type ReadPromiseRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *ReadPromiseRequest) Reset() { + *x = ReadPromiseRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadPromiseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadPromiseRequest) ProtoMessage() {} + +func (x *ReadPromiseRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadPromiseRequest.ProtoReflect.Descriptor instead. +func (*ReadPromiseRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{0} +} + +func (x *ReadPromiseRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *ReadPromiseRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type ReadPromiseResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Promise *Promise `protobuf:"bytes,1,opt,name=promise,proto3" json:"promise,omitempty"` +} + +func (x *ReadPromiseResponse) Reset() { + *x = ReadPromiseResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadPromiseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadPromiseResponse) ProtoMessage() {} + +func (x *ReadPromiseResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadPromiseResponse.ProtoReflect.Descriptor instead. +func (*ReadPromiseResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{1} +} + +func (x *ReadPromiseResponse) GetPromise() *Promise { + if x != nil { + return x.Promise + } + return nil +} + +type SearchPromisesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + State SearchState `protobuf:"varint,2,opt,name=state,proto3,enum=promise.SearchState" json:"state,omitempty"` + Tags map[string]string `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Limit int32 `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"` + Cursor string `protobuf:"bytes,5,opt,name=cursor,proto3" json:"cursor,omitempty"` + RequestId string `protobuf:"bytes,6,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *SearchPromisesRequest) Reset() { + *x = SearchPromisesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchPromisesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchPromisesRequest) ProtoMessage() {} + +func (x *SearchPromisesRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SearchPromisesRequest.ProtoReflect.Descriptor instead. +func (*SearchPromisesRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{2} +} + +func (x *SearchPromisesRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *SearchPromisesRequest) GetState() SearchState { + if x != nil { + return x.State + } + return SearchState_SEARCH_ALL +} + +func (x *SearchPromisesRequest) GetTags() map[string]string { + if x != nil { + return x.Tags + } + return nil +} + +func (x *SearchPromisesRequest) GetLimit() int32 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *SearchPromisesRequest) GetCursor() string { + if x != nil { + return x.Cursor + } + return "" +} + +func (x *SearchPromisesRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type SearchPromisesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Promises []*Promise `protobuf:"bytes,1,rep,name=promises,proto3" json:"promises,omitempty"` + Cursor string `protobuf:"bytes,2,opt,name=cursor,proto3" json:"cursor,omitempty"` +} + +func (x *SearchPromisesResponse) Reset() { + *x = SearchPromisesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchPromisesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchPromisesResponse) ProtoMessage() {} + +func (x *SearchPromisesResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SearchPromisesResponse.ProtoReflect.Descriptor instead. +func (*SearchPromisesResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{3} +} + +func (x *SearchPromisesResponse) GetPromises() []*Promise { + if x != nil { + return x.Promises + } + return nil +} + +func (x *SearchPromisesResponse) GetCursor() string { + if x != nil { + return x.Cursor + } + return "" +} + +type CreatePromiseRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + IdempotencyKey string `protobuf:"bytes,2,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` + Param *Value `protobuf:"bytes,4,opt,name=param,proto3" json:"param,omitempty"` + Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` + Tags map[string]string `protobuf:"bytes,6,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + RequestId string `protobuf:"bytes,7,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *CreatePromiseRequest) Reset() { + *x = CreatePromiseRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePromiseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePromiseRequest) ProtoMessage() {} + +func (x *CreatePromiseRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePromiseRequest.ProtoReflect.Descriptor instead. +func (*CreatePromiseRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{4} +} + +func (x *CreatePromiseRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CreatePromiseRequest) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + +func (x *CreatePromiseRequest) GetStrict() bool { + if x != nil { + return x.Strict + } + return false +} + +func (x *CreatePromiseRequest) GetParam() *Value { + if x != nil { + return x.Param + } + return nil +} + +func (x *CreatePromiseRequest) GetTimeout() int64 { + if x != nil { + return x.Timeout + } + return 0 +} + +func (x *CreatePromiseRequest) GetTags() map[string]string { + if x != nil { + return x.Tags + } + return nil +} + +func (x *CreatePromiseRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type CreatePromiseResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` + Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` +} + +func (x *CreatePromiseResponse) Reset() { + *x = CreatePromiseResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePromiseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePromiseResponse) ProtoMessage() {} + +func (x *CreatePromiseResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePromiseResponse.ProtoReflect.Descriptor instead. +func (*CreatePromiseResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{5} +} + +func (x *CreatePromiseResponse) GetNoop() bool { + if x != nil { + return x.Noop + } + return false +} + +func (x *CreatePromiseResponse) GetPromise() *Promise { + if x != nil { + return x.Promise + } + return nil +} + +type CreatePromiseAndTaskRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Promise *CreatePromiseRequest `protobuf:"bytes,1,opt,name=promise,proto3" json:"promise,omitempty"` + Task *CreatePromiseTaskRequest `protobuf:"bytes,2,opt,name=task,proto3" json:"task,omitempty"` +} + +func (x *CreatePromiseAndTaskRequest) Reset() { + *x = CreatePromiseAndTaskRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePromiseAndTaskRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePromiseAndTaskRequest) ProtoMessage() {} + +func (x *CreatePromiseAndTaskRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePromiseAndTaskRequest.ProtoReflect.Descriptor instead. +func (*CreatePromiseAndTaskRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{6} +} + +func (x *CreatePromiseAndTaskRequest) GetPromise() *CreatePromiseRequest { + if x != nil { + return x.Promise + } + return nil +} + +func (x *CreatePromiseAndTaskRequest) GetTask() *CreatePromiseTaskRequest { + if x != nil { + return x.Task + } + return nil +} + +type CreatePromiseTaskRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProcessId string `protobuf:"bytes,1,opt,name=processId,proto3" json:"processId,omitempty"` + Frequency int32 `protobuf:"varint,2,opt,name=frequency,proto3" json:"frequency,omitempty"` + Recv *Recv `protobuf:"bytes,3,opt,name=recv,proto3" json:"recv,omitempty"` +} + +func (x *CreatePromiseTaskRequest) Reset() { + *x = CreatePromiseTaskRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePromiseTaskRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePromiseTaskRequest) ProtoMessage() {} + +func (x *CreatePromiseTaskRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePromiseTaskRequest.ProtoReflect.Descriptor instead. +func (*CreatePromiseTaskRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{7} +} + +func (x *CreatePromiseTaskRequest) GetProcessId() string { + if x != nil { + return x.ProcessId + } + return "" +} + +func (x *CreatePromiseTaskRequest) GetFrequency() int32 { + if x != nil { + return x.Frequency + } + return 0 +} + +func (x *CreatePromiseTaskRequest) GetRecv() *Recv { + if x != nil { + return x.Recv + } + return nil +} + +type CreatePromiseAndTaskResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` + Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` +} + +func (x *CreatePromiseAndTaskResponse) Reset() { + *x = CreatePromiseAndTaskResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePromiseAndTaskResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePromiseAndTaskResponse) ProtoMessage() {} + +func (x *CreatePromiseAndTaskResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePromiseAndTaskResponse.ProtoReflect.Descriptor instead. +func (*CreatePromiseAndTaskResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{8} +} + +func (x *CreatePromiseAndTaskResponse) GetNoop() bool { + if x != nil { + return x.Noop + } + return false +} + +func (x *CreatePromiseAndTaskResponse) GetPromise() *Promise { + if x != nil { + return x.Promise + } + return nil +} + +type CreatePromiseAndCallbackRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Promise *CreatePromiseRequest `protobuf:"bytes,1,opt,name=promise,proto3" json:"promise,omitempty"` + Callback *CreatePromiseCallbackRequest `protobuf:"bytes,2,opt,name=callback,proto3" json:"callback,omitempty"` +} + +func (x *CreatePromiseAndCallbackRequest) Reset() { + *x = CreatePromiseAndCallbackRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePromiseAndCallbackRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePromiseAndCallbackRequest) ProtoMessage() {} + +func (x *CreatePromiseAndCallbackRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePromiseAndCallbackRequest.ProtoReflect.Descriptor instead. +func (*CreatePromiseAndCallbackRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{9} +} + +func (x *CreatePromiseAndCallbackRequest) GetPromise() *CreatePromiseRequest { + if x != nil { + return x.Promise + } + return nil +} + +func (x *CreatePromiseAndCallbackRequest) GetCallback() *CreatePromiseCallbackRequest { + if x != nil { + return x.Callback + } + return nil +} + +type CreatePromiseCallbackRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RootPromiseId string `protobuf:"bytes,1,opt,name=rootPromiseId,proto3" json:"rootPromiseId,omitempty"` + Timeout int64 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` + Recv *Recv `protobuf:"bytes,3,opt,name=recv,proto3" json:"recv,omitempty"` +} + +func (x *CreatePromiseCallbackRequest) Reset() { + *x = CreatePromiseCallbackRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePromiseCallbackRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePromiseCallbackRequest) ProtoMessage() {} + +func (x *CreatePromiseCallbackRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePromiseCallbackRequest.ProtoReflect.Descriptor instead. +func (*CreatePromiseCallbackRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{10} +} + +func (x *CreatePromiseCallbackRequest) GetRootPromiseId() string { + if x != nil { + return x.RootPromiseId + } + return "" +} + +func (x *CreatePromiseCallbackRequest) GetTimeout() int64 { + if x != nil { + return x.Timeout + } + return 0 +} + +func (x *CreatePromiseCallbackRequest) GetRecv() *Recv { + if x != nil { + return x.Recv + } + return nil +} + +type CreatePromiseAndCallbackResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` + Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` +} + +func (x *CreatePromiseAndCallbackResponse) Reset() { + *x = CreatePromiseAndCallbackResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatePromiseAndCallbackResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePromiseAndCallbackResponse) ProtoMessage() {} + +func (x *CreatePromiseAndCallbackResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatePromiseAndCallbackResponse.ProtoReflect.Descriptor instead. +func (*CreatePromiseAndCallbackResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{11} +} + +func (x *CreatePromiseAndCallbackResponse) GetNoop() bool { + if x != nil { + return x.Noop + } + return false +} + +func (x *CreatePromiseAndCallbackResponse) GetPromise() *Promise { + if x != nil { + return x.Promise + } + return nil +} + +type ResolvePromiseRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + IdempotencyKey string `protobuf:"bytes,2,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` + Value *Value `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` + RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *ResolvePromiseRequest) Reset() { + *x = ResolvePromiseRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResolvePromiseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResolvePromiseRequest) ProtoMessage() {} + +func (x *ResolvePromiseRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResolvePromiseRequest.ProtoReflect.Descriptor instead. +func (*ResolvePromiseRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{12} +} + +func (x *ResolvePromiseRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *ResolvePromiseRequest) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + +func (x *ResolvePromiseRequest) GetStrict() bool { + if x != nil { + return x.Strict + } + return false +} + +func (x *ResolvePromiseRequest) GetValue() *Value { + if x != nil { + return x.Value + } + return nil +} + +func (x *ResolvePromiseRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type ResolvePromiseResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` + Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` +} + +func (x *ResolvePromiseResponse) Reset() { + *x = ResolvePromiseResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResolvePromiseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResolvePromiseResponse) ProtoMessage() {} + +func (x *ResolvePromiseResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResolvePromiseResponse.ProtoReflect.Descriptor instead. +func (*ResolvePromiseResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{13} +} + +func (x *ResolvePromiseResponse) GetNoop() bool { + if x != nil { + return x.Noop + } + return false +} + +func (x *ResolvePromiseResponse) GetPromise() *Promise { + if x != nil { + return x.Promise + } + return nil +} + +type RejectPromiseRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + IdempotencyKey string `protobuf:"bytes,2,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` + Value *Value `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` + RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *RejectPromiseRequest) Reset() { + *x = RejectPromiseRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RejectPromiseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RejectPromiseRequest) ProtoMessage() {} + +func (x *RejectPromiseRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RejectPromiseRequest.ProtoReflect.Descriptor instead. +func (*RejectPromiseRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{14} +} + +func (x *RejectPromiseRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *RejectPromiseRequest) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + +func (x *RejectPromiseRequest) GetStrict() bool { + if x != nil { + return x.Strict + } + return false +} + +func (x *RejectPromiseRequest) GetValue() *Value { + if x != nil { + return x.Value + } + return nil +} + +func (x *RejectPromiseRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type RejectPromiseResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` + Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` +} + +func (x *RejectPromiseResponse) Reset() { + *x = RejectPromiseResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RejectPromiseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RejectPromiseResponse) ProtoMessage() {} + +func (x *RejectPromiseResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RejectPromiseResponse.ProtoReflect.Descriptor instead. +func (*RejectPromiseResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{15} +} + +func (x *RejectPromiseResponse) GetNoop() bool { + if x != nil { + return x.Noop + } + return false +} + +func (x *RejectPromiseResponse) GetPromise() *Promise { + if x != nil { + return x.Promise + } + return nil +} + +type CancelPromiseRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + IdempotencyKey string `protobuf:"bytes,2,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` + Value *Value `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` + RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *CancelPromiseRequest) Reset() { + *x = CancelPromiseRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CancelPromiseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CancelPromiseRequest) ProtoMessage() {} + +func (x *CancelPromiseRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CancelPromiseRequest.ProtoReflect.Descriptor instead. +func (*CancelPromiseRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{16} +} + +func (x *CancelPromiseRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CancelPromiseRequest) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + +func (x *CancelPromiseRequest) GetStrict() bool { + if x != nil { + return x.Strict + } + return false +} + +func (x *CancelPromiseRequest) GetValue() *Value { + if x != nil { + return x.Value + } + return nil +} + +func (x *CancelPromiseRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type CancelPromiseResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` + Promise *Promise `protobuf:"bytes,2,opt,name=promise,proto3" json:"promise,omitempty"` +} + +func (x *CancelPromiseResponse) Reset() { + *x = CancelPromiseResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CancelPromiseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CancelPromiseResponse) ProtoMessage() {} + +func (x *CancelPromiseResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CancelPromiseResponse.ProtoReflect.Descriptor instead. +func (*CancelPromiseResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP(), []int{17} +} + +func (x *CancelPromiseResponse) GetNoop() bool { + if x != nil { + return x.Noop + } + return false +} + +func (x *CancelPromiseResponse) GetPromise() *Promise { + if x != nil { + return x.Promise + } + return nil +} + +var File_internal_app_subsystems_api_grpc_pb_promise_proto protoreflect.FileDescriptor + +var file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDesc = []byte{ + 0x0a, 0x31, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x1a, 0x34, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, + 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, + 0x62, 0x2f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x33, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, + 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, + 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x42, 0x0a, 0x12, 0x52, 0x65, 0x61, 0x64, 0x50, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, + 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x43, 0x0a, 0x13, 0x52, + 0x65, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, + 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x22, 0x96, 0x02, 0x0a, 0x15, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2a, 0x0a, 0x05, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x6d, + 0x69, 0x73, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, + 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, + 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, + 0x74, 0x61, 0x67, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x75, + 0x72, 0x73, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, + 0x6f, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, + 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x60, 0x0a, 0x16, 0x53, 0x65, 0x61, + 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, + 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x22, 0xbc, 0x02, 0x0a, 0x14, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, + 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x64, + 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, + 0x72, 0x69, 0x63, 0x74, 0x12, 0x26, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x18, 0x0a, 0x07, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x3b, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x06, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, + 0x61, 0x67, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, + 0x64, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x59, 0x0a, 0x15, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0x8d, 0x01, 0x0a, 0x1b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x41, 0x6e, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x35, + 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, + 0x04, 0x74, 0x61, 0x73, 0x6b, 0x22, 0x7c, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, + 0x1c, 0x0a, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x09, 0x66, 0x72, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x24, 0x0a, + 0x04, 0x72, 0x65, 0x63, 0x76, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x61, + 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x2e, 0x52, 0x65, 0x63, 0x76, 0x52, 0x04, 0x72, + 0x65, 0x63, 0x76, 0x22, 0x60, 0x0a, 0x1c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x41, 0x6e, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0x9d, 0x01, 0x0a, 0x1f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x41, 0x6e, 0x64, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, + 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x07, 0x70, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x43, 0x61, 0x6c, 0x6c, + 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x08, 0x63, 0x61, 0x6c, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x22, 0x84, 0x01, 0x0a, 0x1c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x6f, 0x6f, 0x74, 0x50, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, + 0x6f, 0x6f, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x72, 0x65, 0x63, 0x76, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, + 0x74, 0x2e, 0x52, 0x65, 0x63, 0x76, 0x52, 0x04, 0x72, 0x65, 0x63, 0x76, 0x22, 0x64, 0x0a, 0x20, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x41, 0x6e, 0x64, + 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, + 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, + 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x15, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x0e, + 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, + 0x79, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x12, 0x26, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, + 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x49, 0x64, 0x22, 0x5a, 0x0a, 0x16, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, + 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x50, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0xac, + 0x01, 0x0a, 0x14, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, + 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x12, + 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x12, 0x26, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x5f, 0x74, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, + 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x59, 0x0a, + 0x15, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, + 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0xac, 0x01, 0x0a, 0x14, 0x43, 0x61, 0x6e, + 0x63, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, + 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, + 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, + 0x69, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, + 0x74, 0x12, 0x26, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x59, 0x0a, 0x15, 0x43, 0x61, 0x6e, 0x63, 0x65, + 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, + 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, + 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x2a, 0x5b, 0x0a, 0x0b, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, 0x5f, 0x41, 0x4c, 0x4c, 0x10, + 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, 0x5f, 0x50, 0x45, 0x4e, 0x44, + 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, 0x5f, + 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, + 0x41, 0x52, 0x43, 0x48, 0x5f, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x03, 0x32, + 0xd0, 0x05, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x12, 0x4a, 0x0a, 0x0b, + 0x52, 0x65, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x1b, 0x2e, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, + 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x1d, + 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, + 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x65, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x41, 0x6e, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x41, + 0x6e, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, + 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x41, 0x6e, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x71, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x41, 0x6e, 0x64, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, + 0x63, 0x6b, 0x12, 0x28, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x41, 0x6e, 0x64, 0x43, 0x61, 0x6c, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x41, 0x6e, 0x64, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x0e, 0x52, 0x65, 0x73, + 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x1e, 0x2e, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, + 0x0a, 0x0d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, + 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, + 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, + 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x50, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x50, 0x0a, 0x0d, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, 0x61, 0x6e, 0x63, + 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x43, 0x61, 0x6e, 0x63, 0x65, + 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, + 0x6e, 0x61, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, + 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescOnce sync.Once + file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescData = file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDesc +) + +func file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescGZIP() []byte { + file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescOnce.Do(func() { + file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescData) + }) + return file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDescData +} + +var file_internal_app_subsystems_api_grpc_pb_promise_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_internal_app_subsystems_api_grpc_pb_promise_proto_goTypes = []interface{}{ + (SearchState)(0), // 0: promise.SearchState + (*ReadPromiseRequest)(nil), // 1: promise.ReadPromiseRequest + (*ReadPromiseResponse)(nil), // 2: promise.ReadPromiseResponse + (*SearchPromisesRequest)(nil), // 3: promise.SearchPromisesRequest + (*SearchPromisesResponse)(nil), // 4: promise.SearchPromisesResponse + (*CreatePromiseRequest)(nil), // 5: promise.CreatePromiseRequest + (*CreatePromiseResponse)(nil), // 6: promise.CreatePromiseResponse + (*CreatePromiseAndTaskRequest)(nil), // 7: promise.CreatePromiseAndTaskRequest + (*CreatePromiseTaskRequest)(nil), // 8: promise.CreatePromiseTaskRequest + (*CreatePromiseAndTaskResponse)(nil), // 9: promise.CreatePromiseAndTaskResponse + (*CreatePromiseAndCallbackRequest)(nil), // 10: promise.CreatePromiseAndCallbackRequest + (*CreatePromiseCallbackRequest)(nil), // 11: promise.CreatePromiseCallbackRequest + (*CreatePromiseAndCallbackResponse)(nil), // 12: promise.CreatePromiseAndCallbackResponse + (*ResolvePromiseRequest)(nil), // 13: promise.ResolvePromiseRequest + (*ResolvePromiseResponse)(nil), // 14: promise.ResolvePromiseResponse + (*RejectPromiseRequest)(nil), // 15: promise.RejectPromiseRequest + (*RejectPromiseResponse)(nil), // 16: promise.RejectPromiseResponse + (*CancelPromiseRequest)(nil), // 17: promise.CancelPromiseRequest + (*CancelPromiseResponse)(nil), // 18: promise.CancelPromiseResponse + nil, // 19: promise.SearchPromisesRequest.TagsEntry + nil, // 20: promise.CreatePromiseRequest.TagsEntry + (*Promise)(nil), // 21: promise_t.Promise + (*Value)(nil), // 22: promise_t.Value + (*Recv)(nil), // 23: callback_t.Recv +} +var file_internal_app_subsystems_api_grpc_pb_promise_proto_depIdxs = []int32{ + 21, // 0: promise.ReadPromiseResponse.promise:type_name -> promise_t.Promise + 0, // 1: promise.SearchPromisesRequest.state:type_name -> promise.SearchState + 19, // 2: promise.SearchPromisesRequest.tags:type_name -> promise.SearchPromisesRequest.TagsEntry + 21, // 3: promise.SearchPromisesResponse.promises:type_name -> promise_t.Promise + 22, // 4: promise.CreatePromiseRequest.param:type_name -> promise_t.Value + 20, // 5: promise.CreatePromiseRequest.tags:type_name -> promise.CreatePromiseRequest.TagsEntry + 21, // 6: promise.CreatePromiseResponse.promise:type_name -> promise_t.Promise + 5, // 7: promise.CreatePromiseAndTaskRequest.promise:type_name -> promise.CreatePromiseRequest + 8, // 8: promise.CreatePromiseAndTaskRequest.task:type_name -> promise.CreatePromiseTaskRequest + 23, // 9: promise.CreatePromiseTaskRequest.recv:type_name -> callback_t.Recv + 21, // 10: promise.CreatePromiseAndTaskResponse.promise:type_name -> promise_t.Promise + 5, // 11: promise.CreatePromiseAndCallbackRequest.promise:type_name -> promise.CreatePromiseRequest + 11, // 12: promise.CreatePromiseAndCallbackRequest.callback:type_name -> promise.CreatePromiseCallbackRequest + 23, // 13: promise.CreatePromiseCallbackRequest.recv:type_name -> callback_t.Recv + 21, // 14: promise.CreatePromiseAndCallbackResponse.promise:type_name -> promise_t.Promise + 22, // 15: promise.ResolvePromiseRequest.value:type_name -> promise_t.Value + 21, // 16: promise.ResolvePromiseResponse.promise:type_name -> promise_t.Promise + 22, // 17: promise.RejectPromiseRequest.value:type_name -> promise_t.Value + 21, // 18: promise.RejectPromiseResponse.promise:type_name -> promise_t.Promise + 22, // 19: promise.CancelPromiseRequest.value:type_name -> promise_t.Value + 21, // 20: promise.CancelPromiseResponse.promise:type_name -> promise_t.Promise + 1, // 21: promise.Promises.ReadPromise:input_type -> promise.ReadPromiseRequest + 3, // 22: promise.Promises.SearchPromises:input_type -> promise.SearchPromisesRequest + 5, // 23: promise.Promises.CreatePromise:input_type -> promise.CreatePromiseRequest + 7, // 24: promise.Promises.CreatePromiseAndTask:input_type -> promise.CreatePromiseAndTaskRequest + 10, // 25: promise.Promises.CreatePromiseAndCallback:input_type -> promise.CreatePromiseAndCallbackRequest + 13, // 26: promise.Promises.ResolvePromise:input_type -> promise.ResolvePromiseRequest + 15, // 27: promise.Promises.RejectPromise:input_type -> promise.RejectPromiseRequest + 17, // 28: promise.Promises.CancelPromise:input_type -> promise.CancelPromiseRequest + 2, // 29: promise.Promises.ReadPromise:output_type -> promise.ReadPromiseResponse + 4, // 30: promise.Promises.SearchPromises:output_type -> promise.SearchPromisesResponse + 6, // 31: promise.Promises.CreatePromise:output_type -> promise.CreatePromiseResponse + 9, // 32: promise.Promises.CreatePromiseAndTask:output_type -> promise.CreatePromiseAndTaskResponse + 12, // 33: promise.Promises.CreatePromiseAndCallback:output_type -> promise.CreatePromiseAndCallbackResponse + 14, // 34: promise.Promises.ResolvePromise:output_type -> promise.ResolvePromiseResponse + 16, // 35: promise.Promises.RejectPromise:output_type -> promise.RejectPromiseResponse + 18, // 36: promise.Promises.CancelPromise:output_type -> promise.CancelPromiseResponse + 29, // [29:37] is the sub-list for method output_type + 21, // [21:29] is the sub-list for method input_type + 21, // [21:21] is the sub-list for extension type_name + 21, // [21:21] is the sub-list for extension extendee + 0, // [0:21] is the sub-list for field type_name +} + +func init() { file_internal_app_subsystems_api_grpc_pb_promise_proto_init() } +func file_internal_app_subsystems_api_grpc_pb_promise_proto_init() { + if File_internal_app_subsystems_api_grpc_pb_promise_proto != nil { + return + } + file_internal_app_subsystems_api_grpc_pb_callback_t_proto_init() + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_init() + if !protoimpl.UnsafeEnabled { + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadPromiseRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadPromiseResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchPromisesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchPromisesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatePromiseRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatePromiseResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatePromiseAndTaskRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatePromiseTaskRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatePromiseAndTaskResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatePromiseAndCallbackRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatePromiseCallbackRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatePromiseAndCallbackResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResolvePromiseRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResolvePromiseResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RejectPromiseRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RejectPromiseResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CancelPromiseRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CancelPromiseResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDesc, + NumEnums: 1, + NumMessages: 20, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_internal_app_subsystems_api_grpc_pb_promise_proto_goTypes, + DependencyIndexes: file_internal_app_subsystems_api_grpc_pb_promise_proto_depIdxs, + EnumInfos: file_internal_app_subsystems_api_grpc_pb_promise_proto_enumTypes, + MessageInfos: file_internal_app_subsystems_api_grpc_pb_promise_proto_msgTypes, + }.Build() + File_internal_app_subsystems_api_grpc_pb_promise_proto = out.File + file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDesc = nil + file_internal_app_subsystems_api_grpc_pb_promise_proto_goTypes = nil + file_internal_app_subsystems_api_grpc_pb_promise_proto_depIdxs = nil +} diff --git a/internal/app/subsystems/api/grpc/api/promise.proto b/internal/app/subsystems/api/grpc/pb/promise.proto similarity index 54% rename from internal/app/subsystems/api/grpc/api/promise.proto rename to internal/app/subsystems/api/grpc/pb/promise.proto index 0b348dac..5de37fa1 100644 --- a/internal/app/subsystems/api/grpc/api/promise.proto +++ b/internal/app/subsystems/api/grpc/pb/promise.proto @@ -2,36 +2,29 @@ syntax = "proto3"; package promise; -option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api"; +import "internal/app/subsystems/api/grpc/pb/callback_t.proto"; +import "internal/app/subsystems/api/grpc/pb/promise_t.proto"; + +option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb"; service Promises { rpc ReadPromise(ReadPromiseRequest) returns (ReadPromiseResponse) {} rpc SearchPromises(SearchPromisesRequest) returns (SearchPromisesResponse) {} rpc CreatePromise(CreatePromiseRequest) returns (CreatePromiseResponse) {} - rpc CancelPromise(CancelPromiseRequest) returns (CancelPromiseResponse) {} + rpc CreatePromiseAndTask(CreatePromiseAndTaskRequest) returns (CreatePromiseAndTaskResponse) {} + rpc CreatePromiseAndCallback(CreatePromiseAndCallbackRequest) returns (CreatePromiseAndCallbackResponse) {} rpc ResolvePromise(ResolvePromiseRequest) returns (ResolvePromiseResponse) {} rpc RejectPromise(RejectPromiseRequest) returns (RejectPromiseResponse) {} + rpc CancelPromise(CancelPromiseRequest) returns (CancelPromiseResponse) {} } -message Promise { +message ReadPromiseRequest { string id = 1; - State state = 2; - Value param = 3; - Value value = 4; - int64 timeout = 5; - string idempotencyKeyForCreate = 6; - string idempotencyKeyForComplete = 7; - int64 createdOn = 8; - int64 completedOn = 9; - map tags = 10; + string requestId = 2; } -enum State { - PENDING = 0; - RESOLVED = 1; - REJECTED = 2; - REJECTED_TIMEDOUT = 3; - REJECTED_CANCELED = 4; +message ReadPromiseResponse { + promise_t.Promise promise = 1; } enum SearchState { @@ -41,20 +34,6 @@ enum SearchState { SEARCH_REJECTED = 3; } -message Value { - map headers = 1; - bytes data = 2; -} - -message ReadPromiseRequest { - string id = 1; - string requestId = 2; -} - -message ReadPromiseResponse { - Promise promise = 1; -} - message SearchPromisesRequest { string id = 1; SearchState state = 2; @@ -65,59 +44,92 @@ message SearchPromisesRequest { } message SearchPromisesResponse { - string cursor = 1; - repeated Promise promises = 2; + repeated promise_t.Promise promises = 1; + string cursor = 2; } message CreatePromiseRequest { string id = 1; string idempotencyKey = 2; bool strict = 3; - Value param = 4; + promise_t.Value param = 4; int64 timeout = 5; - string requestId = 6; + map tags = 6; + string requestId = 7; } message CreatePromiseResponse { bool noop = 1; - Promise promise = 2; + promise_t.Promise promise = 2; } -message CancelPromiseRequest { - string id = 1; - string idempotencyKey = 2; - bool strict = 3; - Value value = 4; - string requestId = 5; +message CreatePromiseAndTaskRequest { + CreatePromiseRequest promise = 1; + CreatePromiseTaskRequest task = 2; } -message CancelPromiseResponse { +message CreatePromiseTaskRequest { + string processId = 1; + int32 frequency = 2; + callback_t.Recv recv = 3; +} + +message CreatePromiseAndTaskResponse { + bool noop = 1; + promise_t.Promise promise = 2; +} + +message CreatePromiseAndCallbackRequest { + CreatePromiseRequest promise = 1; + CreatePromiseCallbackRequest callback = 2; +} + +message CreatePromiseCallbackRequest { + string rootPromiseId = 1; + int64 timeout = 2; + callback_t.Recv recv = 3; +} + +message CreatePromiseAndCallbackResponse { bool noop = 1; - Promise promise = 2; + promise_t.Promise promise = 2; } message ResolvePromiseRequest { string id = 1; string idempotencyKey = 2; bool strict = 3; - Value value = 4; + promise_t.Value value = 4; string requestId = 5; } message ResolvePromiseResponse { bool noop = 1; - Promise promise = 2; + promise_t.Promise promise = 2; } message RejectPromiseRequest { string id = 1; string idempotencyKey = 2; bool strict = 3; - Value value = 4; + promise_t.Value value = 4; string requestId = 5; } message RejectPromiseResponse { bool noop = 1; - Promise promise = 2; + promise_t.Promise promise = 2; +} + +message CancelPromiseRequest { + string id = 1; + string idempotencyKey = 2; + bool strict = 3; + promise_t.Value value = 4; + string requestId = 5; +} + +message CancelPromiseResponse { + bool noop = 1; + promise_t.Promise promise = 2; } diff --git a/internal/app/subsystems/api/grpc/api/promise_grpc.pb.go b/internal/app/subsystems/api/grpc/pb/promise_grpc.pb.go similarity index 72% rename from internal/app/subsystems/api/grpc/api/promise_grpc.pb.go rename to internal/app/subsystems/api/grpc/pb/promise_grpc.pb.go index 670bb656..4119f909 100644 --- a/internal/app/subsystems/api/grpc/api/promise_grpc.pb.go +++ b/internal/app/subsystems/api/grpc/pb/promise_grpc.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-grpc v1.3.0 // - protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/promise.proto +// source: internal/app/subsystems/api/grpc/pb/promise.proto -package api +package pb import ( context "context" @@ -19,12 +19,14 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - Promises_ReadPromise_FullMethodName = "/promise.Promises/ReadPromise" - Promises_SearchPromises_FullMethodName = "/promise.Promises/SearchPromises" - Promises_CreatePromise_FullMethodName = "/promise.Promises/CreatePromise" - Promises_CancelPromise_FullMethodName = "/promise.Promises/CancelPromise" - Promises_ResolvePromise_FullMethodName = "/promise.Promises/ResolvePromise" - Promises_RejectPromise_FullMethodName = "/promise.Promises/RejectPromise" + Promises_ReadPromise_FullMethodName = "/promise.Promises/ReadPromise" + Promises_SearchPromises_FullMethodName = "/promise.Promises/SearchPromises" + Promises_CreatePromise_FullMethodName = "/promise.Promises/CreatePromise" + Promises_CreatePromiseAndTask_FullMethodName = "/promise.Promises/CreatePromiseAndTask" + Promises_CreatePromiseAndCallback_FullMethodName = "/promise.Promises/CreatePromiseAndCallback" + Promises_ResolvePromise_FullMethodName = "/promise.Promises/ResolvePromise" + Promises_RejectPromise_FullMethodName = "/promise.Promises/RejectPromise" + Promises_CancelPromise_FullMethodName = "/promise.Promises/CancelPromise" ) // PromisesClient is the client API for Promises service. @@ -34,9 +36,11 @@ type PromisesClient interface { ReadPromise(ctx context.Context, in *ReadPromiseRequest, opts ...grpc.CallOption) (*ReadPromiseResponse, error) SearchPromises(ctx context.Context, in *SearchPromisesRequest, opts ...grpc.CallOption) (*SearchPromisesResponse, error) CreatePromise(ctx context.Context, in *CreatePromiseRequest, opts ...grpc.CallOption) (*CreatePromiseResponse, error) - CancelPromise(ctx context.Context, in *CancelPromiseRequest, opts ...grpc.CallOption) (*CancelPromiseResponse, error) + CreatePromiseAndTask(ctx context.Context, in *CreatePromiseAndTaskRequest, opts ...grpc.CallOption) (*CreatePromiseAndTaskResponse, error) + CreatePromiseAndCallback(ctx context.Context, in *CreatePromiseAndCallbackRequest, opts ...grpc.CallOption) (*CreatePromiseAndCallbackResponse, error) ResolvePromise(ctx context.Context, in *ResolvePromiseRequest, opts ...grpc.CallOption) (*ResolvePromiseResponse, error) RejectPromise(ctx context.Context, in *RejectPromiseRequest, opts ...grpc.CallOption) (*RejectPromiseResponse, error) + CancelPromise(ctx context.Context, in *CancelPromiseRequest, opts ...grpc.CallOption) (*CancelPromiseResponse, error) } type promisesClient struct { @@ -74,9 +78,18 @@ func (c *promisesClient) CreatePromise(ctx context.Context, in *CreatePromiseReq return out, nil } -func (c *promisesClient) CancelPromise(ctx context.Context, in *CancelPromiseRequest, opts ...grpc.CallOption) (*CancelPromiseResponse, error) { - out := new(CancelPromiseResponse) - err := c.cc.Invoke(ctx, Promises_CancelPromise_FullMethodName, in, out, opts...) +func (c *promisesClient) CreatePromiseAndTask(ctx context.Context, in *CreatePromiseAndTaskRequest, opts ...grpc.CallOption) (*CreatePromiseAndTaskResponse, error) { + out := new(CreatePromiseAndTaskResponse) + err := c.cc.Invoke(ctx, Promises_CreatePromiseAndTask_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *promisesClient) CreatePromiseAndCallback(ctx context.Context, in *CreatePromiseAndCallbackRequest, opts ...grpc.CallOption) (*CreatePromiseAndCallbackResponse, error) { + out := new(CreatePromiseAndCallbackResponse) + err := c.cc.Invoke(ctx, Promises_CreatePromiseAndCallback_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -101,6 +114,15 @@ func (c *promisesClient) RejectPromise(ctx context.Context, in *RejectPromiseReq return out, nil } +func (c *promisesClient) CancelPromise(ctx context.Context, in *CancelPromiseRequest, opts ...grpc.CallOption) (*CancelPromiseResponse, error) { + out := new(CancelPromiseResponse) + err := c.cc.Invoke(ctx, Promises_CancelPromise_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // PromisesServer is the server API for Promises service. // All implementations must embed UnimplementedPromisesServer // for forward compatibility @@ -108,9 +130,11 @@ type PromisesServer interface { ReadPromise(context.Context, *ReadPromiseRequest) (*ReadPromiseResponse, error) SearchPromises(context.Context, *SearchPromisesRequest) (*SearchPromisesResponse, error) CreatePromise(context.Context, *CreatePromiseRequest) (*CreatePromiseResponse, error) - CancelPromise(context.Context, *CancelPromiseRequest) (*CancelPromiseResponse, error) + CreatePromiseAndTask(context.Context, *CreatePromiseAndTaskRequest) (*CreatePromiseAndTaskResponse, error) + CreatePromiseAndCallback(context.Context, *CreatePromiseAndCallbackRequest) (*CreatePromiseAndCallbackResponse, error) ResolvePromise(context.Context, *ResolvePromiseRequest) (*ResolvePromiseResponse, error) RejectPromise(context.Context, *RejectPromiseRequest) (*RejectPromiseResponse, error) + CancelPromise(context.Context, *CancelPromiseRequest) (*CancelPromiseResponse, error) mustEmbedUnimplementedPromisesServer() } @@ -127,8 +151,11 @@ func (UnimplementedPromisesServer) SearchPromises(context.Context, *SearchPromis func (UnimplementedPromisesServer) CreatePromise(context.Context, *CreatePromiseRequest) (*CreatePromiseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreatePromise not implemented") } -func (UnimplementedPromisesServer) CancelPromise(context.Context, *CancelPromiseRequest) (*CancelPromiseResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CancelPromise not implemented") +func (UnimplementedPromisesServer) CreatePromiseAndTask(context.Context, *CreatePromiseAndTaskRequest) (*CreatePromiseAndTaskResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePromiseAndTask not implemented") +} +func (UnimplementedPromisesServer) CreatePromiseAndCallback(context.Context, *CreatePromiseAndCallbackRequest) (*CreatePromiseAndCallbackResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePromiseAndCallback not implemented") } func (UnimplementedPromisesServer) ResolvePromise(context.Context, *ResolvePromiseRequest) (*ResolvePromiseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ResolvePromise not implemented") @@ -136,6 +163,9 @@ func (UnimplementedPromisesServer) ResolvePromise(context.Context, *ResolvePromi func (UnimplementedPromisesServer) RejectPromise(context.Context, *RejectPromiseRequest) (*RejectPromiseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RejectPromise not implemented") } +func (UnimplementedPromisesServer) CancelPromise(context.Context, *CancelPromiseRequest) (*CancelPromiseResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CancelPromise not implemented") +} func (UnimplementedPromisesServer) mustEmbedUnimplementedPromisesServer() {} // UnsafePromisesServer may be embedded to opt out of forward compatibility for this service. @@ -203,20 +233,38 @@ func _Promises_CreatePromise_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _Promises_CancelPromise_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CancelPromiseRequest) +func _Promises_CreatePromiseAndTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreatePromiseAndTaskRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(PromisesServer).CancelPromise(ctx, in) + return srv.(PromisesServer).CreatePromiseAndTask(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Promises_CancelPromise_FullMethodName, + FullMethod: Promises_CreatePromiseAndTask_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PromisesServer).CancelPromise(ctx, req.(*CancelPromiseRequest)) + return srv.(PromisesServer).CreatePromiseAndTask(ctx, req.(*CreatePromiseAndTaskRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Promises_CreatePromiseAndCallback_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreatePromiseAndCallbackRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PromisesServer).CreatePromiseAndCallback(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Promises_CreatePromiseAndCallback_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PromisesServer).CreatePromiseAndCallback(ctx, req.(*CreatePromiseAndCallbackRequest)) } return interceptor(ctx, in, info, handler) } @@ -257,6 +305,24 @@ func _Promises_RejectPromise_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Promises_CancelPromise_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CancelPromiseRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PromisesServer).CancelPromise(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Promises_CancelPromise_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PromisesServer).CancelPromise(ctx, req.(*CancelPromiseRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Promises_ServiceDesc is the grpc.ServiceDesc for Promises service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -277,8 +343,12 @@ var Promises_ServiceDesc = grpc.ServiceDesc{ Handler: _Promises_CreatePromise_Handler, }, { - MethodName: "CancelPromise", - Handler: _Promises_CancelPromise_Handler, + MethodName: "CreatePromiseAndTask", + Handler: _Promises_CreatePromiseAndTask_Handler, + }, + { + MethodName: "CreatePromiseAndCallback", + Handler: _Promises_CreatePromiseAndCallback_Handler, }, { MethodName: "ResolvePromise", @@ -288,7 +358,11 @@ var Promises_ServiceDesc = grpc.ServiceDesc{ MethodName: "RejectPromise", Handler: _Promises_RejectPromise_Handler, }, + { + MethodName: "CancelPromise", + Handler: _Promises_CancelPromise_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "internal/app/subsystems/api/grpc/api/promise.proto", + Metadata: "internal/app/subsystems/api/grpc/pb/promise.proto", } diff --git a/internal/app/subsystems/api/grpc/pb/promise_t.pb.go b/internal/app/subsystems/api/grpc/pb/promise_t.pb.go new file mode 100644 index 00000000..e5c35d6b --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/promise_t.pb.go @@ -0,0 +1,395 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.3 +// source: internal/app/subsystems/api/grpc/pb/promise_t.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type State int32 + +const ( + State_PENDING State = 0 + State_RESOLVED State = 1 + State_REJECTED State = 2 + State_REJECTED_TIMEDOUT State = 3 + State_REJECTED_CANCELED State = 4 +) + +// Enum value maps for State. +var ( + State_name = map[int32]string{ + 0: "PENDING", + 1: "RESOLVED", + 2: "REJECTED", + 3: "REJECTED_TIMEDOUT", + 4: "REJECTED_CANCELED", + } + State_value = map[string]int32{ + "PENDING": 0, + "RESOLVED": 1, + "REJECTED": 2, + "REJECTED_TIMEDOUT": 3, + "REJECTED_CANCELED": 4, + } +) + +func (x State) Enum() *State { + p := new(State) + *p = x + return p +} + +func (x State) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (State) Descriptor() protoreflect.EnumDescriptor { + return file_internal_app_subsystems_api_grpc_pb_promise_t_proto_enumTypes[0].Descriptor() +} + +func (State) Type() protoreflect.EnumType { + return &file_internal_app_subsystems_api_grpc_pb_promise_t_proto_enumTypes[0] +} + +func (x State) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use State.Descriptor instead. +func (State) EnumDescriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescGZIP(), []int{0} +} + +type Promise struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + State State `protobuf:"varint,2,opt,name=state,proto3,enum=promise_t.State" json:"state,omitempty"` + Param *Value `protobuf:"bytes,3,opt,name=param,proto3" json:"param,omitempty"` + Value *Value `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` + Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` + IdempotencyKeyForCreate string `protobuf:"bytes,6,opt,name=idempotencyKeyForCreate,proto3" json:"idempotencyKeyForCreate,omitempty"` + IdempotencyKeyForComplete string `protobuf:"bytes,7,opt,name=idempotencyKeyForComplete,proto3" json:"idempotencyKeyForComplete,omitempty"` + Tags map[string]string `protobuf:"bytes,8,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + CreatedOn int64 `protobuf:"varint,9,opt,name=createdOn,proto3" json:"createdOn,omitempty"` + CompletedOn int64 `protobuf:"varint,10,opt,name=completedOn,proto3" json:"completedOn,omitempty"` +} + +func (x *Promise) Reset() { + *x = Promise{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_t_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Promise) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Promise) ProtoMessage() {} + +func (x *Promise) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_t_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Promise.ProtoReflect.Descriptor instead. +func (*Promise) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescGZIP(), []int{0} +} + +func (x *Promise) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Promise) GetState() State { + if x != nil { + return x.State + } + return State_PENDING +} + +func (x *Promise) GetParam() *Value { + if x != nil { + return x.Param + } + return nil +} + +func (x *Promise) GetValue() *Value { + if x != nil { + return x.Value + } + return nil +} + +func (x *Promise) GetTimeout() int64 { + if x != nil { + return x.Timeout + } + return 0 +} + +func (x *Promise) GetIdempotencyKeyForCreate() string { + if x != nil { + return x.IdempotencyKeyForCreate + } + return "" +} + +func (x *Promise) GetIdempotencyKeyForComplete() string { + if x != nil { + return x.IdempotencyKeyForComplete + } + return "" +} + +func (x *Promise) GetTags() map[string]string { + if x != nil { + return x.Tags + } + return nil +} + +func (x *Promise) GetCreatedOn() int64 { + if x != nil { + return x.CreatedOn + } + return 0 +} + +func (x *Promise) GetCompletedOn() int64 { + if x != nil { + return x.CompletedOn + } + return 0 +} + +type Value struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *Value) Reset() { + *x = Value{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_t_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Value) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Value) ProtoMessage() {} + +func (x *Value) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_promise_t_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Value.ProtoReflect.Descriptor instead. +func (*Value) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescGZIP(), []int{1} +} + +func (x *Value) GetHeaders() map[string]string { + if x != nil { + return x.Headers + } + return nil +} + +func (x *Value) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +var File_internal_app_subsystems_api_grpc_pb_promise_t_proto protoreflect.FileDescriptor + +var file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDesc = []byte{ + 0x0a, 0x33, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, + 0x22, 0xce, 0x03, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x05, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x26, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x38, + 0x0a, 0x17, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, + 0x46, 0x6f, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x17, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x46, + 0x6f, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x19, 0x69, 0x64, 0x65, 0x6d, + 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x43, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x19, 0x69, 0x64, 0x65, + 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x46, 0x6f, 0x72, 0x43, 0x6f, + 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x08, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, + 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, + 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x63, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x22, 0x90, 0x01, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x68, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x5e, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, + 0x07, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, + 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x4a, 0x45, + 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, + 0x45, 0x44, 0x5f, 0x54, 0x49, 0x4d, 0x45, 0x44, 0x4f, 0x55, 0x54, 0x10, 0x03, 0x12, 0x15, 0x0a, + 0x11, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, + 0x45, 0x44, 0x10, 0x04, 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, + 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, + 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescOnce sync.Once + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescData = file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDesc +) + +func file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescGZIP() []byte { + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescOnce.Do(func() { + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescData) + }) + return file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDescData +} + +var file_internal_app_subsystems_api_grpc_pb_promise_t_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_internal_app_subsystems_api_grpc_pb_promise_t_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_internal_app_subsystems_api_grpc_pb_promise_t_proto_goTypes = []interface{}{ + (State)(0), // 0: promise_t.State + (*Promise)(nil), // 1: promise_t.Promise + (*Value)(nil), // 2: promise_t.Value + nil, // 3: promise_t.Promise.TagsEntry + nil, // 4: promise_t.Value.HeadersEntry +} +var file_internal_app_subsystems_api_grpc_pb_promise_t_proto_depIdxs = []int32{ + 0, // 0: promise_t.Promise.state:type_name -> promise_t.State + 2, // 1: promise_t.Promise.param:type_name -> promise_t.Value + 2, // 2: promise_t.Promise.value:type_name -> promise_t.Value + 3, // 3: promise_t.Promise.tags:type_name -> promise_t.Promise.TagsEntry + 4, // 4: promise_t.Value.headers:type_name -> promise_t.Value.HeadersEntry + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_internal_app_subsystems_api_grpc_pb_promise_t_proto_init() } +func file_internal_app_subsystems_api_grpc_pb_promise_t_proto_init() { + if File_internal_app_subsystems_api_grpc_pb_promise_t_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Promise); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Value); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDesc, + NumEnums: 1, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_internal_app_subsystems_api_grpc_pb_promise_t_proto_goTypes, + DependencyIndexes: file_internal_app_subsystems_api_grpc_pb_promise_t_proto_depIdxs, + EnumInfos: file_internal_app_subsystems_api_grpc_pb_promise_t_proto_enumTypes, + MessageInfos: file_internal_app_subsystems_api_grpc_pb_promise_t_proto_msgTypes, + }.Build() + File_internal_app_subsystems_api_grpc_pb_promise_t_proto = out.File + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_rawDesc = nil + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_goTypes = nil + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_depIdxs = nil +} diff --git a/internal/app/subsystems/api/grpc/pb/promise_t.proto b/internal/app/subsystems/api/grpc/pb/promise_t.proto new file mode 100644 index 00000000..b0e4ac15 --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/promise_t.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package promise_t; + +option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb"; + +message Promise { + string id = 1; + State state = 2; + Value param = 3; + Value value = 4; + int64 timeout = 5; + string idempotencyKeyForCreate = 6; + string idempotencyKeyForComplete = 7; + map tags = 8; + int64 createdOn = 9; + int64 completedOn = 10; +} + +enum State { + PENDING = 0; + RESOLVED = 1; + REJECTED = 2; + REJECTED_TIMEDOUT = 3; + REJECTED_CANCELED = 4; +} + +message Value { + map headers = 1; + bytes data = 2; +} diff --git a/internal/app/subsystems/api/grpc/pb/schedule.pb.go b/internal/app/subsystems/api/grpc/pb/schedule.pb.go new file mode 100644 index 00000000..7ee1a30b --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/schedule.pb.go @@ -0,0 +1,821 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.3 +// source: internal/app/subsystems/api/grpc/pb/schedule.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type CreateScheduleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Cron string `protobuf:"bytes,3,opt,name=cron,proto3" json:"cron,omitempty"` + Tags map[string]string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + PromiseId string `protobuf:"bytes,5,opt,name=promiseId,proto3" json:"promiseId,omitempty"` + PromiseTimeout int64 `protobuf:"varint,6,opt,name=promiseTimeout,proto3" json:"promiseTimeout,omitempty"` + PromiseParam *Value `protobuf:"bytes,7,opt,name=promiseParam,proto3" json:"promiseParam,omitempty"` + PromiseTags map[string]string `protobuf:"bytes,8,rep,name=promiseTags,proto3" json:"promiseTags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + IdempotencyKey string `protobuf:"bytes,9,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + RequestId string `protobuf:"bytes,10,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *CreateScheduleRequest) Reset() { + *x = CreateScheduleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateScheduleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateScheduleRequest) ProtoMessage() {} + +func (x *CreateScheduleRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateScheduleRequest.ProtoReflect.Descriptor instead. +func (*CreateScheduleRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateScheduleRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CreateScheduleRequest) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *CreateScheduleRequest) GetCron() string { + if x != nil { + return x.Cron + } + return "" +} + +func (x *CreateScheduleRequest) GetTags() map[string]string { + if x != nil { + return x.Tags + } + return nil +} + +func (x *CreateScheduleRequest) GetPromiseId() string { + if x != nil { + return x.PromiseId + } + return "" +} + +func (x *CreateScheduleRequest) GetPromiseTimeout() int64 { + if x != nil { + return x.PromiseTimeout + } + return 0 +} + +func (x *CreateScheduleRequest) GetPromiseParam() *Value { + if x != nil { + return x.PromiseParam + } + return nil +} + +func (x *CreateScheduleRequest) GetPromiseTags() map[string]string { + if x != nil { + return x.PromiseTags + } + return nil +} + +func (x *CreateScheduleRequest) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + +func (x *CreateScheduleRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type CreatedScheduleResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Noop bool `protobuf:"varint,1,opt,name=noop,proto3" json:"noop,omitempty"` + Schedule *Schedule `protobuf:"bytes,2,opt,name=schedule,proto3" json:"schedule,omitempty"` +} + +func (x *CreatedScheduleResponse) Reset() { + *x = CreatedScheduleResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreatedScheduleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatedScheduleResponse) ProtoMessage() {} + +func (x *CreatedScheduleResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreatedScheduleResponse.ProtoReflect.Descriptor instead. +func (*CreatedScheduleResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescGZIP(), []int{1} +} + +func (x *CreatedScheduleResponse) GetNoop() bool { + if x != nil { + return x.Noop + } + return false +} + +func (x *CreatedScheduleResponse) GetSchedule() *Schedule { + if x != nil { + return x.Schedule + } + return nil +} + +type ReadScheduleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *ReadScheduleRequest) Reset() { + *x = ReadScheduleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadScheduleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadScheduleRequest) ProtoMessage() {} + +func (x *ReadScheduleRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadScheduleRequest.ProtoReflect.Descriptor instead. +func (*ReadScheduleRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescGZIP(), []int{2} +} + +func (x *ReadScheduleRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *ReadScheduleRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type ReadScheduleResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Schedule *Schedule `protobuf:"bytes,1,opt,name=schedule,proto3" json:"schedule,omitempty"` +} + +func (x *ReadScheduleResponse) Reset() { + *x = ReadScheduleResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadScheduleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadScheduleResponse) ProtoMessage() {} + +func (x *ReadScheduleResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadScheduleResponse.ProtoReflect.Descriptor instead. +func (*ReadScheduleResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescGZIP(), []int{3} +} + +func (x *ReadScheduleResponse) GetSchedule() *Schedule { + if x != nil { + return x.Schedule + } + return nil +} + +type SearchSchedulesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Tags map[string]string `protobuf:"bytes,2,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Limit int32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` + Cursor string `protobuf:"bytes,4,opt,name=cursor,proto3" json:"cursor,omitempty"` + RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *SearchSchedulesRequest) Reset() { + *x = SearchSchedulesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchSchedulesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchSchedulesRequest) ProtoMessage() {} + +func (x *SearchSchedulesRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SearchSchedulesRequest.ProtoReflect.Descriptor instead. +func (*SearchSchedulesRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescGZIP(), []int{4} +} + +func (x *SearchSchedulesRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *SearchSchedulesRequest) GetTags() map[string]string { + if x != nil { + return x.Tags + } + return nil +} + +func (x *SearchSchedulesRequest) GetLimit() int32 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *SearchSchedulesRequest) GetCursor() string { + if x != nil { + return x.Cursor + } + return "" +} + +func (x *SearchSchedulesRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type SearchSchedulesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Schedules []*Schedule `protobuf:"bytes,1,rep,name=schedules,proto3" json:"schedules,omitempty"` + Cursor string `protobuf:"bytes,2,opt,name=cursor,proto3" json:"cursor,omitempty"` +} + +func (x *SearchSchedulesResponse) Reset() { + *x = SearchSchedulesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SearchSchedulesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SearchSchedulesResponse) ProtoMessage() {} + +func (x *SearchSchedulesResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SearchSchedulesResponse.ProtoReflect.Descriptor instead. +func (*SearchSchedulesResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescGZIP(), []int{5} +} + +func (x *SearchSchedulesResponse) GetSchedules() []*Schedule { + if x != nil { + return x.Schedules + } + return nil +} + +func (x *SearchSchedulesResponse) GetCursor() string { + if x != nil { + return x.Cursor + } + return "" +} + +type DeleteScheduleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *DeleteScheduleRequest) Reset() { + *x = DeleteScheduleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteScheduleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteScheduleRequest) ProtoMessage() {} + +func (x *DeleteScheduleRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteScheduleRequest.ProtoReflect.Descriptor instead. +func (*DeleteScheduleRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescGZIP(), []int{6} +} + +func (x *DeleteScheduleRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DeleteScheduleRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type DeleteScheduleResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DeleteScheduleResponse) Reset() { + *x = DeleteScheduleResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteScheduleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteScheduleResponse) ProtoMessage() {} + +func (x *DeleteScheduleResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteScheduleResponse.ProtoReflect.Descriptor instead. +func (*DeleteScheduleResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescGZIP(), []int{7} +} + +var File_internal_app_subsystems_api_grpc_pb_schedule_proto protoreflect.FileDescriptor + +var file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDesc = []byte{ + 0x0a, 0x32, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x1a, 0x33, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, + 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, + 0x2f, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x34, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, + 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, + 0x65, 0x5f, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xab, 0x04, 0x0a, 0x15, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x12, 0x3d, 0x0a, 0x04, 0x74, 0x61, 0x67, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, + 0x6c, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6d, + 0x69, 0x73, 0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, + 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x34, + 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, + 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x12, 0x52, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, + 0x61, 0x67, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x73, 0x63, 0x68, 0x65, + 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, + 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x70, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, + 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, + 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x1a, 0x37, + 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x6d, 0x69, + 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x5f, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x64, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x04, 0x6e, 0x6f, 0x6f, 0x70, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, + 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, + 0x75, 0x6c, 0x65, 0x5f, 0x74, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x08, + 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x43, 0x0a, 0x13, 0x52, 0x65, 0x61, 0x64, + 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x48, 0x0a, + 0x14, 0x52, 0x65, 0x61, 0x64, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, + 0x6c, 0x65, 0x5f, 0x74, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x08, 0x73, + 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x22, 0xed, 0x01, 0x0a, 0x16, 0x53, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x3e, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x2a, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, + 0x67, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, + 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, + 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x1a, 0x37, + 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x65, 0x0a, 0x17, 0x53, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, + 0x5f, 0x74, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x09, 0x73, 0x63, 0x68, + 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x22, 0x45, + 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, + 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, + 0xe5, 0x02, 0x0a, 0x09, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x4f, 0x0a, + 0x0c, 0x52, 0x65, 0x61, 0x64, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1d, 0x2e, + 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x53, 0x63, 0x68, + 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x73, + 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x53, 0x63, 0x68, 0x65, + 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, + 0x0a, 0x0f, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, + 0x73, 0x12, 0x20, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x53, 0x65, 0x61, + 0x72, 0x63, 0x68, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x53, + 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1f, 0x2e, 0x73, 0x63, 0x68, + 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, + 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x63, + 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x63, + 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x55, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, + 0x6c, 0x65, 0x12, 0x1f, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, + 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, + 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescOnce sync.Once + file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescData = file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDesc +) + +func file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescGZIP() []byte { + file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescOnce.Do(func() { + file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescData) + }) + return file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDescData +} + +var file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_internal_app_subsystems_api_grpc_pb_schedule_proto_goTypes = []interface{}{ + (*CreateScheduleRequest)(nil), // 0: schedule.CreateScheduleRequest + (*CreatedScheduleResponse)(nil), // 1: schedule.CreatedScheduleResponse + (*ReadScheduleRequest)(nil), // 2: schedule.ReadScheduleRequest + (*ReadScheduleResponse)(nil), // 3: schedule.ReadScheduleResponse + (*SearchSchedulesRequest)(nil), // 4: schedule.SearchSchedulesRequest + (*SearchSchedulesResponse)(nil), // 5: schedule.SearchSchedulesResponse + (*DeleteScheduleRequest)(nil), // 6: schedule.DeleteScheduleRequest + (*DeleteScheduleResponse)(nil), // 7: schedule.DeleteScheduleResponse + nil, // 8: schedule.CreateScheduleRequest.TagsEntry + nil, // 9: schedule.CreateScheduleRequest.PromiseTagsEntry + nil, // 10: schedule.SearchSchedulesRequest.TagsEntry + (*Value)(nil), // 11: promise_t.Value + (*Schedule)(nil), // 12: schedule_t.Schedule +} +var file_internal_app_subsystems_api_grpc_pb_schedule_proto_depIdxs = []int32{ + 8, // 0: schedule.CreateScheduleRequest.tags:type_name -> schedule.CreateScheduleRequest.TagsEntry + 11, // 1: schedule.CreateScheduleRequest.promiseParam:type_name -> promise_t.Value + 9, // 2: schedule.CreateScheduleRequest.promiseTags:type_name -> schedule.CreateScheduleRequest.PromiseTagsEntry + 12, // 3: schedule.CreatedScheduleResponse.schedule:type_name -> schedule_t.Schedule + 12, // 4: schedule.ReadScheduleResponse.schedule:type_name -> schedule_t.Schedule + 10, // 5: schedule.SearchSchedulesRequest.tags:type_name -> schedule.SearchSchedulesRequest.TagsEntry + 12, // 6: schedule.SearchSchedulesResponse.schedules:type_name -> schedule_t.Schedule + 2, // 7: schedule.Schedules.ReadSchedule:input_type -> schedule.ReadScheduleRequest + 4, // 8: schedule.Schedules.SearchSchedules:input_type -> schedule.SearchSchedulesRequest + 0, // 9: schedule.Schedules.CreateSchedule:input_type -> schedule.CreateScheduleRequest + 6, // 10: schedule.Schedules.DeleteSchedule:input_type -> schedule.DeleteScheduleRequest + 3, // 11: schedule.Schedules.ReadSchedule:output_type -> schedule.ReadScheduleResponse + 5, // 12: schedule.Schedules.SearchSchedules:output_type -> schedule.SearchSchedulesResponse + 1, // 13: schedule.Schedules.CreateSchedule:output_type -> schedule.CreatedScheduleResponse + 7, // 14: schedule.Schedules.DeleteSchedule:output_type -> schedule.DeleteScheduleResponse + 11, // [11:15] is the sub-list for method output_type + 7, // [7:11] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_internal_app_subsystems_api_grpc_pb_schedule_proto_init() } +func file_internal_app_subsystems_api_grpc_pb_schedule_proto_init() { + if File_internal_app_subsystems_api_grpc_pb_schedule_proto != nil { + return + } + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_init() + file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_init() + if !protoimpl.UnsafeEnabled { + file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateScheduleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreatedScheduleResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadScheduleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadScheduleResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchSchedulesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SearchSchedulesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteScheduleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteScheduleResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDesc, + NumEnums: 0, + NumMessages: 11, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_internal_app_subsystems_api_grpc_pb_schedule_proto_goTypes, + DependencyIndexes: file_internal_app_subsystems_api_grpc_pb_schedule_proto_depIdxs, + MessageInfos: file_internal_app_subsystems_api_grpc_pb_schedule_proto_msgTypes, + }.Build() + File_internal_app_subsystems_api_grpc_pb_schedule_proto = out.File + file_internal_app_subsystems_api_grpc_pb_schedule_proto_rawDesc = nil + file_internal_app_subsystems_api_grpc_pb_schedule_proto_goTypes = nil + file_internal_app_subsystems_api_grpc_pb_schedule_proto_depIdxs = nil +} diff --git a/internal/app/subsystems/api/grpc/api/schedule.proto b/internal/app/subsystems/api/grpc/pb/schedule.proto similarity index 67% rename from internal/app/subsystems/api/grpc/api/schedule.proto rename to internal/app/subsystems/api/grpc/pb/schedule.proto index db6202fa..a12f922f 100644 --- a/internal/app/subsystems/api/grpc/api/schedule.proto +++ b/internal/app/subsystems/api/grpc/pb/schedule.proto @@ -2,32 +2,18 @@ syntax = "proto3"; package schedule; -import "internal/app/subsystems/api/grpc/api/promise.proto"; +import "internal/app/subsystems/api/grpc/pb/promise_t.proto"; +import "internal/app/subsystems/api/grpc/pb/schedule_t.proto"; -option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api"; +option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb"; service Schedules { - rpc CreateSchedule (CreateScheduleRequest) returns (CreatedScheduleResponse) {} rpc ReadSchedule (ReadScheduleRequest) returns (ReadScheduleResponse) {} rpc SearchSchedules (SearchSchedulesRequest) returns (SearchSchedulesResponse) {} + rpc CreateSchedule (CreateScheduleRequest) returns (CreatedScheduleResponse) {} rpc DeleteSchedule (DeleteScheduleRequest) returns (DeleteScheduleResponse) {} } -message Schedule { - string id = 1; - string description = 2; - string cron = 3; - map tags = 4; - string promiseId = 5; - int64 promiseTimeout = 6; - promise.Value promiseParam = 7; - map promiseTags = 8; - string idempotencyKey = 9; - int64 lastRunTime = 10; - int64 nextRunTime = 11; - int64 createdOn = 12; -} - // CREATE message CreateScheduleRequest { @@ -37,7 +23,7 @@ message CreateScheduleRequest { map tags = 4; string promiseId = 5; int64 promiseTimeout = 6; - promise.Value promiseParam = 7; + promise_t.Value promiseParam = 7; map promiseTags = 8; string idempotencyKey = 9; string requestId = 10; @@ -45,7 +31,7 @@ message CreateScheduleRequest { message CreatedScheduleResponse { bool noop = 1; - Schedule schedule = 2; + schedule_t.Schedule schedule = 2; } // READ @@ -56,7 +42,7 @@ message ReadScheduleRequest { } message ReadScheduleResponse { - Schedule schedule = 1; + schedule_t.Schedule schedule = 1; } // SEARCH @@ -70,8 +56,8 @@ message SearchSchedulesRequest { } message SearchSchedulesResponse { - string cursor = 1; - repeated Schedule schedules = 2; + repeated schedule_t.Schedule schedules = 1; + string cursor = 2; } // DELETE diff --git a/internal/app/subsystems/api/grpc/api/schedule_grpc.pb.go b/internal/app/subsystems/api/grpc/pb/schedule_grpc.pb.go similarity index 98% rename from internal/app/subsystems/api/grpc/api/schedule_grpc.pb.go rename to internal/app/subsystems/api/grpc/pb/schedule_grpc.pb.go index 1cca6ab3..a555e611 100644 --- a/internal/app/subsystems/api/grpc/api/schedule_grpc.pb.go +++ b/internal/app/subsystems/api/grpc/pb/schedule_grpc.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-grpc v1.3.0 // - protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/schedule.proto +// source: internal/app/subsystems/api/grpc/pb/schedule.proto -package api +package pb import ( context "context" @@ -19,9 +19,9 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - Schedules_CreateSchedule_FullMethodName = "/schedule.Schedules/CreateSchedule" Schedules_ReadSchedule_FullMethodName = "/schedule.Schedules/ReadSchedule" Schedules_SearchSchedules_FullMethodName = "/schedule.Schedules/SearchSchedules" + Schedules_CreateSchedule_FullMethodName = "/schedule.Schedules/CreateSchedule" Schedules_DeleteSchedule_FullMethodName = "/schedule.Schedules/DeleteSchedule" ) @@ -29,9 +29,9 @@ const ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type SchedulesClient interface { - CreateSchedule(ctx context.Context, in *CreateScheduleRequest, opts ...grpc.CallOption) (*CreatedScheduleResponse, error) ReadSchedule(ctx context.Context, in *ReadScheduleRequest, opts ...grpc.CallOption) (*ReadScheduleResponse, error) SearchSchedules(ctx context.Context, in *SearchSchedulesRequest, opts ...grpc.CallOption) (*SearchSchedulesResponse, error) + CreateSchedule(ctx context.Context, in *CreateScheduleRequest, opts ...grpc.CallOption) (*CreatedScheduleResponse, error) DeleteSchedule(ctx context.Context, in *DeleteScheduleRequest, opts ...grpc.CallOption) (*DeleteScheduleResponse, error) } @@ -43,15 +43,6 @@ func NewSchedulesClient(cc grpc.ClientConnInterface) SchedulesClient { return &schedulesClient{cc} } -func (c *schedulesClient) CreateSchedule(ctx context.Context, in *CreateScheduleRequest, opts ...grpc.CallOption) (*CreatedScheduleResponse, error) { - out := new(CreatedScheduleResponse) - err := c.cc.Invoke(ctx, Schedules_CreateSchedule_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *schedulesClient) ReadSchedule(ctx context.Context, in *ReadScheduleRequest, opts ...grpc.CallOption) (*ReadScheduleResponse, error) { out := new(ReadScheduleResponse) err := c.cc.Invoke(ctx, Schedules_ReadSchedule_FullMethodName, in, out, opts...) @@ -70,6 +61,15 @@ func (c *schedulesClient) SearchSchedules(ctx context.Context, in *SearchSchedul return out, nil } +func (c *schedulesClient) CreateSchedule(ctx context.Context, in *CreateScheduleRequest, opts ...grpc.CallOption) (*CreatedScheduleResponse, error) { + out := new(CreatedScheduleResponse) + err := c.cc.Invoke(ctx, Schedules_CreateSchedule_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *schedulesClient) DeleteSchedule(ctx context.Context, in *DeleteScheduleRequest, opts ...grpc.CallOption) (*DeleteScheduleResponse, error) { out := new(DeleteScheduleResponse) err := c.cc.Invoke(ctx, Schedules_DeleteSchedule_FullMethodName, in, out, opts...) @@ -83,9 +83,9 @@ func (c *schedulesClient) DeleteSchedule(ctx context.Context, in *DeleteSchedule // All implementations must embed UnimplementedSchedulesServer // for forward compatibility type SchedulesServer interface { - CreateSchedule(context.Context, *CreateScheduleRequest) (*CreatedScheduleResponse, error) ReadSchedule(context.Context, *ReadScheduleRequest) (*ReadScheduleResponse, error) SearchSchedules(context.Context, *SearchSchedulesRequest) (*SearchSchedulesResponse, error) + CreateSchedule(context.Context, *CreateScheduleRequest) (*CreatedScheduleResponse, error) DeleteSchedule(context.Context, *DeleteScheduleRequest) (*DeleteScheduleResponse, error) mustEmbedUnimplementedSchedulesServer() } @@ -94,15 +94,15 @@ type SchedulesServer interface { type UnimplementedSchedulesServer struct { } -func (UnimplementedSchedulesServer) CreateSchedule(context.Context, *CreateScheduleRequest) (*CreatedScheduleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateSchedule not implemented") -} func (UnimplementedSchedulesServer) ReadSchedule(context.Context, *ReadScheduleRequest) (*ReadScheduleResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ReadSchedule not implemented") } func (UnimplementedSchedulesServer) SearchSchedules(context.Context, *SearchSchedulesRequest) (*SearchSchedulesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SearchSchedules not implemented") } +func (UnimplementedSchedulesServer) CreateSchedule(context.Context, *CreateScheduleRequest) (*CreatedScheduleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateSchedule not implemented") +} func (UnimplementedSchedulesServer) DeleteSchedule(context.Context, *DeleteScheduleRequest) (*DeleteScheduleResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteSchedule not implemented") } @@ -119,56 +119,56 @@ func RegisterSchedulesServer(s grpc.ServiceRegistrar, srv SchedulesServer) { s.RegisterService(&Schedules_ServiceDesc, srv) } -func _Schedules_CreateSchedule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateScheduleRequest) +func _Schedules_ReadSchedule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReadScheduleRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(SchedulesServer).CreateSchedule(ctx, in) + return srv.(SchedulesServer).ReadSchedule(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Schedules_CreateSchedule_FullMethodName, + FullMethod: Schedules_ReadSchedule_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SchedulesServer).CreateSchedule(ctx, req.(*CreateScheduleRequest)) + return srv.(SchedulesServer).ReadSchedule(ctx, req.(*ReadScheduleRequest)) } return interceptor(ctx, in, info, handler) } -func _Schedules_ReadSchedule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ReadScheduleRequest) +func _Schedules_SearchSchedules_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SearchSchedulesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(SchedulesServer).ReadSchedule(ctx, in) + return srv.(SchedulesServer).SearchSchedules(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Schedules_ReadSchedule_FullMethodName, + FullMethod: Schedules_SearchSchedules_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SchedulesServer).ReadSchedule(ctx, req.(*ReadScheduleRequest)) + return srv.(SchedulesServer).SearchSchedules(ctx, req.(*SearchSchedulesRequest)) } return interceptor(ctx, in, info, handler) } -func _Schedules_SearchSchedules_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SearchSchedulesRequest) +func _Schedules_CreateSchedule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateScheduleRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(SchedulesServer).SearchSchedules(ctx, in) + return srv.(SchedulesServer).CreateSchedule(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Schedules_SearchSchedules_FullMethodName, + FullMethod: Schedules_CreateSchedule_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SchedulesServer).SearchSchedules(ctx, req.(*SearchSchedulesRequest)) + return srv.(SchedulesServer).CreateSchedule(ctx, req.(*CreateScheduleRequest)) } return interceptor(ctx, in, info, handler) } @@ -198,10 +198,6 @@ var Schedules_ServiceDesc = grpc.ServiceDesc{ ServiceName: "schedule.Schedules", HandlerType: (*SchedulesServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "CreateSchedule", - Handler: _Schedules_CreateSchedule_Handler, - }, { MethodName: "ReadSchedule", Handler: _Schedules_ReadSchedule_Handler, @@ -210,11 +206,15 @@ var Schedules_ServiceDesc = grpc.ServiceDesc{ MethodName: "SearchSchedules", Handler: _Schedules_SearchSchedules_Handler, }, + { + MethodName: "CreateSchedule", + Handler: _Schedules_CreateSchedule_Handler, + }, { MethodName: "DeleteSchedule", Handler: _Schedules_DeleteSchedule_Handler, }, }, Streams: []grpc.StreamDesc{}, - Metadata: "internal/app/subsystems/api/grpc/api/schedule.proto", + Metadata: "internal/app/subsystems/api/grpc/pb/schedule.proto", } diff --git a/internal/app/subsystems/api/grpc/pb/schedule_t.pb.go b/internal/app/subsystems/api/grpc/pb/schedule_t.pb.go new file mode 100644 index 00000000..fd81abc4 --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/schedule_t.pb.go @@ -0,0 +1,281 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.3 +// source: internal/app/subsystems/api/grpc/pb/schedule_t.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Schedule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Cron string `protobuf:"bytes,3,opt,name=cron,proto3" json:"cron,omitempty"` + Tags map[string]string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + PromiseId string `protobuf:"bytes,5,opt,name=promiseId,proto3" json:"promiseId,omitempty"` + PromiseTimeout int64 `protobuf:"varint,6,opt,name=promiseTimeout,proto3" json:"promiseTimeout,omitempty"` + PromiseParam *Value `protobuf:"bytes,7,opt,name=promiseParam,proto3" json:"promiseParam,omitempty"` + PromiseTags map[string]string `protobuf:"bytes,8,rep,name=promiseTags,proto3" json:"promiseTags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + IdempotencyKey string `protobuf:"bytes,9,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + LastRunTime int64 `protobuf:"varint,10,opt,name=lastRunTime,proto3" json:"lastRunTime,omitempty"` + NextRunTime int64 `protobuf:"varint,11,opt,name=nextRunTime,proto3" json:"nextRunTime,omitempty"` + CreatedOn int64 `protobuf:"varint,12,opt,name=createdOn,proto3" json:"createdOn,omitempty"` +} + +func (x *Schedule) Reset() { + *x = Schedule{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Schedule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Schedule) ProtoMessage() {} + +func (x *Schedule) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Schedule.ProtoReflect.Descriptor instead. +func (*Schedule) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDescGZIP(), []int{0} +} + +func (x *Schedule) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Schedule) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Schedule) GetCron() string { + if x != nil { + return x.Cron + } + return "" +} + +func (x *Schedule) GetTags() map[string]string { + if x != nil { + return x.Tags + } + return nil +} + +func (x *Schedule) GetPromiseId() string { + if x != nil { + return x.PromiseId + } + return "" +} + +func (x *Schedule) GetPromiseTimeout() int64 { + if x != nil { + return x.PromiseTimeout + } + return 0 +} + +func (x *Schedule) GetPromiseParam() *Value { + if x != nil { + return x.PromiseParam + } + return nil +} + +func (x *Schedule) GetPromiseTags() map[string]string { + if x != nil { + return x.PromiseTags + } + return nil +} + +func (x *Schedule) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + +func (x *Schedule) GetLastRunTime() int64 { + if x != nil { + return x.LastRunTime + } + return 0 +} + +func (x *Schedule) GetNextRunTime() int64 { + if x != nil { + return x.NextRunTime + } + return 0 +} + +func (x *Schedule) GetCreatedOn() int64 { + if x != nil { + return x.CreatedOn + } + return 0 +} + +var File_internal_app_subsystems_api_grpc_pb_schedule_t_proto protoreflect.FileDescriptor + +var file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDesc = []byte{ + 0x0a, 0x34, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x74, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, + 0x5f, 0x74, 0x1a, 0x33, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, + 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x5f, + 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcc, 0x04, 0x0a, 0x08, 0x53, 0x63, 0x68, 0x65, + 0x64, 0x75, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x72, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x04, 0x74, 0x61, + 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, + 0x75, 0x6c, 0x65, 0x5f, 0x74, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x54, + 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x1c, + 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, + 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x69, 0x6d, + 0x65, 0x6f, 0x75, 0x74, 0x12, 0x34, 0x0a, 0x0c, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, + 0x6d, 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0c, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x47, 0x0a, 0x0b, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x25, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x74, 0x2e, 0x53, 0x63, 0x68, + 0x65, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, 0x61, 0x67, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x54, + 0x61, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, + 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x64, 0x65, + 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x6c, + 0x61, 0x73, 0x74, 0x52, 0x75, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x75, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, + 0x0b, 0x6e, 0x65, 0x78, 0x74, 0x52, 0x75, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x0b, 0x6e, 0x65, 0x78, 0x74, 0x52, 0x75, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, + 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x18, 0x0c, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x1a, 0x37, 0x0a, + 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, + 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDescOnce sync.Once + file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDescData = file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDesc +) + +func file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDescGZIP() []byte { + file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDescOnce.Do(func() { + file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDescData) + }) + return file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDescData +} + +var file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_goTypes = []interface{}{ + (*Schedule)(nil), // 0: schedule_t.Schedule + nil, // 1: schedule_t.Schedule.TagsEntry + nil, // 2: schedule_t.Schedule.PromiseTagsEntry + (*Value)(nil), // 3: promise_t.Value +} +var file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_depIdxs = []int32{ + 1, // 0: schedule_t.Schedule.tags:type_name -> schedule_t.Schedule.TagsEntry + 3, // 1: schedule_t.Schedule.promiseParam:type_name -> promise_t.Value + 2, // 2: schedule_t.Schedule.promiseTags:type_name -> schedule_t.Schedule.PromiseTagsEntry + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_init() } +func file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_init() { + if File_internal_app_subsystems_api_grpc_pb_schedule_t_proto != nil { + return + } + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_init() + if !protoimpl.UnsafeEnabled { + file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Schedule); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_goTypes, + DependencyIndexes: file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_depIdxs, + MessageInfos: file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_msgTypes, + }.Build() + File_internal_app_subsystems_api_grpc_pb_schedule_t_proto = out.File + file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_rawDesc = nil + file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_goTypes = nil + file_internal_app_subsystems_api_grpc_pb_schedule_t_proto_depIdxs = nil +} diff --git a/internal/app/subsystems/api/grpc/pb/schedule_t.proto b/internal/app/subsystems/api/grpc/pb/schedule_t.proto new file mode 100644 index 00000000..058d144c --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/schedule_t.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package schedule_t; + +import "internal/app/subsystems/api/grpc/pb/promise_t.proto"; + +option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb"; + +message Schedule { + string id = 1; + string description = 2; + string cron = 3; + map tags = 4; + string promiseId = 5; + int64 promiseTimeout = 6; + promise_t.Value promiseParam = 7; + map promiseTags = 8; + string idempotencyKey = 9; + int64 lastRunTime = 10; + int64 nextRunTime = 11; + int64 createdOn = 12; +} diff --git a/internal/app/subsystems/api/grpc/pb/task.pb.go b/internal/app/subsystems/api/grpc/pb/task.pb.go new file mode 100644 index 00000000..1cd07f6a --- /dev/null +++ b/internal/app/subsystems/api/grpc/pb/task.pb.go @@ -0,0 +1,732 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.3 +// source: internal/app/subsystems/api/grpc/pb/task.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ClaimTaskRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Counter int32 `protobuf:"varint,2,opt,name=counter,proto3" json:"counter,omitempty"` + ProcessId string `protobuf:"bytes,3,opt,name=processId,proto3" json:"processId,omitempty"` + Frequency int32 `protobuf:"varint,4,opt,name=frequency,proto3" json:"frequency,omitempty"` + RequestId string `protobuf:"bytes,5,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *ClaimTaskRequest) Reset() { + *x = ClaimTaskRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClaimTaskRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClaimTaskRequest) ProtoMessage() {} + +func (x *ClaimTaskRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClaimTaskRequest.ProtoReflect.Descriptor instead. +func (*ClaimTaskRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescGZIP(), []int{0} +} + +func (x *ClaimTaskRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *ClaimTaskRequest) GetCounter() int32 { + if x != nil { + return x.Counter + } + return 0 +} + +func (x *ClaimTaskRequest) GetProcessId() string { + if x != nil { + return x.ProcessId + } + return "" +} + +func (x *ClaimTaskRequest) GetFrequency() int32 { + if x != nil { + return x.Frequency + } + return 0 +} + +func (x *ClaimTaskRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type ClaimTaskResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Claimed bool `protobuf:"varint,1,opt,name=claimed,proto3" json:"claimed,omitempty"` + Mesg *Mesg `protobuf:"bytes,2,opt,name=mesg,proto3" json:"mesg,omitempty"` +} + +func (x *ClaimTaskResponse) Reset() { + *x = ClaimTaskResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClaimTaskResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClaimTaskResponse) ProtoMessage() {} + +func (x *ClaimTaskResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClaimTaskResponse.ProtoReflect.Descriptor instead. +func (*ClaimTaskResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescGZIP(), []int{1} +} + +func (x *ClaimTaskResponse) GetClaimed() bool { + if x != nil { + return x.Claimed + } + return false +} + +func (x *ClaimTaskResponse) GetMesg() *Mesg { + if x != nil { + return x.Mesg + } + return nil +} + +type Mesg struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Promises map[string]*MesgPromise `protobuf:"bytes,2,rep,name=promises,proto3" json:"promises,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Mesg) Reset() { + *x = Mesg{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Mesg) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Mesg) ProtoMessage() {} + +func (x *Mesg) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Mesg.ProtoReflect.Descriptor instead. +func (*Mesg) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescGZIP(), []int{2} +} + +func (x *Mesg) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Mesg) GetPromises() map[string]*MesgPromise { + if x != nil { + return x.Promises + } + return nil +} + +type MesgPromise struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Href string `protobuf:"bytes,2,opt,name=href,proto3" json:"href,omitempty"` + Data *Promise `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *MesgPromise) Reset() { + *x = MesgPromise{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MesgPromise) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MesgPromise) ProtoMessage() {} + +func (x *MesgPromise) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MesgPromise.ProtoReflect.Descriptor instead. +func (*MesgPromise) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescGZIP(), []int{3} +} + +func (x *MesgPromise) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *MesgPromise) GetHref() string { + if x != nil { + return x.Href + } + return "" +} + +func (x *MesgPromise) GetData() *Promise { + if x != nil { + return x.Data + } + return nil +} + +type CompleteTaskRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Counter int32 `protobuf:"varint,2,opt,name=counter,proto3" json:"counter,omitempty"` + RequestId string `protobuf:"bytes,3,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *CompleteTaskRequest) Reset() { + *x = CompleteTaskRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CompleteTaskRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CompleteTaskRequest) ProtoMessage() {} + +func (x *CompleteTaskRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CompleteTaskRequest.ProtoReflect.Descriptor instead. +func (*CompleteTaskRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescGZIP(), []int{4} +} + +func (x *CompleteTaskRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CompleteTaskRequest) GetCounter() int32 { + if x != nil { + return x.Counter + } + return 0 +} + +func (x *CompleteTaskRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type CompleteTaskResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Completed bool `protobuf:"varint,1,opt,name=completed,proto3" json:"completed,omitempty"` +} + +func (x *CompleteTaskResponse) Reset() { + *x = CompleteTaskResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CompleteTaskResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CompleteTaskResponse) ProtoMessage() {} + +func (x *CompleteTaskResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CompleteTaskResponse.ProtoReflect.Descriptor instead. +func (*CompleteTaskResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescGZIP(), []int{5} +} + +func (x *CompleteTaskResponse) GetCompleted() bool { + if x != nil { + return x.Completed + } + return false +} + +type HeartbeatTasksRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProcessId string `protobuf:"bytes,1,opt,name=processId,proto3" json:"processId,omitempty"` + RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` +} + +func (x *HeartbeatTasksRequest) Reset() { + *x = HeartbeatTasksRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeartbeatTasksRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeartbeatTasksRequest) ProtoMessage() {} + +func (x *HeartbeatTasksRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HeartbeatTasksRequest.ProtoReflect.Descriptor instead. +func (*HeartbeatTasksRequest) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescGZIP(), []int{6} +} + +func (x *HeartbeatTasksRequest) GetProcessId() string { + if x != nil { + return x.ProcessId + } + return "" +} + +func (x *HeartbeatTasksRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type HeartbeatTasksResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TasksAffected int64 `protobuf:"varint,1,opt,name=tasksAffected,proto3" json:"tasksAffected,omitempty"` +} + +func (x *HeartbeatTasksResponse) Reset() { + *x = HeartbeatTasksResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeartbeatTasksResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeartbeatTasksResponse) ProtoMessage() {} + +func (x *HeartbeatTasksResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HeartbeatTasksResponse.ProtoReflect.Descriptor instead. +func (*HeartbeatTasksResponse) Descriptor() ([]byte, []int) { + return file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescGZIP(), []int{7} +} + +func (x *HeartbeatTasksResponse) GetTasksAffected() int64 { + if x != nil { + return x.TasksAffected + } + return 0 +} + +var File_internal_app_subsystems_api_grpc_pb_task_proto protoreflect.FileDescriptor + +var file_internal_app_subsystems_api_grpc_pb_task_proto_rawDesc = []byte{ + 0x0a, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, + 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x1a, 0x33, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x6d, + 0x69, 0x73, 0x65, 0x5f, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x96, 0x01, 0x0a, 0x10, + 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, + 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, + 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x66, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x49, 0x64, 0x22, 0x4d, 0x0a, 0x11, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, + 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6c, 0x61, + 0x69, 0x6d, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x63, 0x6c, 0x61, 0x69, + 0x6d, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x04, 0x6d, 0x65, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0a, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x4d, 0x65, 0x73, 0x67, 0x52, 0x04, 0x6d, + 0x65, 0x73, 0x67, 0x22, 0xa0, 0x01, 0x0a, 0x04, 0x4d, 0x65, 0x73, 0x67, 0x12, 0x12, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x34, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x4d, 0x65, 0x73, 0x67, 0x2e, 0x50, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x1a, 0x4e, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x27, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, + 0x4d, 0x65, 0x73, 0x67, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x59, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x67, 0x50, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x72, 0x65, 0x66, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x72, 0x65, 0x66, 0x12, 0x26, 0x0a, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x5f, 0x74, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x22, 0x5d, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, + 0x22, 0x34, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70, + 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x63, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x22, 0x53, 0x0a, 0x15, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, + 0x65, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x1c, 0x0a, + 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x3e, 0x0a, 0x16, 0x48, + 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x41, 0x66, + 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x74, 0x61, + 0x73, 0x6b, 0x73, 0x41, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x32, 0xdf, 0x01, 0x0a, 0x05, + 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, + 0x73, 0x6b, 0x12, 0x16, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, + 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x74, 0x61, 0x73, + 0x6b, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0c, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, + 0x65, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x19, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x43, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1a, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, + 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4d, + 0x0a, 0x0e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, + 0x12, 0x1b, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, + 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, + 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x54, 0x61, + 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x44, 0x5a, + 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x73, 0x6f, + 0x6e, 0x61, 0x74, 0x65, 0x68, 0x71, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x74, 0x65, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, + 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, + 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescOnce sync.Once + file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescData = file_internal_app_subsystems_api_grpc_pb_task_proto_rawDesc +) + +func file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescGZIP() []byte { + file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescOnce.Do(func() { + file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescData) + }) + return file_internal_app_subsystems_api_grpc_pb_task_proto_rawDescData +} + +var file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_internal_app_subsystems_api_grpc_pb_task_proto_goTypes = []interface{}{ + (*ClaimTaskRequest)(nil), // 0: task.ClaimTaskRequest + (*ClaimTaskResponse)(nil), // 1: task.ClaimTaskResponse + (*Mesg)(nil), // 2: task.Mesg + (*MesgPromise)(nil), // 3: task.MesgPromise + (*CompleteTaskRequest)(nil), // 4: task.CompleteTaskRequest + (*CompleteTaskResponse)(nil), // 5: task.CompleteTaskResponse + (*HeartbeatTasksRequest)(nil), // 6: task.HeartbeatTasksRequest + (*HeartbeatTasksResponse)(nil), // 7: task.HeartbeatTasksResponse + nil, // 8: task.Mesg.PromisesEntry + (*Promise)(nil), // 9: promise_t.Promise +} +var file_internal_app_subsystems_api_grpc_pb_task_proto_depIdxs = []int32{ + 2, // 0: task.ClaimTaskResponse.mesg:type_name -> task.Mesg + 8, // 1: task.Mesg.promises:type_name -> task.Mesg.PromisesEntry + 9, // 2: task.MesgPromise.data:type_name -> promise_t.Promise + 3, // 3: task.Mesg.PromisesEntry.value:type_name -> task.MesgPromise + 0, // 4: task.Tasks.ClaimTask:input_type -> task.ClaimTaskRequest + 4, // 5: task.Tasks.CompleteTask:input_type -> task.CompleteTaskRequest + 6, // 6: task.Tasks.HeartbeatTasks:input_type -> task.HeartbeatTasksRequest + 1, // 7: task.Tasks.ClaimTask:output_type -> task.ClaimTaskResponse + 5, // 8: task.Tasks.CompleteTask:output_type -> task.CompleteTaskResponse + 7, // 9: task.Tasks.HeartbeatTasks:output_type -> task.HeartbeatTasksResponse + 7, // [7:10] is the sub-list for method output_type + 4, // [4:7] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_internal_app_subsystems_api_grpc_pb_task_proto_init() } +func file_internal_app_subsystems_api_grpc_pb_task_proto_init() { + if File_internal_app_subsystems_api_grpc_pb_task_proto != nil { + return + } + file_internal_app_subsystems_api_grpc_pb_promise_t_proto_init() + if !protoimpl.UnsafeEnabled { + file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClaimTaskRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClaimTaskResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Mesg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MesgPromise); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CompleteTaskRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CompleteTaskResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeartbeatTasksRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeartbeatTasksResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_app_subsystems_api_grpc_pb_task_proto_rawDesc, + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_internal_app_subsystems_api_grpc_pb_task_proto_goTypes, + DependencyIndexes: file_internal_app_subsystems_api_grpc_pb_task_proto_depIdxs, + MessageInfos: file_internal_app_subsystems_api_grpc_pb_task_proto_msgTypes, + }.Build() + File_internal_app_subsystems_api_grpc_pb_task_proto = out.File + file_internal_app_subsystems_api_grpc_pb_task_proto_rawDesc = nil + file_internal_app_subsystems_api_grpc_pb_task_proto_goTypes = nil + file_internal_app_subsystems_api_grpc_pb_task_proto_depIdxs = nil +} diff --git a/internal/app/subsystems/api/grpc/api/task.proto b/internal/app/subsystems/api/grpc/pb/task.proto similarity index 65% rename from internal/app/subsystems/api/grpc/api/task.proto rename to internal/app/subsystems/api/grpc/pb/task.proto index 6bc9bee6..7c693f45 100644 --- a/internal/app/subsystems/api/grpc/api/task.proto +++ b/internal/app/subsystems/api/grpc/pb/task.proto @@ -2,9 +2,9 @@ syntax = "proto3"; package task; -import "internal/app/subsystems/api/grpc/api/promise.proto"; +import "internal/app/subsystems/api/grpc/pb/promise_t.proto"; -option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api"; +option go_package = "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb"; service Tasks { rpc ClaimTask (ClaimTaskRequest) returns (ClaimTaskResponse) {} @@ -14,15 +14,26 @@ service Tasks { message ClaimTaskRequest { string id = 1; - string processId = 2; - int32 counter = 3; + int32 counter = 2; + string processId = 3; int32 frequency = 4; string requestId = 5; } message ClaimTaskResponse { + bool claimed = 1; + Mesg mesg = 2; +} + +message Mesg { string type = 1; - map promises = 2; + map promises = 2; +} + +message MesgPromise { + string id = 1; + string href = 2; + promise_t.Promise data = 3; } message CompleteTaskRequest { @@ -31,7 +42,9 @@ message CompleteTaskRequest { string requestId = 3; } -message CompleteTaskResponse {} +message CompleteTaskResponse { + bool completed = 1; +} message HeartbeatTasksRequest { string processId = 1; diff --git a/internal/app/subsystems/api/grpc/api/task_grpc.pb.go b/internal/app/subsystems/api/grpc/pb/task_grpc.pb.go similarity index 98% rename from internal/app/subsystems/api/grpc/api/task_grpc.pb.go rename to internal/app/subsystems/api/grpc/pb/task_grpc.pb.go index 5039007d..a4fcdd72 100644 --- a/internal/app/subsystems/api/grpc/api/task_grpc.pb.go +++ b/internal/app/subsystems/api/grpc/pb/task_grpc.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-grpc v1.3.0 // - protoc v4.23.3 -// source: internal/app/subsystems/api/grpc/api/task.proto +// source: internal/app/subsystems/api/grpc/pb/task.proto -package api +package pb import ( context "context" @@ -179,5 +179,5 @@ var Tasks_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "internal/app/subsystems/api/grpc/api/task.proto", + Metadata: "internal/app/subsystems/api/grpc/pb/task.proto", } diff --git a/internal/app/subsystems/api/grpc/promise.go b/internal/app/subsystems/api/grpc/promise.go index 9f10dafe..a90c8202 100644 --- a/internal/app/subsystems/api/grpc/promise.go +++ b/internal/app/subsystems/api/grpc/promise.go @@ -3,305 +3,386 @@ package grpc import ( "context" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" "github.com/resonatehq/resonate/internal/kernel/t_api" "github.com/resonatehq/resonate/internal/util" - grpcApi "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api" + "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb" "github.com/resonatehq/resonate/pkg/idempotency" "github.com/resonatehq/resonate/pkg/promise" "google.golang.org/grpc/codes" - grpcStatus "google.golang.org/grpc/status" + "google.golang.org/grpc/status" ) -func (s *server) ReadPromise(ctx context.Context, req *grpcApi.ReadPromiseRequest) (*grpcApi.ReadPromiseResponse, error) { - header := &service.Header{ - RequestId: req.RequestId, - } - - res, err := s.service.ReadPromise(req.Id, header) +func (s *server) ReadPromise(c context.Context, r *pb.ReadPromiseRequest) (*pb.ReadPromiseResponse, error) { + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.ReadPromise, + ReadPromise: &t_api.ReadPromiseRequest{ + Id: r.Id, + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.ReadPromiseResponse{ - Promise: protoPromise(res.Promise), + util.Assert(res.ReadPromise != nil, "result must not be nil") + return &pb.ReadPromiseResponse{ + Promise: protoPromise(res.ReadPromise.Promise), }, nil } -func (s *server) SearchPromises(ctx context.Context, req *grpcApi.SearchPromisesRequest) (*grpcApi.SearchPromisesResponse, error) { - header := &service.Header{ - RequestId: req.RequestId, - } - - // TODO: for now, look at at protobuf validators - // ref: https://github.com/protocolbuffers/protobuf/issues/1606 - // can't check if limit was set or not in proto3. see above issue - // so can't check for 0. - if req.Limit > 100 || req.Limit < 0 { - return nil, grpcStatus.Error(codes.InvalidArgument, "field limit must be greater than 0 and less than or equal to 100") - } - - params := &service.SearchPromisesParams{ - Id: &req.Id, - State: searchState(req.State), - Tags: req.Tags, - Limit: util.ToPointer(int(req.Limit)), - Cursor: &req.Cursor, +func (s *server) SearchPromises(c context.Context, r *pb.SearchPromisesRequest) (*pb.SearchPromisesResponse, error) { + req, err := s.api.SearchPromises(r.Id, searchState(r.State), r.Tags, int(r.Limit), r.Cursor) + if err != nil { + return nil, status.Error(s.code(err.Code), err.Error()) } - res, err := s.service.SearchPromises(header, params) + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.SearchPromises, + SearchPromises: req, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - promises := make([]*grpcApi.Promise, len(res.Promises)) - for i, promise := range res.Promises { + util.Assert(res.SearchPromises != nil, "result must not be nil") + + promises := make([]*pb.Promise, len(res.SearchPromises.Promises)) + for i, promise := range res.SearchPromises.Promises { promises[i] = protoPromise(promise) } - cursor := "" - if res.Cursor != nil { + var cursor string + if res.SearchPromises.Cursor != nil { var err error - cursor, err = res.Cursor.Encode() + cursor, err = res.SearchPromises.Cursor.Encode() if err != nil { - return nil, grpcStatus.Error(codes.Internal, err.Error()) + return nil, status.Error(codes.Internal, err.Error()) } } - return &grpcApi.SearchPromisesResponse{ - Cursor: cursor, + return &pb.SearchPromisesResponse{ Promises: promises, + Cursor: cursor, }, nil } -func (s *server) CreatePromise(ctx context.Context, req *grpcApi.CreatePromiseRequest) (*grpcApi.CreatePromiseResponse, error) { +func (s *server) CreatePromise(c context.Context, r *pb.CreatePromiseRequest) (*pb.CreatePromiseResponse, error) { var idempotencyKey *idempotency.Key - if req.IdempotencyKey != "" { - idempotencyKey = util.ToPointer(idempotency.Key(req.IdempotencyKey)) + if r.IdempotencyKey != "" { + idempotencyKey = util.ToPointer(idempotency.Key(r.IdempotencyKey)) } var headers map[string]string - if req.Param != nil { - headers = req.Param.Headers + if r.Param != nil { + headers = r.Param.Headers } var data []byte - if req.Param != nil { - data = req.Param.Data + if r.Param != nil { + data = r.Param.Data + } + + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.CreatePromise, + CreatePromise: &t_api.CreatePromiseRequest{ + Id: r.Id, + IdempotencyKey: idempotencyKey, + Strict: r.Strict, + Param: promise.Value{Headers: headers, Data: data}, + Timeout: r.Timeout, + Tags: r.Tags, + }, + }) + if err != nil { + return nil, status.Error(s.code(err.Code), err.Error()) } - // TODO: for now, look at at protobuf validators - if req.Timeout < 0 || req.Timeout == 0 { - return nil, grpcStatus.Error(codes.InvalidArgument, "timeout must be greater than 0") + util.Assert(res.CreatePromise != nil, "result must not be nil") + return &pb.CreatePromiseResponse{ + Noop: res.CreatePromise.Status == t_api.StatusOK, + Promise: protoPromise(res.CreatePromise.Promise), + }, nil +} + +func (s *server) CreatePromiseAndTask(c context.Context, r *pb.CreatePromiseAndTaskRequest) (*pb.CreatePromiseAndTaskResponse, error) { + if r.Promise == nil { + return nil, status.Error(codes.InvalidArgument, "The field task is required.") } - header := &service.CreatePromiseHeader{ - Header: service.Header{RequestId: req.RequestId}, - Strict: req.Strict, - IdempotencyKey: idempotencyKey, + if r.Task == nil { + return nil, status.Error(codes.InvalidArgument, "The field task is required.") } - body := &promise.Promise{ - Id: req.Id, - Param: promise.Value{ - Headers: headers, - Data: data, - }, - Timeout: req.Timeout, + var idempotencyKey *idempotency.Key + if r.Promise.IdempotencyKey != "" { + idempotencyKey = util.ToPointer(idempotency.Key(r.Promise.IdempotencyKey)) + } + + var headers map[string]string + if r.Promise.Param != nil { + headers = r.Promise.Param.Headers } - res, err := s.service.CreatePromise(header, body) + var data []byte + if r.Promise.Param != nil { + data = r.Promise.Param.Data + } + + recv, rErr := protoRecv(r.Task.Recv) + if rErr != nil { + return nil, rErr + } + + res, err := s.api.Process(r.Promise.RequestId, &t_api.Request{ + Kind: t_api.CreatePromiseAndTask, + CreatePromiseAndTask: &t_api.CreatePromiseAndTaskRequest{ + Promise: &t_api.CreatePromiseRequest{ + Id: r.Promise.Id, + IdempotencyKey: idempotencyKey, + Strict: r.Promise.Strict, + Param: promise.Value{Headers: headers, Data: data}, + Timeout: r.Promise.Timeout, + Tags: r.Promise.Tags, + }, + Task: &t_api.CreateTaskRequest{ + PromiseId: r.Promise.Id, + ProcessId: r.Task.ProcessId, + Frequency: int(r.Task.Frequency), + Timeout: r.Promise.Timeout, + Recv: recv, + }, + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.CreatePromiseResponse{ - Noop: res.Status == t_api.StatusOK, - Promise: protoPromise(res.Promise), + util.Assert(res.CreatePromiseAndTask != nil, "result must not be nil") + return &pb.CreatePromiseAndTaskResponse{ + Noop: res.CreatePromiseAndTask.Status == t_api.StatusOK, + Promise: protoPromise(res.CreatePromiseAndTask.Promise), }, nil } -func (s *server) CancelPromise(ctx context.Context, req *grpcApi.CancelPromiseRequest) (*grpcApi.CancelPromiseResponse, error) { - var idempotencyKey *idempotency.Key - if req.IdempotencyKey != "" { - idempotencyKey = util.ToPointer(idempotency.Key(req.IdempotencyKey)) +func (s *server) CreatePromiseAndCallback(c context.Context, r *pb.CreatePromiseAndCallbackRequest) (*pb.CreatePromiseAndCallbackResponse, error) { + if r.Promise == nil { + return nil, status.Error(codes.InvalidArgument, "The field promise is required.") } - var headers map[string]string - if req.Value != nil { - headers = req.Value.Headers + if r.Callback == nil { + return nil, status.Error(codes.InvalidArgument, "The field callback is required.") } - var data []byte - if req.Value != nil { - data = req.Value.Data + var idempotencyKey *idempotency.Key + if r.Promise.IdempotencyKey != "" { + idempotencyKey = util.ToPointer(idempotency.Key(r.Promise.IdempotencyKey)) } - header := &service.CompletePromiseHeader{ - Header: service.Header{RequestId: req.RequestId}, - Strict: req.Strict, - IdempotencyKey: idempotencyKey, + var headers map[string]string + if r.Promise.Param != nil { + headers = r.Promise.Param.Headers } - body := &service.CompletePromiseBody{ - Value: promise.Value{ - Headers: headers, - Data: data, + var data []byte + if r.Promise.Param != nil { + data = r.Promise.Param.Data + } + + recv, rErr := protoRecv(r.Callback.Recv) + if rErr != nil { + return nil, rErr + } + + res, err := s.api.Process(r.Promise.RequestId, &t_api.Request{ + Kind: t_api.CreatePromiseAndCallback, + CreatePromiseAndCallback: &t_api.CreatePromiseAndCallbackRequest{ + Promise: &t_api.CreatePromiseRequest{ + Id: r.Promise.Id, + IdempotencyKey: idempotencyKey, + Strict: r.Promise.Strict, + Param: promise.Value{Headers: headers, Data: data}, + Timeout: r.Promise.Timeout, + Tags: r.Promise.Tags, + }, + Callback: &t_api.CreateCallbackRequest{ + PromiseId: r.Promise.Id, + RootPromiseId: r.Callback.RootPromiseId, + Timeout: r.Callback.Timeout, + Recv: recv, + }, }, - } - res, err := s.service.CompletePromise(req.Id, promise.Canceled, header, body) + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.CancelPromiseResponse{ - Noop: res.Status == t_api.StatusOK, - Promise: protoPromise(res.Promise), + util.Assert(res.CreatePromiseAndCallback != nil, "result must not be nil") + return &pb.CreatePromiseAndCallbackResponse{ + Noop: res.CreatePromiseAndCallback.Status == t_api.StatusOK, + Promise: protoPromise(res.CreatePromiseAndCallback.Promise), }, nil } -func (s *server) ResolvePromise(ctx context.Context, req *grpcApi.ResolvePromiseRequest) (*grpcApi.ResolvePromiseResponse, error) { +func (s *server) ResolvePromise(c context.Context, r *pb.ResolvePromiseRequest) (*pb.ResolvePromiseResponse, error) { var idempotencyKey *idempotency.Key - if req.IdempotencyKey != "" { - idempotencyKey = util.ToPointer(idempotency.Key(req.IdempotencyKey)) + if r.IdempotencyKey != "" { + idempotencyKey = util.ToPointer(idempotency.Key(r.IdempotencyKey)) } var headers map[string]string - if req.Value != nil { - headers = req.Value.Headers + if r.Value != nil { + headers = r.Value.Headers } var data []byte - if req.Value != nil { - data = req.Value.Data - } - - header := &service.CompletePromiseHeader{ - Header: service.Header{RequestId: req.RequestId}, - Strict: req.Strict, - IdempotencyKey: idempotencyKey, - } - - body := &service.CompletePromiseBody{ - Value: promise.Value{ - Headers: headers, - Data: data, + if r.Value != nil { + data = r.Value.Data + } + + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: r.Id, + IdempotencyKey: idempotencyKey, + Strict: r.Strict, + State: promise.Resolved, + Value: promise.Value{Headers: headers, Data: data}, }, - } - - res, err := s.service.CompletePromise(req.Id, promise.Resolved, header, body) + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.ResolvePromiseResponse{ - Noop: res.Status == t_api.StatusOK, - Promise: protoPromise(res.Promise), + util.Assert(res.CompletePromise != nil, "result must not be nil") + return &pb.ResolvePromiseResponse{ + Noop: res.CompletePromise.Status == t_api.StatusOK, + Promise: protoPromise(res.CompletePromise.Promise), }, nil } -func (s *server) RejectPromise(ctx context.Context, req *grpcApi.RejectPromiseRequest) (*grpcApi.RejectPromiseResponse, error) { +func (s *server) RejectPromise(c context.Context, r *pb.RejectPromiseRequest) (*pb.RejectPromiseResponse, error) { var idempotencyKey *idempotency.Key - if req.IdempotencyKey != "" { - idempotencyKey = util.ToPointer(idempotency.Key(req.IdempotencyKey)) + if r.IdempotencyKey != "" { + idempotencyKey = util.ToPointer(idempotency.Key(r.IdempotencyKey)) } var headers map[string]string - if req.Value != nil { - headers = req.Value.Headers + if r.Value != nil { + headers = r.Value.Headers } var data []byte - if req.Value != nil { - data = req.Value.Data + if r.Value != nil { + data = r.Value.Data + } + + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: r.Id, + IdempotencyKey: idempotencyKey, + Strict: r.Strict, + State: promise.Rejected, + Value: promise.Value{Headers: headers, Data: data}, + }, + }) + if err != nil { + return nil, status.Error(s.code(err.Code), err.Error()) } - header := &service.CompletePromiseHeader{ - Header: service.Header{RequestId: req.RequestId}, - Strict: req.Strict, - IdempotencyKey: idempotencyKey, + util.Assert(res.CompletePromise != nil, "result must not be nil") + return &pb.RejectPromiseResponse{ + Noop: res.CompletePromise.Status == t_api.StatusOK, + Promise: protoPromise(res.CompletePromise.Promise), + }, nil +} + +func (s *server) CancelPromise(c context.Context, r *pb.CancelPromiseRequest) (*pb.CancelPromiseResponse, error) { + var idempotencyKey *idempotency.Key + if r.IdempotencyKey != "" { + idempotencyKey = util.ToPointer(idempotency.Key(r.IdempotencyKey)) } - body := &service.CompletePromiseBody{ - Value: promise.Value{ - Headers: headers, - Data: data, - }, + var headers map[string]string + if r.Value != nil { + headers = r.Value.Headers } - res, err := s.service.CompletePromise(req.Id, promise.Rejected, header, body) + var data []byte + if r.Value != nil { + data = r.Value.Data + } + + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: r.Id, + IdempotencyKey: idempotencyKey, + Strict: r.Strict, + State: promise.Canceled, + Value: promise.Value{Headers: headers, Data: data}, + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.RejectPromiseResponse{ - Noop: res.Status == t_api.StatusOK, - Promise: protoPromise(res.Promise), + util.Assert(res.CompletePromise != nil, "result must not be nil") + return &pb.CancelPromiseResponse{ + Noop: res.CompletePromise.Status == t_api.StatusOK, + Promise: protoPromise(res.CompletePromise.Promise), }, nil } -func protoPromise(promise *promise.Promise) *grpcApi.Promise { +// Helper functions + +func protoPromise(promise *promise.Promise) *pb.Promise { if promise == nil { return nil } - var idempotencyKeyForCreate, idempotencyKeyForComplete string - if promise.IdempotencyKeyForCreate != nil { - idempotencyKeyForCreate = string(*promise.IdempotencyKeyForCreate) - } - if promise.IdempotencyKeyForComplete != nil { - idempotencyKeyForComplete = string(*promise.IdempotencyKeyForComplete) - } - - return &grpcApi.Promise{ - Id: promise.Id, - State: protoState(promise.State), - Param: &grpcApi.Value{ - Headers: promise.Param.Headers, - Data: promise.Param.Data, - }, - Value: &grpcApi.Value{ - Headers: promise.Param.Headers, - Data: promise.Param.Data, - }, + return &pb.Promise{ + Id: promise.Id, + State: protoState(promise.State), + Param: &pb.Value{Headers: promise.Param.Headers, Data: promise.Param.Data}, + Value: &pb.Value{Headers: promise.Value.Headers, Data: promise.Value.Data}, Timeout: promise.Timeout, - IdempotencyKeyForCreate: idempotencyKeyForCreate, - IdempotencyKeyForComplete: idempotencyKeyForComplete, + IdempotencyKeyForCreate: string(util.SafeDeref(promise.IdempotencyKeyForCreate)), + IdempotencyKeyForComplete: string(util.SafeDeref(promise.IdempotencyKeyForComplete)), CreatedOn: util.SafeDeref(promise.CreatedOn), CompletedOn: util.SafeDeref(promise.CompletedOn), Tags: promise.Tags, } } -func protoState(state promise.State) grpcApi.State { +func protoState(state promise.State) pb.State { switch state { case promise.Pending: - return grpcApi.State_PENDING + return pb.State_PENDING case promise.Resolved: - return grpcApi.State_RESOLVED + return pb.State_RESOLVED case promise.Rejected: - return grpcApi.State_REJECTED + return pb.State_REJECTED case promise.Timedout: - return grpcApi.State_REJECTED_TIMEDOUT + return pb.State_REJECTED_TIMEDOUT case promise.Canceled: - return grpcApi.State_REJECTED_CANCELED + return pb.State_REJECTED_CANCELED default: panic("invalid state") } } -func searchState(searchState grpcApi.SearchState) *string { +func searchState(searchState pb.SearchState) string { switch searchState { - case grpcApi.SearchState_SEARCH_ALL: - return nil - case grpcApi.SearchState_SEARCH_RESOLVED: - return util.ToPointer("resolved") - case grpcApi.SearchState_SEARCH_REJECTED: - return util.ToPointer("rejected") - case grpcApi.SearchState_SEARCH_PENDING: - return util.ToPointer("pending") + case pb.SearchState_SEARCH_ALL: + return "" + case pb.SearchState_SEARCH_PENDING: + return "pending" + case pb.SearchState_SEARCH_RESOLVED: + return "resolved" + case pb.SearchState_SEARCH_REJECTED: + return "rejected" default: - panic("invalid state") + return "INVALID" // will be validated in the helper function } } diff --git a/internal/app/subsystems/api/grpc/schedule.go b/internal/app/subsystems/api/grpc/schedule.go index 5b0b054c..8500cefd 100644 --- a/internal/app/subsystems/api/grpc/schedule.go +++ b/internal/app/subsystems/api/grpc/schedule.go @@ -3,141 +3,143 @@ package grpc import ( "context" - grpcApi "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb" + "github.com/resonatehq/resonate/internal/kernel/t_api" "github.com/resonatehq/resonate/internal/util" "github.com/resonatehq/resonate/pkg/idempotency" "github.com/resonatehq/resonate/pkg/promise" "github.com/resonatehq/resonate/pkg/schedule" "google.golang.org/grpc/codes" - grpcStatus "google.golang.org/grpc/status" + "google.golang.org/grpc/status" ) -// CREATE - -func (s *server) CreateSchedule(ctx context.Context, req *grpcApi.CreateScheduleRequest) (*grpcApi.CreatedScheduleResponse, error) { - ikey := idempotency.Key(req.IdempotencyKey) - - header := service.CreateScheduleHeader{ - Header: service.Header{RequestId: req.RequestId}, - IdempotencyKey: &ikey, - } - - body := service.CreateScheduleBody{ - Id: req.Id, - Description: req.Description, - Cron: req.Cron, - Tags: req.Tags, - PromiseId: req.PromiseId, - PromiseTimeout: req.PromiseTimeout, - PromiseParam: promise.Value{ - Headers: req.PromiseParam.Headers, - Data: []byte(req.PromiseParam.Data), +func (s *server) ReadSchedule(c context.Context, r *pb.ReadScheduleRequest) (*pb.ReadScheduleResponse, error) { + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.ReadSchedule, + ReadSchedule: &t_api.ReadScheduleRequest{ + Id: r.Id, }, - PromiseTags: req.PromiseTags, - } - - res, err := s.service.CreateSchedule(header, &body) + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.CreatedScheduleResponse{ - Schedule: protoSchedule(res.Schedule), + util.Assert(res.ReadSchedule != nil, "result must not be nil") + return &pb.ReadScheduleResponse{ + Schedule: protoSchedule(res.ReadSchedule.Schedule), }, nil } -// READ - -func (s *server) ReadSchedule(ctx context.Context, req *grpcApi.ReadScheduleRequest) (*grpcApi.ReadScheduleResponse, error) { - header := service.Header{ - RequestId: req.RequestId, - } - - res, err := s.service.ReadSchedule(req.Id, &header) +func (s *server) SearchSchedules(c context.Context, r *pb.SearchSchedulesRequest) (*pb.SearchSchedulesResponse, error) { + req, err := s.api.SearchSchedules(r.Id, r.Tags, int(r.Limit), r.Cursor) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.ReadScheduleResponse{ - Schedule: protoSchedule(res.Schedule), - }, nil -} - -// SEARCH - -func (s *server) SearchSchedules(ctx context.Context, req *grpcApi.SearchSchedulesRequest) (*grpcApi.SearchSchedulesResponse, error) { - headers := &service.Header{ - RequestId: req.RequestId, - } - - if req.Limit > 100 || req.Limit < 0 { - return nil, grpcStatus.Error(codes.InvalidArgument, "field limit must be greater than 0 and less than or equal to 100") - } - - params := &service.SearchSchedulesParams{ - Id: &req.Id, - Tags: req.Tags, - Limit: util.ToPointer(int(req.Limit)), - Cursor: &req.Cursor, - } - - res, err := s.service.SearchSchedules(headers, params) + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.SearchSchedules, + SearchSchedules: req, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - schedules := make([]*grpcApi.Schedule, len(res.Schedules)) - for i, schedule := range res.Schedules { + util.Assert(res.SearchSchedules != nil, "result must not be nil") + + schedules := make([]*pb.Schedule, len(res.SearchSchedules.Schedules)) + for i, schedule := range res.SearchSchedules.Schedules { schedules[i] = protoSchedule(schedule) } var cursor string - if res.Cursor != nil { + if res.SearchSchedules.Cursor != nil { var err error - cursor, err = res.Cursor.Encode() + cursor, err = res.SearchSchedules.Cursor.Encode() if err != nil { - return nil, grpcStatus.Error(codes.Internal, err.Error()) + return nil, status.Error(codes.Internal, err.Error()) } } - return &grpcApi.SearchSchedulesResponse{ + return &pb.SearchSchedulesResponse{ Schedules: schedules, Cursor: cursor, }, nil } -// DELETE +func (s *server) CreateSchedule(c context.Context, r *pb.CreateScheduleRequest) (*pb.CreatedScheduleResponse, error) { + if err := s.api.ValidateCron(r.Cron); err != nil { + return nil, status.Error(s.code(err.Code), err.Error()) + } + + var idempotencyKey *idempotency.Key + if r.IdempotencyKey != "" { + idempotencyKey = util.ToPointer(idempotency.Key(r.IdempotencyKey)) + } -func (s *server) DeleteSchedule(ctx context.Context, req *grpcApi.DeleteScheduleRequest) (*grpcApi.DeleteScheduleResponse, error) { - header := service.Header{ - RequestId: req.RequestId, + var headers map[string]string + if r.PromiseParam != nil { + headers = r.PromiseParam.Headers } - _, err := s.service.DeleteSchedule(req.Id, &header) + var data []byte + if r.PromiseParam != nil { + data = r.PromiseParam.Data + } + + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.CreateSchedule, + CreateSchedule: &t_api.CreateScheduleRequest{ + Id: r.Id, + Description: r.Description, + Cron: r.Cron, + Tags: r.Tags, + PromiseId: r.PromiseId, + PromiseTimeout: r.PromiseTimeout, + PromiseParam: promise.Value{Headers: headers, Data: data}, + PromiseTags: r.PromiseTags, + IdempotencyKey: idempotencyKey, + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.DeleteScheduleResponse{}, nil + util.Assert(res.CreateSchedule != nil, "result must not be nil") + return &pb.CreatedScheduleResponse{ + Schedule: protoSchedule(res.CreateSchedule.Schedule), + }, nil } -func protoSchedule(schedule *schedule.Schedule) *grpcApi.Schedule { +func (s *server) DeleteSchedule(c context.Context, r *pb.DeleteScheduleRequest) (*pb.DeleteScheduleResponse, error) { + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.DeleteSchedule, + DeleteSchedule: &t_api.DeleteScheduleRequest{ + Id: r.Id, + }, + }) + if err != nil { + return nil, status.Error(s.code(err.Code), err.Error()) + } + + util.Assert(res.DeleteSchedule != nil, "result must not be nil") + return &pb.DeleteScheduleResponse{}, nil +} + +// Helper functions + +func protoSchedule(schedule *schedule.Schedule) *pb.Schedule { if schedule == nil { return nil } - return &grpcApi.Schedule{ + return &pb.Schedule{ Id: schedule.Id, Description: schedule.Description, Cron: schedule.Cron, Tags: schedule.Tags, PromiseId: schedule.PromiseId, PromiseTimeout: schedule.PromiseTimeout, - PromiseParam: &grpcApi.Value{ - Headers: schedule.PromiseParam.Headers, - Data: schedule.PromiseParam.Data, - }, + PromiseParam: &pb.Value{Headers: schedule.PromiseParam.Headers, Data: schedule.PromiseParam.Data}, PromiseTags: schedule.PromiseTags, LastRunTime: util.SafeDeref(schedule.LastRunTime), NextRunTime: schedule.NextRunTime, diff --git a/internal/app/subsystems/api/grpc/task.go b/internal/app/subsystems/api/grpc/task.go index 8fc3410f..c9af064a 100644 --- a/internal/app/subsystems/api/grpc/task.go +++ b/internal/app/subsystems/api/grpc/task.go @@ -3,95 +3,91 @@ package grpc import ( "context" - grpcApi "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/api" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb" "github.com/resonatehq/resonate/internal/kernel/t_api" "github.com/resonatehq/resonate/internal/util" - "google.golang.org/grpc/codes" - grpcStatus "google.golang.org/grpc/status" + "github.com/resonatehq/resonate/pkg/message" + "google.golang.org/grpc/status" ) -func (s *server) ClaimTask(ctx context.Context, req *grpcApi.ClaimTaskRequest) (*grpcApi.ClaimTaskResponse, error) { - header := &service.Header{ - RequestId: req.RequestId, - } - - if req.Id == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "task.id must be provided") - } - if req.ProcessId == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "task.processId must be provided") - } - if req.Frequency == 0 { - return nil, grpcStatus.Error(codes.InvalidArgument, "task.frequency must be provided") - } - - body := &service.ClaimTaskBody{ - Id: req.Id, - ProcessId: req.ProcessId, - Counter: int(req.Counter), - Frequency: int(req.Frequency), - } - - res, err := s.service.ClaimTask(header, body) +func (s *server) ClaimTask(c context.Context, r *pb.ClaimTaskRequest) (*pb.ClaimTaskResponse, error) { + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.ClaimTask, + ClaimTask: &t_api.ClaimTaskRequest{ + Id: r.Id, + ProcessId: r.ProcessId, + Counter: int(r.Counter), + Frequency: int(r.Frequency), + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - util.Assert(res.Status != t_api.StatusCreated || res.Mesg != nil, "message must not be nil if created") - - promises := map[string]*grpcApi.Promise{} - for k, promise := range res.Mesg.Promises { - promises[k] = protoPromise(promise) + util.Assert(res.ClaimTask != nil, "result must not be nil") + util.Assert(res.ClaimTask.Status != t_api.StatusCreated || (res.ClaimTask.Task != nil && res.ClaimTask.Task.Mesg != nil), "task and mesg must not be nil if created") + + var mesg *pb.Mesg + if res.ClaimTask.Status == t_api.StatusCreated { + promises := map[string]*pb.MesgPromise{ + "root": { + Id: res.ClaimTask.Task.Mesg.Root, + Href: res.ClaimTask.RootPromiseHref, + Data: protoPromise(res.ClaimTask.RootPromise), + }, + } + + if res.ClaimTask.Task.Mesg.Type == message.Resume { + promises["leaf"] = &pb.MesgPromise{ + Id: res.ClaimTask.Task.Mesg.Leaf, + Href: res.ClaimTask.LeafPromiseHref, + Data: protoPromise(res.ClaimTask.LeafPromise), + } + } + + mesg = &pb.Mesg{ + Type: string(res.ClaimTask.Task.Mesg.Type), + Promises: promises, + } } - return &grpcApi.ClaimTaskResponse{ - Type: string(res.Mesg.Type), - Promises: promises, + return &pb.ClaimTaskResponse{ + Claimed: res.ClaimTask.Status == t_api.StatusCreated, + Mesg: mesg, }, nil } -func (s *server) CompleteTask(ctx context.Context, req *grpcApi.CompleteTaskRequest) (*grpcApi.CompleteTaskResponse, error) { - header := &service.Header{ - RequestId: req.RequestId, - } - - if req.Id == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "task.id must be provided") - } - - body := &service.CompleteTaskBody{ - Id: req.Id, - Counter: int(req.Counter), - } - - _, err := s.service.CompleteTask(header, body) +func (s *server) CompleteTask(c context.Context, r *pb.CompleteTaskRequest) (*pb.CompleteTaskResponse, error) { + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.CompleteTask, + CompleteTask: &t_api.CompleteTaskRequest{ + Id: r.Id, + Counter: int(r.Counter), + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.CompleteTaskResponse{}, nil + util.Assert(res.CompleteTask != nil, "result must not be nil") + return &pb.CompleteTaskResponse{ + Completed: res.CompleteTask.Status == t_api.StatusCreated, + }, nil } -func (s *server) HeartbeatTasks(ctx context.Context, req *grpcApi.HeartbeatTasksRequest) (*grpcApi.HeartbeatTasksResponse, error) { - header := &service.Header{ - RequestId: req.RequestId, - } - - if req.ProcessId == "" { - return nil, grpcStatus.Error(codes.InvalidArgument, "task.process_id must be provided") - } - - body := &service.HeartbeatTaskBody{ - ProcessId: req.ProcessId, - } - - res, err := s.service.HeartbeatTasks(header, body) +func (s *server) HeartbeatTasks(c context.Context, r *pb.HeartbeatTasksRequest) (*pb.HeartbeatTasksResponse, error) { + res, err := s.api.Process(r.RequestId, &t_api.Request{ + Kind: t_api.HeartbeatTasks, + HeartbeatTasks: &t_api.HeartbeatTasksRequest{ + ProcessId: r.ProcessId, + }, + }) if err != nil { - return nil, grpcStatus.Error(s.code(err.Code), err.Error()) + return nil, status.Error(s.code(err.Code), err.Error()) } - return &grpcApi.HeartbeatTasksResponse{ - TasksAffected: res.TasksAffected, + util.Assert(res.HeartbeatTasks != nil, "result must not be nil") + return &pb.HeartbeatTasksResponse{ + TasksAffected: res.HeartbeatTasks.TasksAffected, }, nil } diff --git a/internal/app/subsystems/api/http/callback.go b/internal/app/subsystems/api/http/callback.go index 5199ca72..0919a490 100644 --- a/internal/app/subsystems/api/http/callback.go +++ b/internal/app/subsystems/api/http/callback.go @@ -1,41 +1,59 @@ package http import ( + "encoding/json" + "github.com/gin-gonic/gin" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + "github.com/resonatehq/resonate/internal/app/subsystems/api" + "github.com/resonatehq/resonate/internal/kernel/t_api" + "github.com/resonatehq/resonate/internal/util" ) -// CREATE +// Create + +type createCallbackHeader struct { + RequestId string `header:"request-id"` +} + +type createCallbackBody struct { + PromiseId string `json:"promiseId" binding:"required"` + RootPromiseId string `json:"rootPromiseId" binding:"required"` + Timeout int64 `json:"timeout" binding:"required"` + Recv json.RawMessage `json:"recv" binding:"required"` +} func (s *server) createCallback(c *gin.Context) { - var header service.Header + var header createCallbackHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var body *service.CreateCallbackBody + var body createCallbackBody if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.CreateCallback(&header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.CreateCallback, + CreateCallback: &t_api.CreateCallbackRequest{ + PromiseId: body.PromiseId, + RootPromiseId: body.RootPromiseId, + Timeout: body.Timeout, + Recv: body.Recv, + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), gin.H{ - "callback": res.Callback, - "promise": res.Promise, + util.Assert(res.CreateCallback != nil, "result must not be nil") + c.JSON(s.code(res.CreateCallback.Status), gin.H{ + "callback": res.CreateCallback.Callback, + "promise": res.CreateCallback.Promise, }) } diff --git a/internal/app/subsystems/api/http/http.go b/internal/app/subsystems/api/http/http.go index ab54b802..ad19a704 100644 --- a/internal/app/subsystems/api/http/http.go +++ b/internal/app/subsystems/api/http/http.go @@ -2,7 +2,7 @@ package http import ( "context" - "fmt" + "net" "net/http" "strings" "time" @@ -10,34 +10,38 @@ import ( "log/slog" "github.com/go-playground/validator/v10" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + "github.com/resonatehq/resonate/internal/app/subsystems/api" "github.com/resonatehq/resonate/internal/kernel/t_api" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" - "github.com/resonatehq/resonate/internal/api" + i_api "github.com/resonatehq/resonate/internal/api" ) type Config struct { - Host string `flag:"host" desc:"http server host" default:"0.0.0.0"` - Port int `flag:"port" desc:"http server port" default:"8001"` - Timeout time.Duration `flag:"timeout" desc:"http server graceful shutdown timeout" default:"10s"` - Auth map[string]string `flag:"auth" desc:"http basic auth username password pairs"` + Addr string `flag:"addr" desc:"http server address" default:":8001"` + Auth map[string]string `flag:"auth" desc:"http basic auth username password pairs"` + Timeout time.Duration `flag:"timeout" desc:"http server graceful shutdown timeout" default:"10s"` + TaskFrequency time.Duration `flag:"task-frequency" desc:"default task frequency" default:"1m"` } type Http struct { - addr string config *Config + listen net.Listener server *http.Server } -func New(api api.API, config *Config) api.Subsystem { +func New(a i_api.API, config *Config) (i_api.Subsystem, error) { gin.SetMode(gin.ReleaseMode) - r := gin.New() - s := &server{service: service.New(api, "http")} + handler := gin.New() + server := &server{api: api.New(a, "http"), config: config} - addr := fmt.Sprintf("%s:%d", config.Host, config.Port) + // Create a listener on specified address + listen, err := net.Listen("tcp", config.Addr) + if err != nil { + return nil, err + } // Register custom validators if v, ok := binding.Validator.Engine().(*validator.Validate); ok { @@ -45,56 +49,67 @@ func New(api api.API, config *Config) api.Subsystem { } // Middleware - r.Use(s.log) + handler.Use(server.log) // Authentication - authorized := r.Group("/") + authorized := handler.Group("/") if len(config.Auth) > 0 { authorized.Use(gin.BasicAuth(config.Auth)) } // Promises API - authorized.POST("/promises", s.createPromise) - authorized.GET("/promises", s.searchPromises) - authorized.GET("/promises/*id", s.readPromise) - authorized.PATCH("/promises/*id", s.completePromise) + authorized.POST("/promises", server.createPromise) + authorized.POST("/promises/task", server.createPromiseAndTask) + authorized.POST("/promises/callback", server.createPromiseAndCallback) + authorized.GET("/promises", server.searchPromises) + authorized.GET("/promises/*id", server.readPromise) + authorized.PATCH("/promises/*id", server.completePromise) // Callbacks API - authorized.POST("/callbacks", s.createCallback) + authorized.POST("/callbacks", server.createCallback) // Schedules API - authorized.POST("/schedules", s.createSchedule) - authorized.GET("/schedules", s.searchSchedules) - authorized.GET("/schedules/*id", s.readSchedule) - authorized.DELETE("/schedules/*id", s.deleteSchedule) + authorized.POST("/schedules", server.createSchedule) + authorized.GET("/schedules", server.searchSchedules) + authorized.GET("/schedules/*id", server.readSchedule) + authorized.DELETE("/schedules/*id", server.deleteSchedule) // Locks API - authorized.POST("/locks/acquire", s.acquireLock) - authorized.POST("/locks/release", s.releaseLock) - authorized.POST("/locks/heartbeat", s.heartbeatLocks) + authorized.POST("/locks/acquire", server.acquireLock) + authorized.POST("/locks/release", server.releaseLock) + authorized.POST("/locks/heartbeat", server.heartbeatLocks) // Tasks API - authorized.POST("/tasks/claim", s.claimTask) - authorized.POST("/tasks/complete", s.completeTask) - authorized.POST("/tasks/heartbeat", s.heartbeatTasks) + authorized.POST("/tasks/claim", server.claimTask) + authorized.GET("/tasks/claim/:id/:counter", server.claimTask) + authorized.POST("/tasks/complete", server.completeTask) + authorized.GET("/tasks/complete/:id/:counter", server.completeTask) + authorized.POST("/tasks/heartbeat", server.heartbeatTasks) + authorized.GET("/tasks/heartbeat/:id/:counter", server.heartbeatTasks) return &Http{ - addr: addr, config: config, - server: &http.Server{ - Addr: addr, - Handler: r, - }, - } + listen: listen, + server: &http.Server{Handler: handler}, + }, nil } func (h *Http) String() string { return "http" } +func (h *Http) Kind() string { + return "http" +} + +func (h *Http) Addr() string { + return h.listen.Addr().String() +} + func (h *Http) Start(errors chan<- error) { - slog.Info("starting http server", "addr", h.addr) - if err := h.server.ListenAndServe(); err != nil && err != http.ErrServerClosed { + // Start the http server + slog.Info("starting http server", "addr", h.config.Addr) + if err := h.server.Serve(h.listen); err != nil && err != http.ErrServerClosed { errors <- err } } @@ -107,7 +122,8 @@ func (h *Http) Stop() error { } type server struct { - service *service.Service + api *api.API + config *Config } func (s *server) code(status t_api.StatusCode) int { @@ -119,6 +135,8 @@ func (s *server) log(c *gin.Context) { c.Next() } +// Helper functions + func oneOfCaseInsensitive(f validator.FieldLevel) bool { fieldValue := f.Field().String() allowedValues := strings.Split(f.Param(), " ") diff --git a/internal/app/subsystems/api/http/http_test.go b/internal/app/subsystems/api/http/http_test.go index a3186327..b577945c 100644 --- a/internal/app/subsystems/api/http/http_test.go +++ b/internal/app/subsystems/api/http/http_test.go @@ -10,13 +10,6 @@ import ( "github.com/resonatehq/resonate/internal/api" "github.com/resonatehq/resonate/internal/app/subsystems/api/test" - "github.com/resonatehq/resonate/internal/kernel/t_api" - "github.com/resonatehq/resonate/internal/util" - "github.com/resonatehq/resonate/pkg/idempotency" - "github.com/resonatehq/resonate/pkg/lock" - "github.com/resonatehq/resonate/pkg/message" - "github.com/resonatehq/resonate/pkg/promise" - "github.com/resonatehq/resonate/pkg/schedule" "github.com/stretchr/testify/assert" ) @@ -27,16 +20,20 @@ type httpTest struct { client *http.Client } -func setup(auth map[string]string) *httpTest { +func setup(auth map[string]string) (*httpTest, error) { api := &test.API{} errors := make(chan error) - subsystem := New(api, &Config{ - Host: "127.0.0.1", - Port: 8888, - Auth: auth, - Timeout: 1 * time.Second, + subsystem, err := New(api, &Config{ + Addr: ":0", + Auth: auth, + Timeout: 1 * time.Second, + TaskFrequency: 1 * time.Minute, // used as default }) + if err != nil { + return nil, err + } + // start http server go subsystem.Start(errors) time.Sleep(100 * time.Millisecond) @@ -46,7 +43,7 @@ func setup(auth map[string]string) *httpTest { subsystem: subsystem, errors: errors, client: &http.Client{Timeout: 1 * time.Second}, - } + }, nil } func (t *httpTest) teardown() error { @@ -55,1431 +52,52 @@ func (t *httpTest) teardown() error { return t.subsystem.Stop() } -func TestHttpServer(t *testing.T) { +func TestHttp(t *testing.T) { for _, ts := range []struct { - name string - auth map[string]string - reqUsername string - reqPassword string - statusOveride int + name string + auth map[string]string + reqUsername string + reqPassword string + codeOverride int }{ { name: "BasicAuthCorrectCredentials", - auth: map[string]string{"user1": "pass1"}, - reqUsername: "user1", - reqPassword: "pass1", + auth: map[string]string{"user": "pass"}, + reqUsername: "user", + reqPassword: "pass", }, { - name: "BasicAuthIncorrectCredentials", - auth: map[string]string{"user1": "pass1"}, - reqUsername: "user1", - reqPassword: "notthepassword", - statusOveride: 401, + name: "BasicAuthIncorrectCredentials", + auth: map[string]string{"user": "pass"}, + reqUsername: "user", + reqPassword: "notthepassword", + codeOverride: 401, }, } { // start the server - httpTest := setup(ts.auth) + httpTest, err := setup(ts.auth) + if err != nil { + t.Fatal(err) + } t.Run(ts.name, func(t *testing.T) { - for _, tc := range []struct { - name string - path string - method string - headers map[string]string - reqBody []byte - resBody []byte - req *t_api.Request - res *t_api.Response - status int - }{ - // Promises - { - name: "ReadPromise", - path: "promises/foo", - method: "GET", - headers: map[string]string{ - "Request-Id": "ReadPromise", - }, - req: &t_api.Request{ - Kind: t_api.ReadPromise, - Tags: map[string]string{ - "id": "ReadPromise", - "name": "ReadPromise", - "protocol": "http", - }, - ReadPromise: &t_api.ReadPromiseRequest{ - Id: "foo", - }, - }, - res: &t_api.Response{ - Kind: t_api.ReadPromise, - ReadPromise: &t_api.ReadPromiseResponse{ - Status: t_api.StatusOK, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Pending, - }, - }, - }, - status: 200, - }, - { - name: "ReadPromiseWithSlash", - path: "promises/foo/bar", - method: "GET", - headers: map[string]string{ - "Request-Id": "ReadPromiseWithSlash", - }, - req: &t_api.Request{ - Kind: t_api.ReadPromise, - Tags: map[string]string{ - "id": "ReadPromiseWithSlash", - "name": "ReadPromise", - "protocol": "http", - }, - ReadPromise: &t_api.ReadPromiseRequest{ - Id: "foo/bar", - }, - }, - res: &t_api.Response{ - Kind: t_api.ReadPromise, - ReadPromise: &t_api.ReadPromiseResponse{ - Status: t_api.StatusOK, - Promise: &promise.Promise{ - Id: "foo/bar", - State: promise.Pending, - }, - }, - }, - status: 200, - }, - { - name: "ReadPromiseNotFound", - path: "promises/bar", - method: "GET", - headers: map[string]string{ - "Request-Id": "ReadPromiseNotFound", - }, - req: &t_api.Request{ - Kind: t_api.ReadPromise, - Tags: map[string]string{ - "id": "ReadPromiseNotFound", - "name": "ReadPromise", - "protocol": "http", - }, - ReadPromise: &t_api.ReadPromiseRequest{ - Id: "bar", - }, - }, - res: &t_api.Response{ - Kind: t_api.ReadPromise, - ReadPromise: &t_api.ReadPromiseResponse{ - Status: t_api.StatusPromiseNotFound, - Promise: nil, - }, - }, - status: 404, - }, - { - name: "SearchPromises", - path: "promises?id=*&limit=10", - method: "GET", - headers: map[string]string{ - "Request-Id": "SearchPromises", - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromises", - "name": "SearchPromises", - "protocol": "http", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Pending, - promise.Resolved, - promise.Rejected, - promise.Timedout, - promise.Canceled, - }, - Tags: map[string]string{}, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - status: 200, - }, - { - name: "SearchPromisesCursor", - path: "promises?cursor=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJOZXh0Ijp7ImlkIjoiKiIsInN0YXRlcyI6WyJQRU5ESU5HIl0sInRhZ3MiOnt9LCJsaW1pdCI6MTAsInNvcnRJZCI6MTAwfX0.XKusWO-Jl4v7QVIwh5Pn3oIElBvtpf0VPOLJkXPvQLk", - method: "GET", - headers: map[string]string{ - "Request-Id": "SearchPromisesCursor", - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesCursor", - "name": "SearchPromises", - "protocol": "http", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Pending, - }, - Tags: map[string]string{}, - Limit: 10, - SortId: util.ToPointer(int64(100)), - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, // not checked - Promises: []*promise.Promise{}, - }, - }, - status: 200, - }, - { - name: "SearchPromisesPending", - path: "promises?id=*&state=pending&limit=10", - method: "GET", - headers: map[string]string{ - "Request-Id": "SearchPromisesPending", - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesPending", - "name": "SearchPromises", - "protocol": "http", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Pending, - }, - Tags: map[string]string{}, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - status: 200, - }, - { - name: "SearchPromisesResolved", - path: "promises?id=*&state=resolved&limit=10", - method: "GET", - headers: map[string]string{ - "Request-Id": "SearchPromisesResolved", - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesResolved", - "name": "SearchPromises", - "protocol": "http", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Resolved, - }, - Tags: map[string]string{}, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - status: 200, - }, - { - name: "SearchPromisesRejected", - path: "promises?id=*&state=rejected&limit=10", - method: "GET", - headers: map[string]string{ - "Request-Id": "SearchPromisesRejected", - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesRejected", - "name": "SearchPromises", - "protocol": "http", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Rejected, - promise.Timedout, - promise.Canceled, - }, - Tags: map[string]string{}, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - status: 200, - }, - { - name: "SearchPromisesTags", - path: "promises?id=*&tags[resonate:invocation]=true&limit=10", - method: "GET", - headers: map[string]string{ - "Request-Id": "SearchPromisesTags", - }, - req: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": "SearchPromisesTags", - "name": "SearchPromises", - "protocol": "http", - }, - SearchPromises: &t_api.SearchPromisesRequest{ - Id: "*", - States: []promise.State{ - promise.Pending, - promise.Resolved, - promise.Rejected, - promise.Timedout, - promise.Canceled, - }, - Tags: map[string]string{ - "resonate:invocation": "true", - }, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchPromises, - SearchPromises: &t_api.SearchPromisesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Promises: []*promise.Promise{}, - }, - }, - status: 200, - }, - { - name: "SearchPromisesInvalidQuery", - path: "promises?id=", - method: "GET", - req: nil, - res: nil, - status: 400, - }, - { - name: "SearchPromisesInvalidLimit", - path: "promises?id=*&limit=0", - method: "GET", - req: nil, - res: nil, - status: 400, - }, - { - name: "SearchPromisesInvalidState", - path: "promises?id=*&state=x", - method: "GET", - req: nil, - res: nil, - status: 400, - }, - { - name: "SearchPromisesInvalidTags", - path: "promises?id=*&tags=x", - method: "GET", - req: nil, - res: nil, - status: 400, - }, - { - name: "CreatePromise", - path: "promises", - method: "POST", - headers: map[string]string{ - "Request-Id": "CreatePromise", - "Idempotency-Key": "bar", - "Strict": "true", - }, - reqBody: []byte(`{ - "id": "foo/bar", - "param": { - "headers": {"a":"a","b":"b","c":"c"}, - "data": "cGVuZGluZw==" - }, - "timeout": 1 - }`), - req: &t_api.Request{ - Kind: t_api.CreatePromise, - Tags: map[string]string{ - "id": "CreatePromise", - "name": "CreatePromise", - "protocol": "http", - }, - CreatePromise: &t_api.CreatePromiseRequest{ - Id: "foo/bar", - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - Strict: true, - Param: promise.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("pending"), - }, - Timeout: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.CreatePromise, - CreatePromise: &t_api.CreatePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo/bar", - State: promise.Pending, - }, - }, - }, - status: 201, - }, - { - name: "CreatePromiseMinimal", - path: "promises", - method: "POST", - headers: map[string]string{ - "Request-Id": "CreatePromiseMinimal", - }, - reqBody: []byte(`{ - "id": "foo", - "timeout": 1 - }`), - req: &t_api.Request{ - Kind: t_api.CreatePromise, - Tags: map[string]string{ - "id": "CreatePromiseMinimal", - "name": "CreatePromise", - "protocol": "http", - }, - CreatePromise: &t_api.CreatePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - Param: promise.Value{ - Headers: nil, - Data: nil, - }, - Timeout: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.CreatePromise, - CreatePromise: &t_api.CreatePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Pending, - }, - }, - }, - status: 201, - }, - { - name: "CancelPromise", - path: "promises/foo/bar", - method: "PATCH", - headers: map[string]string{ - "Request-Id": "CancelPromise", - "Idempotency-Key": "bar", - "Strict": "true", - }, - reqBody: []byte(`{ - "state": "REJECTED_CANCELED", - "value": { - "headers": {"a":"a","b":"b","c":"c"}, - "data": "Y2FuY2Vs" - } - }`), - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "CancelPromise", - "name": "CompletePromise", - "protocol": "http", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo/bar", - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - Strict: true, - State: promise.Canceled, - Value: promise.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("cancel"), - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo/bar", - State: promise.Canceled, - }, - }, - }, - status: 201, - }, - { - name: "CancelPromiseMinimal", - path: "promises/foo", - method: "PATCH", - headers: map[string]string{ - "Request-Id": "CancelPromiseMinimal", - }, - reqBody: []byte(`{ - "state": "REJECTED_CANCELED" - }`), - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "CancelPromiseMinimal", - "name": "CompletePromise", - "protocol": "http", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - State: promise.Canceled, - Value: promise.Value{ - Headers: nil, - Data: nil, - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Canceled, - }, - }, - }, - status: 201, - }, - { - name: "ResolvePromise", - path: "promises/foo/bar", - method: "PATCH", - headers: map[string]string{ - "Request-Id": "ResolvePromise", - "Idempotency-Key": "bar", - "Strict": "true", - }, - reqBody: []byte(`{ - "state": "RESOLVED", - "value": { - "headers": {"a":"a","b":"b","c":"c"}, - "data": "cmVzb2x2ZQ==" - } - }`), - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "ResolvePromise", - "name": "CompletePromise", - "protocol": "http", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo/bar", - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - Strict: true, - State: promise.Resolved, - Value: promise.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("resolve"), - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo/bar", - State: promise.Resolved, - }, - }, - }, - status: 201, - }, - { - name: "ResolvePromiseMinimal", - path: "promises/foo", - method: "PATCH", - headers: map[string]string{ - "Request-Id": "ResolvePromiseMinimal", - }, - reqBody: []byte(`{ - "state": "RESOLVED" - }`), - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "ResolvePromiseMinimal", - "name": "CompletePromise", - "protocol": "http", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - State: promise.Resolved, - Value: promise.Value{ - Headers: nil, - Data: nil, - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Resolved, - }, - }, - }, - status: 201, - }, - { - name: "RejectPromise", - path: "promises/foo/bar", - method: "PATCH", - headers: map[string]string{ - "Request-Id": "RejectPromise", - "Idempotency-Key": "bar", - "Strict": "true", - }, - reqBody: []byte(`{ - "state": "REJECTED", - "value": { - "headers": {"a":"a","b":"b","c":"c"}, - "data": "cmVqZWN0" - } - }`), - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "RejectPromise", - "name": "CompletePromise", - "protocol": "http", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo/bar", - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - Strict: true, - State: promise.Rejected, - Value: promise.Value{ - Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, - Data: []byte("reject"), - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo/bar", - State: promise.Rejected, - }, - }, - }, - status: 201, - }, - { - name: "RejectPromiseMinimal", - path: "promises/foo", - method: "PATCH", - headers: map[string]string{ - "Request-Id": "RejectPromiseMinimal", - }, - reqBody: []byte(`{ - "state": "REJECTED" - }`), - req: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": "RejectPromiseMinimal", - "name": "CompletePromise", - "protocol": "http", - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: "foo", - IdempotencyKey: nil, - Strict: false, - State: promise.Rejected, - Value: promise.Value{ - Headers: nil, - Data: nil, - }, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompletePromise, - CompletePromise: &t_api.CompletePromiseResponse{ - Status: t_api.StatusCreated, - Promise: &promise.Promise{ - Id: "foo", - State: promise.Rejected, - }, - }, - }, - status: 201, - }, - - // Callbacks - { - name: "CreateCallback", - path: "callbacks", - method: "POST", - headers: map[string]string{ - "Request-Id": "CreateCallback", - }, - reqBody: []byte(`{ - "promiseId": "foo", - "rootPromiseId": "bar", - "timeout": 1, - "recv": "foo" - }`), - req: &t_api.Request{ - Kind: t_api.CreateCallback, - Tags: map[string]string{ - "id": "CreateCallback", - "name": "CreateCallback", - "protocol": "http", - }, - CreateCallback: &t_api.CreateCallbackRequest{ - PromiseId: "foo", - RootPromiseId: "bar", - Timeout: 1, - Recv: []byte(`"foo"`), - }, - }, - res: &t_api.Response{ - Kind: t_api.CreateCallback, - CreateCallback: &t_api.CreateCallbackResponse{ - Status: t_api.StatusCreated, - }, - }, - status: 201, - }, - { - name: "CreateCallbackPhysicalReceiver", - path: "callbacks", - method: "POST", - headers: map[string]string{ - "Request-Id": "CreateCallbackPhysicalReceiver", - }, - reqBody: []byte(`{ - "promiseId": "foo", - "rootPromiseId": "bar", - "timeout": 1, - "recv": {"type": "http", "data": {"url": "http://localhost:3000"}} - }`), - req: &t_api.Request{ - Kind: t_api.CreateCallback, - Tags: map[string]string{ - "id": "CreateCallbackPhysicalReceiver", - "name": "CreateCallback", - "protocol": "http", - }, - CreateCallback: &t_api.CreateCallbackRequest{ - PromiseId: "foo", - RootPromiseId: "bar", - Timeout: 1, - Recv: []byte(`{"type": "http", "data": {"url": "http://localhost:3000"}}`), - }, - }, - res: &t_api.Response{ - Kind: t_api.CreateCallback, - CreateCallback: &t_api.CreateCallbackResponse{ - Status: t_api.StatusCreated, - }, - }, - status: 201, - }, - { - name: "CreateCallbackNotFound", - path: "callbacks", - method: "POST", - headers: map[string]string{ - "Request-Id": "CreateCallbackNotFound", - }, - reqBody: []byte(`{ - "promiseId": "foo", - "rootPromiseId": "bar", - "timeout": 1, - "recv": "foo" - }`), - req: &t_api.Request{ - Kind: t_api.CreateCallback, - Tags: map[string]string{ - "id": "CreateCallbackNotFound", - "name": "CreateCallback", - "protocol": "http", - }, - CreateCallback: &t_api.CreateCallbackRequest{ - PromiseId: "foo", - RootPromiseId: "bar", - Timeout: 1, - Recv: []byte(`"foo"`), - }, - }, - res: &t_api.Response{ - Kind: t_api.CreateCallback, - CreateCallback: &t_api.CreateCallbackResponse{ - Status: t_api.StatusPromiseNotFound, - }, - }, - status: 404, - }, - - // Schedules - { - name: "ReadSchedule", - path: "schedules/foo", - method: "GET", - headers: map[string]string{ - "Request-Id": "ReadSchedule", - }, - req: &t_api.Request{ - Kind: t_api.ReadSchedule, - Tags: map[string]string{ - "id": "ReadSchedule", - "name": "ReadSchedule", - "protocol": "http", - }, - ReadSchedule: &t_api.ReadScheduleRequest{ - Id: "foo", - }, - }, - res: &t_api.Response{ - Kind: t_api.ReadSchedule, - ReadSchedule: &t_api.ReadScheduleResponse{ - Status: t_api.StatusOK, - Schedule: &schedule.Schedule{ - Id: "foo", - Description: "", - Cron: "* * * * * *", - PromiseId: "foo.{{.timestamp}}", - PromiseTimeout: 1000000, - }, - }, - }, - status: 200, - }, - { - name: "SearchSchedules", - path: "schedules?id=*&limit=10", - method: "GET", - headers: map[string]string{ - "Request-Id": "SearchSchedules", - }, - req: &t_api.Request{ - Kind: t_api.SearchSchedules, - Tags: map[string]string{ - "id": "SearchSchedules", - "name": "SearchSchedules", - "protocol": "http", - }, - SearchSchedules: &t_api.SearchSchedulesRequest{ - Id: "*", - Tags: map[string]string{}, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchSchedules, - SearchSchedules: &t_api.SearchSchedulesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Schedules: []*schedule.Schedule{}, - }, - }, - status: 200, - }, - { - name: "SearchSchedulesTags", - path: "schedules?id=*&tags[foo]=bar&limit=10", - method: "GET", - headers: map[string]string{ - "Request-Id": "SearchSchedulesTags", - }, - req: &t_api.Request{ - Kind: t_api.SearchSchedules, - Tags: map[string]string{ - "id": "SearchSchedulesTags", - "name": "SearchSchedules", - "protocol": "http", - }, - SearchSchedules: &t_api.SearchSchedulesRequest{ - Id: "*", - Tags: map[string]string{ - "foo": "bar", - }, - Limit: 10, - }, - }, - res: &t_api.Response{ - Kind: t_api.SearchSchedules, - SearchSchedules: &t_api.SearchSchedulesResponse{ - Status: t_api.StatusOK, - Cursor: nil, - Schedules: []*schedule.Schedule{}, - }, - }, - status: 200, - }, - { - name: "SearchSchedulesInvalidQuery", - path: "schedules?id=", - method: "GET", - req: nil, - res: nil, - status: 400, - }, - { - name: "SearchSchedulesInvalidLimit", - path: "schedules?id=*&limit=0", - method: "GET", - req: nil, - res: nil, - status: 400, - }, - { - name: "SearchSchedulesInvalidTags", - path: "schedules?id=*&tags=x", - method: "GET", - req: nil, - res: nil, - status: 400, - }, - { - name: "CreateSchedule", - path: "schedules", - method: "POST", - headers: map[string]string{ - "Request-Id": "CreateSchedule", - "Idempotency-Key": "bar", - }, - reqBody: []byte(`{ - "id": "foo", - "desc": "", - "cron": "* * * * * *", - "promiseId": "foo.{{.timestamp}}", - "promiseTimeout": 1000000 - }`), - req: &t_api.Request{ - Kind: t_api.CreateSchedule, - Tags: map[string]string{ - "id": "CreateSchedule", - "name": "CreateSchedule", - "protocol": "http", - }, - CreateSchedule: &t_api.CreateScheduleRequest{ - Id: "foo", - IdempotencyKey: util.ToPointer(idempotency.Key("bar")), - Cron: "* * * * * *", - PromiseId: "foo.{{.timestamp}}", - PromiseTimeout: 1000000, - }, - }, - res: &t_api.Response{ - Kind: t_api.CreateSchedule, - CreateSchedule: &t_api.CreateScheduleResponse{ - Status: t_api.StatusCreated, - Schedule: &schedule.Schedule{ - Id: "foo", - Description: "", - Cron: "* * * * * *", - PromiseId: "foo.{{.timestamp}}", - PromiseTimeout: 1000000, - }, - }, - }, - status: 201, - }, - { - name: "DeleteSchedule", - path: "schedules/foo", - method: "DELETE", - headers: map[string]string{ - "Request-Id": "DeleteSchedule", - }, - req: &t_api.Request{ - Kind: t_api.DeleteSchedule, - Tags: map[string]string{ - "id": "DeleteSchedule", - "name": "DeleteSchedule", - "protocol": "http", - }, - DeleteSchedule: &t_api.DeleteScheduleRequest{ - Id: "foo", - }, - }, - res: &t_api.Response{ - Kind: t_api.DeleteSchedule, - DeleteSchedule: &t_api.DeleteScheduleResponse{ - Status: t_api.StatusNoContent, - }, - }, - status: 204, - }, - - // Tasks - { - name: "ClaimTask", - path: "tasks/claim", - method: "POST", - headers: map[string]string{ - "Request-Id": "ClaimTask", - }, - reqBody: []byte(`{ - "id": "foo", - "processId": "bar", - "counter": 0, - "frequency": 1 - }`), - req: &t_api.Request{ - Kind: t_api.ClaimTask, - Tags: map[string]string{ - "id": "ClaimTask", - "name": "ClaimTask", - "protocol": "http", - }, - ClaimTask: &t_api.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 0, - Frequency: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.ClaimTask, - ClaimTask: &t_api.ClaimTaskResponse{ - Status: t_api.StatusCreated, - Mesg: &message.Mesg{}, - }, - }, - status: 201, - }, - { - name: "ClaimTaskInvoke", - path: "tasks/claim", - method: "POST", - headers: map[string]string{ - "Request-Id": "ClaimTaskInvoke", - }, - reqBody: []byte(`{ - "id": "foo", - "processId": "bar", - "counter": 1, - "frequency": 1 - }`), - resBody: []byte(`{"type":"invoke","promises":{"root":{"id":"foo","state":"PENDING","param":{},"value":{},"timeout":0}}}`), - req: &t_api.Request{ - Kind: t_api.ClaimTask, - Tags: map[string]string{ - "id": "ClaimTaskInvoke", - "name": "ClaimTask", - "protocol": "http", - }, - ClaimTask: &t_api.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 1, - Frequency: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.ClaimTask, - ClaimTask: &t_api.ClaimTaskResponse{ - Status: t_api.StatusCreated, - Mesg: &message.Mesg{ - Type: message.Invoke, - Promises: map[string]*promise.Promise{ - "root": {Id: "foo", State: promise.Pending}, - }, - }, - }, - }, - status: 201, - }, - { - name: "ClaimTaskResume", - path: "tasks/claim", - method: "POST", - headers: map[string]string{ - "Request-Id": "ClaimTaskResume", - }, - reqBody: []byte(`{ - "id": "foo", - "processId": "bar", - "counter": 2, - "frequency": 1 - }`), - resBody: []byte(`{"type":"invoke","promises":{"leaf":{"id":"bar","state":"RESOLVED","param":{},"value":{},"timeout":0},"root":{"id":"foo","state":"PENDING","param":{},"value":{},"timeout":0}}}`), - req: &t_api.Request{ - Kind: t_api.ClaimTask, - Tags: map[string]string{ - "id": "ClaimTaskResume", - "name": "ClaimTask", - "protocol": "http", - }, - ClaimTask: &t_api.ClaimTaskRequest{ - Id: "foo", - ProcessId: "bar", - Counter: 2, - Frequency: 1, - }, - }, - res: &t_api.Response{ - Kind: t_api.ClaimTask, - ClaimTask: &t_api.ClaimTaskResponse{ - Status: t_api.StatusCreated, - Mesg: &message.Mesg{ - Type: message.Invoke, - Promises: map[string]*promise.Promise{ - "root": {Id: "foo", State: promise.Pending}, - "leaf": {Id: "bar", State: promise.Resolved}, - }, - }, - }, - }, - status: 201, - }, - { - name: "ClaimTaskNoId", - path: "tasks/claim", - method: "POST", - headers: map[string]string{ - "Request-Id": "ClaimTaskNoId", - }, - reqBody: []byte(`{ - "processId": "bar", - "counter": 0, - "frequency": 1 - }`), - req: nil, - res: nil, - status: 400, - }, - { - name: "ClaimTaskNoProcessId", - path: "tasks/claim", - method: "POST", - headers: map[string]string{ - "Request-Id": "ClaimTaskNoProcessId", - }, - reqBody: []byte(`{ - "id": "foo", - "counter": 0, - "frequency": 1 - }`), - req: nil, - res: nil, - status: 400, - }, - { - name: "ClaimTaskNoFrequency", - path: "tasks/claim", - method: "POST", - headers: map[string]string{ - "Request-Id": "ClaimTaskNoFrequency", - }, - reqBody: []byte(`{ - "id": "foo", - "counter": 0, - "frequency": 0 - }`), - req: nil, - res: nil, - status: 400, - }, - { - name: "CompleteTask", - path: "tasks/complete", - method: "POST", - headers: map[string]string{ - "Request-Id": "CompleteTask", - }, - reqBody: []byte(`{ - "id": "foo", - "counter": 0 - }`), - req: &t_api.Request{ - Kind: t_api.CompleteTask, - Tags: map[string]string{ - "id": "CompleteTask", - "name": "CompleteTask", - "protocol": "http", - }, - CompleteTask: &t_api.CompleteTaskRequest{ - Id: "foo", - Counter: 0, - }, - }, - res: &t_api.Response{ - Kind: t_api.CompleteTask, - CompleteTask: &t_api.CompleteTaskResponse{ - Status: t_api.StatusCreated, - }, - }, - status: 201, - }, - { - name: "CompleteTaskNoId", - path: "tasks/complete", - method: "POST", - headers: map[string]string{ - "Request-Id": "CompleteTaskNoId", - }, - reqBody: []byte(`{ - "counter": 0 - }`), - req: nil, - res: nil, - status: 400, - }, - { - name: "HeartbeatTasks", - path: "tasks/heartbeat", - method: "POST", - headers: map[string]string{ - "Request-Id": "HeartbeatTasks", - }, - reqBody: []byte(`{ - "processId": "bar" - }`), - req: &t_api.Request{ - Kind: t_api.HeartbeatTasks, - Tags: map[string]string{ - "id": "HeartbeatTasks", - "name": "HeartbeatTasks", - "protocol": "http", - }, - HeartbeatTasks: &t_api.HeartbeatTasksRequest{ - ProcessId: "bar", - }, - }, - res: &t_api.Response{ - Kind: t_api.HeartbeatTasks, - HeartbeatTasks: &t_api.HeartbeatTasksResponse{ - Status: t_api.StatusOK, - TasksAffected: 1, - }, - }, - status: 200, - }, - { - name: "HeartbeatTasksNoProcessId", - path: "tasks/heartbeat", - method: "POST", - headers: map[string]string{ - "Request-Id": "HeartbeatTasksNoProcessId", - }, - reqBody: []byte(`{}`), - req: nil, - res: nil, - status: 400, - }, + for _, tc := range test.TestCases { + t.Run(tc.Name, func(t *testing.T) { + if tc.Req != nil { + // set protocol specific header + tc.Req.Tags["protocol"] = "http" + } - // Locks - { - name: "AcquireLock", - path: "locks/acquire", - method: "POST", - headers: map[string]string{ - "Request-Id": "AcquireLock", - }, - reqBody: []byte(`{ - "resourceId": "foo", - "processId": "bar", - "executionId": "baz", - "expiryInMilliseconds": 10000 - }`), - req: &t_api.Request{ - Kind: t_api.AcquireLock, - Tags: map[string]string{ - "id": "AcquireLock", - "name": "AcquireLock", - "protocol": "http", - }, - AcquireLock: &t_api.AcquireLockRequest{ - ResourceId: "foo", - ProcessId: "bar", - ExecutionId: "baz", - ExpiryInMilliseconds: 10_000, - }, - }, - res: &t_api.Response{ - Kind: t_api.AcquireLock, - AcquireLock: &t_api.AcquireLockResponse{ - Status: t_api.StatusCreated, - Lock: &lock.Lock{ - ResourceId: "foo", - ProcessId: "bar", - ExecutionId: "baz", - ExpiryInMilliseconds: 10_000, - }, - }, - }, - status: 201, - }, - { - name: "AcquireLockNoExecutionId", - path: "locks/acquire", - method: "POST", - reqBody: []byte(`{ - "resourceId": "foo", - "processId": "bar", - "executionId": "", - "expiryInMilliseconds": 10000 - }`), - req: nil, - res: nil, - status: 400, - }, - { - name: "ReleaseLock", - path: "locks/release", - method: "POST", - headers: map[string]string{ - "Request-Id": "ReleaseLock", - }, - reqBody: []byte(`{ - "resourceId": "foo", - "executionId": "baz" - }`), - req: &t_api.Request{ - Kind: t_api.ReleaseLock, - Tags: map[string]string{ - "id": "ReleaseLock", - "name": "ReleaseLock", - "protocol": "http", - }, - ReleaseLock: &t_api.ReleaseLockRequest{ - ResourceId: "foo", - ExecutionId: "baz", - }, - }, - res: &t_api.Response{ - Kind: t_api.ReleaseLock, - ReleaseLock: &t_api.ReleaseLockResponse{ - Status: t_api.StatusNoContent, - }, - }, - status: 204, - }, - { - name: "ReleaseLockNoResourceId", - path: "locks/release", - method: "POST", - reqBody: []byte(`{ - "resourceId": "", - "executionId": "baz" - }`), - req: nil, - res: nil, - status: 400, - }, - { - name: "HeartbeatLocks", - path: "locks/heartbeat", - method: "POST", - headers: map[string]string{ - "Request-Id": "HeartbeatLocks", - }, - reqBody: []byte(`{ - "processId": "bar" - }`), - req: &t_api.Request{ - Kind: t_api.HeartbeatLocks, - Tags: map[string]string{ - "id": "HeartbeatLocks", - "name": "HeartbeatLocks", - "protocol": "http", - }, - HeartbeatLocks: &t_api.HeartbeatLocksRequest{ - ProcessId: "bar", - }, - }, - res: &t_api.Response{ - Kind: t_api.HeartbeatLocks, - HeartbeatLocks: &t_api.HeartbeatLocksResponse{ - Status: t_api.StatusOK, - LocksAffected: 0, - }, - }, - status: 200, - }, - { - name: "HeartbeatLocksNoProcessId", - path: "locks/heartbeat", - method: "POST", - reqBody: []byte(`{ - "processId": "", - "timeout": 1736571600000 - }`), - req: nil, - res: nil, - status: 400, - }, - } { - t.Run(tc.name, func(t *testing.T) { - httpTest.Load(t, tc.req, tc.res) + httpTest.Load(t, tc.Req, tc.Res) - req, err := http.NewRequest(tc.method, fmt.Sprintf("http://127.0.0.1:8888/%s", tc.path), bytes.NewBuffer(tc.reqBody)) + req, err := http.NewRequest(tc.Http.Req.Method, fmt.Sprintf("http://%s/%s", httpTest.subsystem.Addr(), tc.Http.Req.Path), bytes.NewBuffer(tc.Http.Req.Body)) if err != nil { t.Fatal(err) } // set headers req.Header.Set("Content-Type", "application/json") - for key, val := range tc.headers { + for key, val := range tc.Http.Req.Headers { req.Header.Set(key, val) } @@ -1499,16 +117,16 @@ func TestHttpServer(t *testing.T) { t.Fatal(err) } - // apply override status if applicable - status := tc.status - if ts.statusOveride != 0 { - status = ts.statusOveride + // apply override code if applicable + code := tc.Http.Res.Code + if ts.codeOverride != 0 { + code = ts.codeOverride } - assert.Equal(t, status, res.StatusCode, string(body)) + assert.Equal(t, code, res.StatusCode, string(body)) - if tc.resBody != nil && status >= 200 && status < 300 { - assert.Equal(t, tc.resBody, body) + if tc.Http.Res.Body != nil && code >= 200 && code < 300 { + assert.Equal(t, tc.Http.Res.Body, body) } select { diff --git a/internal/app/subsystems/api/http/lock.go b/internal/app/subsystems/api/http/lock.go index 49f88d81..8d5b14a2 100644 --- a/internal/app/subsystems/api/http/lock.go +++ b/internal/app/subsystems/api/http/lock.go @@ -2,103 +2,137 @@ package http import ( "github.com/gin-gonic/gin" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + "github.com/resonatehq/resonate/internal/app/subsystems/api" + "github.com/resonatehq/resonate/internal/kernel/t_api" + "github.com/resonatehq/resonate/internal/util" ) -// ACQUIRE +// Acquire + +type acquireLockHeader struct { + RequestId string `header:"request-id"` +} + +type acquireLockBody struct { + ResourceId string `json:"resourceId" binding:"required"` + ExecutionId string `json:"executionId" binding:"required"` + ProcessId string `json:"processId" binding:"required"` + ExpiryInMilliseconds int64 `json:"expiryInMilliseconds" binding:"required"` +} func (s *server) acquireLock(c *gin.Context) { - var header service.Header + var header acquireLockHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var body *service.AcquireLockBody + var body acquireLockBody if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.AcquireLock(&header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.AcquireLock, + AcquireLock: &t_api.AcquireLockRequest{ + ResourceId: body.ResourceId, + ExecutionId: body.ExecutionId, + ProcessId: body.ProcessId, + ExpiryInMilliseconds: body.ExpiryInMilliseconds, + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), res.Lock) + util.Assert(res.AcquireLock != nil, "result must not be nil") + c.JSON(s.code(res.AcquireLock.Status), res.AcquireLock.Lock) } -// RELEASE +// Release + +type releaseLockHeader struct { + RequestId string `header:"request-id"` +} + +type releaseLockBody struct { + ResourceId string `json:"resourceId" binding:"required"` + ExecutionId string `json:"executionId" binding:"required"` +} func (s *server) releaseLock(c *gin.Context) { - var header service.Header + var header releaseLockHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var body *service.ReleaseLockBody + var body releaseLockBody if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.ReleaseLock(&header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.ReleaseLock, + ReleaseLock: &t_api.ReleaseLockRequest{ + ResourceId: body.ResourceId, + ExecutionId: body.ExecutionId, + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), nil) + util.Assert(res.ReleaseLock != nil, "result must not be nil") + c.JSON(s.code(res.ReleaseLock.Status), nil) } -// HEARTBEAT +// Heartbeat + +type heartbeatLocksHeader struct { + RequestId string `header:"request-id"` +} + +type heartbeatLocksBody struct { + ProcessId string `json:"processId" binding:"required"` +} func (s *server) heartbeatLocks(c *gin.Context) { - var header service.Header + var header heartbeatLocksHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var body *service.HeartbeatBody + var body heartbeatLocksBody if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.Heartbeat(&header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.HeartbeatLocks, + HeartbeatLocks: &t_api.HeartbeatLocksRequest{ + ProcessId: body.ProcessId, + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), gin.H{ - "locksAffected": res.LocksAffected, + util.Assert(res.HeartbeatLocks != nil, "result must not be nil") + c.JSON(s.code(res.HeartbeatLocks.Status), gin.H{ + "locksAffected": res.HeartbeatLocks.LocksAffected, }) } diff --git a/internal/app/subsystems/api/http/promise.go b/internal/app/subsystems/api/http/promise.go index c4738960..953f625d 100644 --- a/internal/app/subsystems/api/http/promise.go +++ b/internal/app/subsystems/api/http/promise.go @@ -1,57 +1,73 @@ package http import ( + "encoding/json" "errors" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + "github.com/resonatehq/resonate/internal/app/subsystems/api" + "github.com/resonatehq/resonate/internal/kernel/t_api" + "github.com/resonatehq/resonate/internal/util" + "github.com/resonatehq/resonate/pkg/idempotency" "github.com/resonatehq/resonate/pkg/promise" "github.com/gin-gonic/gin" ) -// Read Promise +// Read -func (s *server) readPromise(c *gin.Context) { - id := extractId(c.Param("id")) +type readPromiseHeader struct { + RequestId string `header:"request-id"` +} - var header service.Header +func (s *server) readPromise(c *gin.Context) { + var header readPromiseHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.ReadPromise(id, &header) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.ReadPromise, + ReadPromise: &t_api.ReadPromiseRequest{ + Id: extractId(c.Param("id")), + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), res.Promise) + util.Assert(res.ReadPromise != nil, "result must not be nil") + c.JSON(s.code(res.ReadPromise.Status), res.ReadPromise.Promise) } -// Search Promise +// Search + +type searchPromisesHeader struct { + RequestId string `header:"request-id"` +} + +type searchPromisesParams struct { + Id *string `form:"id" json:"id" binding:"omitempty,min=1"` + State *string `form:"state" json:"state" binding:"omitempty,oneofcaseinsensitive=pending resolved rejected"` + Tags map[string]string `form:"tags" json:"tags,omitempty"` + Limit *int `form:"limit" json:"limit" binding:"omitempty,gte=0,lte=100"` + Cursor *string `form:"cursor" json:"cursor,omitempty"` +} func (s *server) searchPromises(c *gin.Context) { - var header service.Header + var header searchPromisesHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var params service.SearchPromisesParams + var params searchPromisesParams if err := c.ShouldBindQuery(¶ms); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } @@ -59,90 +75,254 @@ func (s *server) searchPromises(c *gin.Context) { // see: https://github.com/gin-gonic/gin/issues/2606 params.Tags = c.QueryMap("tags") - res, err := s.service.SearchPromises(&header, ¶ms) + req, err := s.api.SearchPromises( + util.SafeDeref(params.Id), + util.SafeDeref(params.State), + params.Tags, + util.SafeDeref(params.Limit), + util.SafeDeref(params.Cursor), + ) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), gin.H{ - "cursor": res.Cursor, - "promises": res.Promises, + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.SearchPromises, + SearchPromises: req, }) + if err != nil { + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + util.Assert(res.SearchPromises != nil, "result must not be nil") + c.JSON(s.code(res.SearchPromises.Status), gin.H{ + "promises": res.SearchPromises.Promises, + "cursor": res.SearchPromises.Cursor, + }) +} + +// Create + +type createPromiseHeader struct { + RequestId string `header:"request-id"` + IdempotencyKey *idempotency.Key `header:"idempotency-key"` + Strict bool `header:"strict"` } -// Create Promise +type createPromiseBody struct { + Id string `json:"id" binding:"required"` + Param promise.Value `json:"param"` + Timeout int64 `json:"timeout" binding:"required"` + Tags map[string]string `json:"tags,omitempty"` +} func (s *server) createPromise(c *gin.Context) { - var header service.CreatePromiseHeader + var header createPromiseHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) + err := api.RequestValidationError(err) c.JSON(s.code(err.Code), gin.H{ "error": err, }) return } - var body *promise.Promise + var body createPromiseBody if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.CreatePromise(&header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.CreatePromise, + CreatePromise: &t_api.CreatePromiseRequest{ + Id: body.Id, + IdempotencyKey: header.IdempotencyKey, + Strict: header.Strict, + Param: body.Param, + Timeout: body.Timeout, + Tags: body.Tags, + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), res.Promise) + util.Assert(res.CreatePromise != nil, "result must not be nil") + c.JSON(s.code(res.CreatePromise.Status), res.CreatePromise.Promise) } -// Complete Promise +type createPromiseAndTaskBody struct { + Promise createPromiseBody `json:"promise" binding:"required"` + Task createPromiseTaskBody `json:"task" binding:"required"` +} -func (s *server) completePromise(c *gin.Context) { - id := extractId(c.Param("id")) +type createPromiseTaskBody struct { + ProcessId string `json:"processId" binding:"required"` + Frequency int `json:"frequency" binding:"required"` + Recv json.RawMessage `json:"recv" binding:"required"` +} - var header service.CompletePromiseHeader +func (s *server) createPromiseAndTask(c *gin.Context) { + var header createPromiseHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) + err := api.RequestValidationError(err) c.JSON(s.code(err.Code), gin.H{ "error": err, }) return } - var body *service.CompletePromiseBody + var body createPromiseAndTaskBody if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.CreatePromiseAndTask, + CreatePromiseAndTask: &t_api.CreatePromiseAndTaskRequest{ + Promise: &t_api.CreatePromiseRequest{ + Id: body.Promise.Id, + IdempotencyKey: header.IdempotencyKey, + Strict: header.Strict, + Param: body.Promise.Param, + Timeout: body.Promise.Timeout, + Tags: body.Promise.Tags, + }, + Task: &t_api.CreateTaskRequest{ + PromiseId: body.Promise.Id, + ProcessId: body.Task.ProcessId, + Frequency: body.Task.Frequency, + Timeout: body.Promise.Timeout, + Recv: body.Task.Recv, + }, + }, + }) + if err != nil { + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + util.Assert(res.CreatePromiseAndTask != nil, "result must not be nil") + c.JSON(s.code(res.CreatePromiseAndTask.Status), gin.H{ + "promise": res.CreatePromiseAndTask.Promise, + "task": res.CreatePromiseAndTask.Task, + }) +} + +type createPromiseAndCallbackBody struct { + Promise createPromiseBody `json:"promise" binding:"required"` + Callback createPromiseCallbackBody `json:"callback" binding:"required"` +} + +type createPromiseCallbackBody struct { + RootPromiseId string `json:"rootPromiseId" binding:"required"` + Timeout int64 `json:"timeout" binding:"required"` + Recv json.RawMessage `json:"recv" binding:"required"` +} + +func (s *server) createPromiseAndCallback(c *gin.Context) { + var header createPromiseHeader + if err := c.ShouldBindHeader(&header); err != nil { + err := api.RequestValidationError(err) c.JSON(s.code(err.Code), gin.H{ "error": err, }) return } + var body createPromiseAndCallbackBody + if err := c.ShouldBindJSON(&body); err != nil { + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.CreatePromiseAndCallback, + CreatePromiseAndCallback: &t_api.CreatePromiseAndCallbackRequest{ + Promise: &t_api.CreatePromiseRequest{ + Id: body.Promise.Id, + IdempotencyKey: header.IdempotencyKey, + Strict: header.Strict, + Param: body.Promise.Param, + Timeout: body.Promise.Timeout, + Tags: body.Promise.Tags, + }, + Callback: &t_api.CreateCallbackRequest{ + PromiseId: body.Promise.Id, + RootPromiseId: body.Callback.RootPromiseId, + Timeout: body.Callback.Timeout, + Recv: body.Callback.Recv, + }, + }, + }) + if err != nil { + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + util.Assert(res.CreatePromiseAndCallback != nil, "result must not be nil") + c.JSON(s.code(res.CreatePromiseAndCallback.Status), gin.H{ + "promise": res.CreatePromiseAndCallback.Promise, + "callback": res.CreatePromiseAndCallback.Callback, + }) +} + +// Complete + +type completePromiseHeader struct { + RequestId string `header:"request-id"` + IdempotencyKey *idempotency.Key `header:"idempotency-key"` + Strict bool `header:"strict"` +} + +type completePromiseBody struct { + State promise.State `json:"state" binding:"required"` + Value promise.Value `json:"value"` +} + +func (s *server) completePromise(c *gin.Context) { + var header completePromiseHeader + if err := c.ShouldBindHeader(&header); err != nil { + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + var body completePromiseBody + if err := c.ShouldBindJSON(&body); err != nil { + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + if !body.State.In(promise.Resolved | promise.Rejected | promise.Canceled) { - err := service.RequestValidationError(errors.New("invalid state")) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(errors.New("The field state must be one of resolved, rejected, rejected_canceled.")) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.CompletePromise(id, body.State, &header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: extractId(c.Param("id")), + IdempotencyKey: header.IdempotencyKey, + Strict: header.Strict, + State: body.State, + Value: body.Value, + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), res.Promise) + util.Assert(res.CompletePromise != nil, "result must not be nil") + c.JSON(s.code(res.CompletePromise.Status), res.CompletePromise.Promise) } diff --git a/internal/app/subsystems/api/http/schedule.go b/internal/app/subsystems/api/http/schedule.go index bda87686..5846b225 100644 --- a/internal/app/subsystems/api/http/schedule.go +++ b/internal/app/subsystems/api/http/schedule.go @@ -2,52 +2,67 @@ package http import ( "github.com/gin-gonic/gin" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + "github.com/resonatehq/resonate/internal/app/subsystems/api" + "github.com/resonatehq/resonate/internal/kernel/t_api" + "github.com/resonatehq/resonate/internal/util" + "github.com/resonatehq/resonate/pkg/idempotency" + "github.com/resonatehq/resonate/pkg/promise" ) -// READ +// Read -func (s *server) readSchedule(c *gin.Context) { - id := extractId(c.Param("id")) +type readScheduleHeader struct { + RequestId string `header:"request-id"` +} - var header service.Header +func (s *server) readSchedule(c *gin.Context) { + var header readScheduleHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.ReadSchedule(id, &header) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.ReadSchedule, + ReadSchedule: &t_api.ReadScheduleRequest{ + Id: extractId(c.Param("id")), + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), res.Schedule) + util.Assert(res.ReadSchedule != nil, "result must not be nil") + c.JSON(s.code(res.ReadSchedule.Status), res.ReadSchedule.Schedule) } -// SEARCH +// Search + +type searchSchedulesHeader struct { + RequestId string `header:"request-id"` +} + +type searchSchedulesParams struct { + Id *string `form:"id" json:"id,omitempty" binding:"omitempty,min=1"` + Tags map[string]string `form:"tags" json:"tags,omitempty"` + Limit *int `form:"limit" json:"limit,omitempty" binding:"omitempty,gt=0,lte=100"` + Cursor *string `form:"cursor" json:"cursor,omitempty"` +} func (s *server) searchSchedules(c *gin.Context) { - var header service.Header + var header searchSchedulesHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var params service.SearchSchedulesParams + var params searchSchedulesParams if err := c.ShouldBindQuery(¶ms); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } @@ -55,73 +70,119 @@ func (s *server) searchSchedules(c *gin.Context) { // see: https://github.com/gin-gonic/gin/issues/2606 params.Tags = c.QueryMap("tags") - res, err := s.service.SearchSchedules(&header, ¶ms) + req, err := s.api.SearchSchedules( + util.SafeDeref(params.Id), + params.Tags, + util.SafeDeref(params.Limit), + util.SafeDeref(params.Cursor), + ) + if err != nil { + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.SearchSchedules, + SearchSchedules: req, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), gin.H{ - "cursor": res.Cursor, - "schedules": res.Schedules, + util.Assert(res.SearchSchedules != nil, "result must not be nil") + c.JSON(s.code(res.SearchSchedules.Status), gin.H{ + "schedules": res.SearchSchedules.Schedules, + "cursor": res.SearchSchedules.Cursor, }) } -// CREATE +// Create + +type createScheduleHeader struct { + RequestId string `header:"request-id"` + IdempotencyKey *idempotency.Key `header:"idempotency-key"` +} + +type createScheduleBody struct { + Id string `json:"id" binding:"required"` + Description string `json:"desc,omitempty"` + Cron string `json:"cron" binding:"required"` + Tags map[string]string `json:"tags,omitempty"` + PromiseId string `json:"promiseId" binding:"required"` + PromiseTimeout int64 `json:"promiseTimeout" binding:"required"` + PromiseParam promise.Value `json:"promiseParam,omitempty"` + PromiseTags map[string]string `json:"promiseTags,omitempty"` +} func (s *server) createSchedule(c *gin.Context) { - var header service.CreateScheduleHeader + var header createScheduleHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var body *service.CreateScheduleBody + var body createScheduleBody if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + if err := s.api.ValidateCron(body.Cron); err != nil { + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.CreateSchedule(header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.CreateSchedule, + CreateSchedule: &t_api.CreateScheduleRequest{ + Id: body.Id, + Description: body.Description, + Cron: body.Cron, + Tags: body.Tags, + PromiseId: body.PromiseId, + PromiseTimeout: body.PromiseTimeout, + PromiseParam: body.PromiseParam, + PromiseTags: body.PromiseTags, + IdempotencyKey: header.IdempotencyKey, + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), res.Schedule) + util.Assert(res.CreateSchedule != nil, "result must not be nil") + c.JSON(s.code(res.CreateSchedule.Status), res.CreateSchedule.Schedule) } -// DELETE +// Delete -func (s *server) deleteSchedule(c *gin.Context) { - id := extractId(c.Param("id")) +type deleteScheduleHeader struct { + RequestId string `header:"request-id"` +} - var header service.Header +func (s *server) deleteSchedule(c *gin.Context) { + var header deleteScheduleHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - res, err := s.service.DeleteSchedule(id, &header) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.DeleteSchedule, + DeleteSchedule: &t_api.DeleteScheduleRequest{ + Id: extractId(c.Param("id")), + }, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), nil) + util.Assert(res.DeleteSchedule != nil, "result must not be nil") + c.JSON(s.code(res.DeleteSchedule.Status), nil) } diff --git a/internal/app/subsystems/api/http/task.go b/internal/app/subsystems/api/http/task.go index 45d4fc25..6f1e60c3 100644 --- a/internal/app/subsystems/api/http/task.go +++ b/internal/app/subsystems/api/http/task.go @@ -1,107 +1,222 @@ package http import ( + "errors" + "strconv" + "github.com/gin-gonic/gin" - "github.com/resonatehq/resonate/internal/app/subsystems/api/service" + "github.com/resonatehq/resonate/internal/app/subsystems/api" "github.com/resonatehq/resonate/internal/kernel/t_api" "github.com/resonatehq/resonate/internal/util" + "github.com/resonatehq/resonate/pkg/message" ) -// CLAIM +// Claim + +type claimTaskHeader struct { + RequestId string `header:"request-id"` +} + +type claimTaskBody struct { + Id string `json:"id" binding:"required"` + Counter int `json:"counter" binding:"required"` + ProcessId string `json:"processId" binding:"required"` + Frequency int `json:"frequency" binding:"required"` +} func (s *server) claimTask(c *gin.Context) { - var header service.Header + var header claimTaskHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var body *service.ClaimTaskBody - if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) - return + var claimTask *t_api.ClaimTaskRequest + + if c.Request.Method == "GET" { + counter, err := strconv.Atoi(c.Param("counter")) + if err != nil { + err := api.RequestValidationError(errors.New("The field counter must be a number.")) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + claimTask = &t_api.ClaimTaskRequest{ + Id: c.Param("id"), + Counter: counter, + ProcessId: s.api.TaskProcessId(c.Param("id"), counter), + Frequency: int(s.config.TaskFrequency.Milliseconds()), + } + } else { + var body claimTaskBody + if err := c.ShouldBindJSON(&body); err != nil { + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + claimTask = &t_api.ClaimTaskRequest{ + Id: body.Id, + Counter: body.Counter, + ProcessId: body.ProcessId, + Frequency: body.Frequency, + } } - res, err := s.service.ClaimTask(&header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.ClaimTask, + ClaimTask: claimTask, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + util.Assert(res.ClaimTask != nil, "result must not be nil") + util.Assert(res.ClaimTask.Status != t_api.StatusCreated || (res.ClaimTask.Task != nil && res.ClaimTask.Task.Mesg != nil), "task and mesg must not be nil if created") + + if res.ClaimTask.Status == t_api.StatusCreated { + promises := gin.H{ + "root": gin.H{ + "id": res.ClaimTask.Task.Mesg.Root, + "href": res.ClaimTask.RootPromiseHref, + "data": res.ClaimTask.RootPromise, + }, + } + if res.ClaimTask.Task.Mesg.Type == message.Resume { + promises["leaf"] = gin.H{ + "id": res.ClaimTask.Task.Mesg.Leaf, + "href": res.ClaimTask.LeafPromiseHref, + "data": res.ClaimTask.LeafPromise, + } + } + + c.JSON(s.code(res.ClaimTask.Status), gin.H{ + "type": res.ClaimTask.Task.Mesg.Type, + "promises": promises, }) return } - util.Assert(res.Status != t_api.StatusCreated || res.Mesg != nil, "message must not be nil if created") - c.JSON(s.code(res.Status), res.Mesg) + c.JSON(s.code(res.ClaimTask.Status), nil) +} + +// Complete + +type completeTaskHeader struct { + RequestId string `header:"request-id"` } -// COMPLETE +type completeTaskBody struct { + Id string `json:"id" binding:"required"` + Counter int `json:"counter" binding:"required"` +} func (s *server) completeTask(c *gin.Context) { - var header service.Header + var header completeTaskHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var body *service.CompleteTaskBody - if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) - return + var completeTask *t_api.CompleteTaskRequest + + if c.Request.Method == "GET" { + counter, err := strconv.Atoi(c.Param("counter")) + if err != nil { + err := api.RequestValidationError(errors.New("The field counter must be a number.")) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + completeTask = &t_api.CompleteTaskRequest{ + Id: c.Param("id"), + Counter: counter, + } + } else { + var body completeTaskBody + if err := c.ShouldBindJSON(&body); err != nil { + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + completeTask = &t_api.CompleteTaskRequest{ + Id: body.Id, + Counter: body.Counter, + } } - res, err := s.service.CompleteTask(&header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.CompleteTask, + CompleteTask: completeTask, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), nil) + util.Assert(res.CompleteTask != nil, "result must not be nil") + c.JSON(s.code(res.CompleteTask.Status), res.CompleteTask.Task) } -// HEARTBEAT +// Heartbeat + +type heartbeatTasksHeader struct { + RequestId string `header:"request-id"` +} + +type heartbeatTaskBody struct { + ProcessId string `json:"processId" binding:"required"` +} func (s *server) heartbeatTasks(c *gin.Context) { - var header service.Header + var header heartbeatTasksHeader if err := c.ShouldBindHeader(&header); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - var body *service.HeartbeatTaskBody - if err := c.ShouldBindJSON(&body); err != nil { - err := service.RequestValidationError(err) - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) - return + var heartbeatTasks *t_api.HeartbeatTasksRequest + + if c.Request.Method == "GET" { + counter, err := strconv.Atoi(c.Param("counter")) + if err != nil { + err := api.RequestValidationError(errors.New("The field counter must be a number.")) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + heartbeatTasks = &t_api.HeartbeatTasksRequest{ + ProcessId: s.api.TaskProcessId(c.Param("id"), counter), + } + } else { + var body heartbeatTaskBody + if err := c.ShouldBindJSON(&body); err != nil { + err := api.RequestValidationError(err) + c.JSON(s.code(err.Code), gin.H{"error": err}) + return + } + + heartbeatTasks = &t_api.HeartbeatTasksRequest{ + ProcessId: body.ProcessId, + } } - res, err := s.service.HeartbeatTasks(&header, body) + res, err := s.api.Process(header.RequestId, &t_api.Request{ + Kind: t_api.HeartbeatTasks, + HeartbeatTasks: heartbeatTasks, + }) if err != nil { - c.JSON(s.code(err.Code), gin.H{ - "error": err, - }) + c.JSON(s.code(err.Code), gin.H{"error": err}) return } - c.JSON(s.code(res.Status), gin.H{ - "tasksAffected": res.TasksAffected, + util.Assert(res.HeartbeatTasks != nil, "result must not be nil") + c.JSON(s.code(res.HeartbeatTasks.Status), gin.H{ + "tasksAffected": res.HeartbeatTasks.TasksAffected, }) } diff --git a/internal/app/subsystems/api/service/callback.go b/internal/app/subsystems/api/service/callback.go deleted file mode 100644 index 1bb6c0fc..00000000 --- a/internal/app/subsystems/api/service/callback.go +++ /dev/null @@ -1,45 +0,0 @@ -package service - -import ( - "github.com/resonatehq/resonate/internal/kernel/bus" - "github.com/resonatehq/resonate/internal/kernel/t_api" - "github.com/resonatehq/resonate/internal/util" -) - -// CREATE - -func (s *Service) CreateCallback(header *Header, body *CreateCallbackBody) (*t_api.CreateCallbackResponse, *Error) { - util.Assert(body.PromiseId != "", "callback.promiseId must be provided") - util.Assert(body.Timeout != 0, "callback.timeout must be provided") - util.Assert(body.Recv != nil, "callback.recv must be provided") - - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.CreateCallback, - Tags: map[string]string{ - "id": header.Id(), - "name": "CreateCallback", - "protocol": s.protocol, - }, - CreateCallback: &t_api.CreateCallbackRequest{ - PromiseId: body.PromiseId, - RootPromiseId: body.RootPromiseId, - Timeout: body.Timeout, - Recv: body.Recv, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.CreateCallback != nil, "response must not be nil") - return cqe.Completion.CreateCallback, RequestError(cqe.Completion.Status()) -} diff --git a/internal/app/subsystems/api/service/lock.go b/internal/app/subsystems/api/service/lock.go deleted file mode 100644 index 83a3712c..00000000 --- a/internal/app/subsystems/api/service/lock.go +++ /dev/null @@ -1,120 +0,0 @@ -package service - -import ( - "github.com/resonatehq/resonate/internal/kernel/bus" - "github.com/resonatehq/resonate/internal/kernel/t_api" - "github.com/resonatehq/resonate/internal/util" -) - -// ACQUIRE - -func (s *Service) AcquireLock(header *Header, body *AcquireLockBody) (*t_api.AcquireLockResponse, *Error) { - util.Assert(body.ResourceId != "", "lock.resource_id must be provided") - util.Assert(body.ExecutionId != "", "lock.execution_id must be provided") - util.Assert(body.ProcessId != "", "lock.process_id must be provided") - util.Assert(body.ExpiryInMilliseconds != 0, "lock.expiry_in_milliseconds must be provided") - - acquireLock := &t_api.AcquireLockRequest{ - ResourceId: body.ResourceId, - ExecutionId: body.ExecutionId, - ProcessId: body.ProcessId, - ExpiryInMilliseconds: body.ExpiryInMilliseconds, - } - - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.AcquireLock, - Tags: map[string]string{ - "id": header.Id(), - "name": "AcquireLock", - "protocol": s.protocol, - }, - AcquireLock: acquireLock, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.AcquireLock != nil, "response must not be nil") - return cqe.Completion.AcquireLock, RequestError(cqe.Completion.Status()) -} - -// RELEASE - -func (s *Service) ReleaseLock(header *Header, body *ReleaseLockBody) (*t_api.ReleaseLockResponse, *Error) { - util.Assert(body.ResourceId != "", "resource_id must be provided") - util.Assert(body.ExecutionId != "", "execution_id must be provided") - - releaseLock := &t_api.ReleaseLockRequest{ - ResourceId: body.ResourceId, - ExecutionId: body.ExecutionId, - } - - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.ReleaseLock, - Tags: map[string]string{ - "id": header.Id(), - "name": "ReleaseLock", - "protocol": s.protocol, - }, - ReleaseLock: releaseLock, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.ReleaseLock != nil, "response must not be nil") - return cqe.Completion.ReleaseLock, RequestError(cqe.Completion.Status()) -} - -// HEARTBEAT - -func (s *Service) Heartbeat(header *Header, body *HeartbeatBody) (*t_api.HeartbeatLocksResponse, *Error) { - util.Assert(body.ProcessId != "", "process_id must be provided") - - HeartbeatLocks := &t_api.HeartbeatLocksRequest{ - ProcessId: body.ProcessId, - } - - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.HeartbeatLocks, - Tags: map[string]string{ - "id": header.Id(), - "name": "HeartbeatLocks", - "protocol": s.protocol, - }, - HeartbeatLocks: HeartbeatLocks, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.HeartbeatLocks != nil, "response must not be nil") - return cqe.Completion.HeartbeatLocks, RequestError(cqe.Completion.Status()) -} diff --git a/internal/app/subsystems/api/service/promise.go b/internal/app/subsystems/api/service/promise.go deleted file mode 100644 index bcc18360..00000000 --- a/internal/app/subsystems/api/service/promise.go +++ /dev/null @@ -1,198 +0,0 @@ -package service - -import ( - "fmt" - "strings" - - "github.com/resonatehq/resonate/internal/kernel/bus" - "github.com/resonatehq/resonate/internal/kernel/t_api" - "github.com/resonatehq/resonate/internal/util" - "github.com/resonatehq/resonate/pkg/promise" -) - -// Read Promise - -func (s *Service) ReadPromise(id string, header *Header) (*t_api.ReadPromiseResponse, *Error) { - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: header.Id(), - Callback: s.sendOrPanic(header.Id(), cq), - Submission: &t_api.Request{ - Kind: t_api.ReadPromise, - Tags: map[string]string{ - "id": header.Id(), - "name": "ReadPromise", - "protocol": s.protocol, - }, - ReadPromise: &t_api.ReadPromiseRequest{ - Id: id, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.ReadPromise != nil, "response must not be nil") - return cqe.Completion.ReadPromise, RequestError(cqe.Completion.Status()) -} - -// Search Promise - -func (s *Service) SearchPromises(header *Header, params *SearchPromisesParams) (*t_api.SearchPromisesResponse, *Error) { - if params == nil { - params = &SearchPromisesParams{} - } - var searchPromises *t_api.SearchPromisesRequest - if params.Cursor != nil && *params.Cursor != "" { - cursor, err := t_api.NewCursor[t_api.SearchPromisesRequest](*params.Cursor) - if err != nil { - return nil, RequestValidationError(err) - } - searchPromises = cursor.Next - } else { - // set default query - if params.Id == nil { - params.Id = util.ToPointer("*") - } - - var states []promise.State - if params.State == nil { - states = []promise.State{ - promise.Pending, - promise.Resolved, - promise.Rejected, - promise.Timedout, - promise.Canceled, - } - } else { - switch strings.ToLower(*params.State) { - case "pending": - states = []promise.State{ - promise.Pending, - } - case "resolved": - states = []promise.State{ - promise.Resolved, - } - case "rejected": - states = []promise.State{ - promise.Rejected, - promise.Timedout, - promise.Canceled, - } - default: - panic(fmt.Sprintf("invalid state: %s", *params.State)) - } - } - - // set default limit - if params.Limit == nil || *params.Limit == 0 { - params.Limit = util.ToPointer(100) - } - - searchPromises = &t_api.SearchPromisesRequest{ - Id: *params.Id, - States: states, - Tags: params.Tags, - Limit: *params.Limit, - } - } - - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.SearchPromises, - Tags: map[string]string{ - "id": header.Id(), - "name": "SearchPromises", - "protocol": s.protocol, - }, - SearchPromises: searchPromises, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.SearchPromises != nil, "response must not be nil") - return cqe.Completion.SearchPromises, RequestError(cqe.Completion.Status()) -} - -// Create Promise - -func (s *Service) CreatePromise(header *CreatePromiseHeader, body *promise.Promise) (*t_api.CreatePromiseResponse, *Error) { - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.CreatePromise, - Tags: map[string]string{ - "id": header.Id(), - "name": "CreatePromise", - "protocol": s.protocol, - }, - CreatePromise: &t_api.CreatePromiseRequest{ - Id: body.Id, - IdempotencyKey: header.IdempotencyKey, - Strict: header.Strict, - Param: body.Param, - Timeout: body.Timeout, - Tags: body.Tags, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.CreatePromise != nil, "response must not be nil") - return cqe.Completion.CreatePromise, RequestError(cqe.Completion.Status()) -} - -// Complete Promise -func (s *Service) CompletePromise(id string, state promise.State, header *CompletePromiseHeader, body *CompletePromiseBody) (*t_api.CompletePromiseResponse, *Error) { - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: header.Id(), - Callback: s.sendOrPanic(header.Id(), cq), - Submission: &t_api.Request{ - Kind: t_api.CompletePromise, - Tags: map[string]string{ - "id": header.Id(), - "name": "CompletePromise", - "protocol": s.protocol, - }, - CompletePromise: &t_api.CompletePromiseRequest{ - Id: id, - IdempotencyKey: header.IdempotencyKey, - Strict: header.Strict, - State: state, - Value: body.Value, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.CompletePromise != nil, "response must not be nil") - return cqe.Completion.CompletePromise, RequestError(cqe.Completion.Status()) -} diff --git a/internal/app/subsystems/api/service/request.go b/internal/app/subsystems/api/service/request.go deleted file mode 100644 index 47658377..00000000 --- a/internal/app/subsystems/api/service/request.go +++ /dev/null @@ -1,118 +0,0 @@ -package service - -import ( - "encoding/json" - - "github.com/google/uuid" - "github.com/resonatehq/resonate/pkg/idempotency" - "github.com/resonatehq/resonate/pkg/promise" -) - -// PROMISES - -type Header struct { - RequestId string `header:"request-id"` -} - -func (h *Header) Id() string { - if h.RequestId == "" { - h.RequestId = uuid.New().String() - } - - return h.RequestId -} - -type SearchPromisesParams struct { - Id *string `form:"id" json:"id,omitempty" binding:"omitempty,min=1"` - State *string `form:"state" json:"state,omitempty" binding:"omitempty,oneofcaseinsensitive=pending resolved rejected"` - Tags map[string]string `form:"tags" json:"tags,omitempty"` - Limit *int `form:"limit" json:"limit,omitempty" binding:"omitempty,gt=0,lte=100"` - Cursor *string `form:"cursor" json:"cursor,omitempty"` -} - -type CreatePromiseHeader struct { - Header - IdempotencyKey *idempotency.Key `header:"idempotency-key"` - Strict bool `header:"strict"` -} - -type CompletePromiseHeader struct { - Header - IdempotencyKey *idempotency.Key `header:"idempotency-key,omitempty"` - Strict bool `header:"strict"` -} - -type CompletePromiseBody struct { - State promise.State `json:"state" binding:"required"` - Value promise.Value `json:"value"` -} - -// CALLBACKS - -type CreateCallbackBody struct { - PromiseId string `json:"promiseId" binding:"required"` - RootPromiseId string `json:"rootPromiseId" binding:"required"` - Timeout int64 `json:"timeout" binding:"required"` - Recv json.RawMessage `json:"recv" binding:"required"` -} - -// SCHEDULES - -type SearchSchedulesParams struct { - Id *string `form:"id" json:"id,omitempty" binding:"omitempty,min=1"` - Tags map[string]string `form:"tags" json:"tags,omitempty"` - Limit *int `form:"limit" json:"limit,omitempty" binding:"omitempty,gt=0,lte=100"` - Cursor *string `form:"cursor" json:"cursor,omitempty"` -} - -type CreateScheduleHeader struct { - Header - IdempotencyKey *idempotency.Key `header:"idempotency-key"` -} - -type CreateScheduleBody struct { - Id string `json:"id" binding:"required"` - Description string `json:"desc,omitempty"` - Cron string `json:"cron" binding:"required"` - Tags map[string]string `json:"tags,omitempty"` - PromiseId string `json:"promiseId" binding:"required"` - PromiseTimeout int64 `json:"promiseTimeout" binding:"required"` - PromiseParam promise.Value `json:"promiseParam,omitempty"` - PromiseTags map[string]string `json:"promiseTags,omitempty"` -} - -// LOCKS - -type AcquireLockBody struct { - ResourceId string `json:"resourceId" binding:"required"` - ExecutionId string `json:"executionId" binding:"required"` - ProcessId string `json:"processId" binding:"required"` - ExpiryInMilliseconds int64 `json:"expiryInMilliseconds" binding:"required"` -} - -type ReleaseLockBody struct { - ResourceId string `json:"resourceId" binding:"required"` - ExecutionId string `json:"executionId" binding:"required"` -} - -type HeartbeatBody struct { - ProcessId string `json:"processId" binding:"required"` -} - -// TASKS - -type ClaimTaskBody struct { - Id string `json:"id" binding:"required"` - ProcessId string `json:"processId" binding:"required"` - Counter int `json:"counter"` - Frequency int `json:"frequency" binding:"required"` -} - -type CompleteTaskBody struct { - Id string `json:"id" binding:"required"` - Counter int `json:"counter"` -} - -type HeartbeatTaskBody struct { - ProcessId string `json:"processId" binding:"required"` -} diff --git a/internal/app/subsystems/api/service/schedule.go b/internal/app/subsystems/api/service/schedule.go deleted file mode 100644 index dffe23b2..00000000 --- a/internal/app/subsystems/api/service/schedule.go +++ /dev/null @@ -1,193 +0,0 @@ -package service - -import ( - "fmt" - - "github.com/resonatehq/resonate/internal/kernel/bus" - "github.com/resonatehq/resonate/internal/kernel/t_api" - "github.com/resonatehq/resonate/internal/util" -) - -// READ - -func (s *Service) ReadSchedule(id string, header *Header) (*t_api.ReadScheduleResponse, *Error) { - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: header.Id(), - Callback: s.sendOrPanic(header.Id(), cq), - Submission: &t_api.Request{ - Kind: t_api.ReadSchedule, - Tags: map[string]string{ - "id": header.Id(), - "name": "ReadSchedule", - "protocol": s.protocol, - }, - ReadSchedule: &t_api.ReadScheduleRequest{ - Id: id, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.ReadSchedule != nil, "response must not be nil") - return cqe.Completion.ReadSchedule, RequestError(cqe.Completion.Status()) -} - -// SEARCH - -func (s *Service) SearchSchedules(header *Header, params *SearchSchedulesParams) (*t_api.SearchSchedulesResponse, *Error) { - if params == nil { - params = &SearchSchedulesParams{} - } - var searchSchedules *t_api.SearchSchedulesRequest - if params.Cursor != nil && *params.Cursor != "" { - cursor, err := t_api.NewCursor[t_api.SearchSchedulesRequest](*params.Cursor) - if err != nil { - return nil, RequestValidationError(err) - } - searchSchedules = cursor.Next - } else { - // set default query - if params.Id == nil { - params.Id = util.ToPointer("*") - } - - // set default limit - if params.Limit == nil || *params.Limit == 0 { - params.Limit = util.ToPointer(100) - } - - searchSchedules = &t_api.SearchSchedulesRequest{ - Id: *params.Id, - Tags: params.Tags, - Limit: *params.Limit, - } - } - - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.SearchSchedules, - Tags: map[string]string{ - "id": header.Id(), - "name": "SearchSchedules", - "protocol": s.protocol, - }, - SearchSchedules: searchSchedules, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.SearchSchedules != nil, "response must not be nil") - return cqe.Completion.SearchSchedules, RequestError(cqe.Completion.Status()) -} - -// CREATE - -func (s *Service) CreateSchedule(header CreateScheduleHeader, body *CreateScheduleBody) (*t_api.CreateScheduleResponse, *Error) { - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - // validation - if err := validateSchedule(body.Cron); err != nil { - return nil, RequestValidationError(err) - } - - if err := validatePromiseId(body.PromiseId); err != nil { - return nil, RequestValidationError(err) - } - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.CreateSchedule, - Tags: map[string]string{ - "id": header.Id(), - "name": "CreateSchedule", - "protocol": s.protocol, - }, - CreateSchedule: &t_api.CreateScheduleRequest{ - Id: body.Id, - Description: body.Description, - Cron: body.Cron, - Tags: body.Tags, - PromiseId: body.PromiseId, - PromiseTimeout: body.PromiseTimeout, - PromiseParam: body.PromiseParam, - PromiseTags: body.PromiseTags, - IdempotencyKey: header.IdempotencyKey, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.CreateSchedule != nil, "response must not be nil") - return cqe.Completion.CreateSchedule, RequestError(cqe.Completion.Status()) -} - -// DELETE - -func (s *Service) DeleteSchedule(id string, header *Header) (*t_api.DeleteScheduleResponse, *Error) { - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: header.Id(), - Callback: s.sendOrPanic(header.Id(), cq), - Submission: &t_api.Request{ - Kind: t_api.DeleteSchedule, - Tags: map[string]string{ - "id": header.Id(), - "name": "DeleteSchedule", - "protocol": s.protocol, - }, - DeleteSchedule: &t_api.DeleteScheduleRequest{ - Id: id, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.DeleteSchedule != nil, "response must not be nil") - return cqe.Completion.DeleteSchedule, RequestError(cqe.Completion.Status()) -} - -// validations - -func validateSchedule(schedule string) error { - // Validate schedule is valid cron expression - if _, err := util.ParseCron(schedule); err != nil { - return fmt.Errorf("invalid cron schedule: %v", err) - } - - return nil -} - -func validatePromiseId(promiseId string) error { - if promiseId == "" { - return fmt.Errorf("promiseId is required") - } - - return nil -} diff --git a/internal/app/subsystems/api/service/service.go b/internal/app/subsystems/api/service/service.go deleted file mode 100644 index c0a572a1..00000000 --- a/internal/app/subsystems/api/service/service.go +++ /dev/null @@ -1,35 +0,0 @@ -package service - -import ( - "github.com/resonatehq/resonate/internal/api" - "github.com/resonatehq/resonate/internal/kernel/bus" - "github.com/resonatehq/resonate/internal/kernel/t_api" -) - -type Service struct { - api api.API - protocol string -} - -func New(api api.API, protocol string) *Service { - return &Service{ - api: api, - protocol: protocol, - } -} - -func (s *Service) sendOrPanic(id string, cq chan<- *bus.CQE[t_api.Request, t_api.Response]) func(*t_api.Response, error) { - return func(res *t_api.Response, err error) { - defer close(cq) - - select { - case cq <- &bus.CQE[t_api.Request, t_api.Response]{ - Id: id, - Completion: res, - Error: err, - }: - default: - panic("response channel must not block") - } - } -} diff --git a/internal/app/subsystems/api/service/task.go b/internal/app/subsystems/api/service/task.go deleted file mode 100644 index 7eb4b407..00000000 --- a/internal/app/subsystems/api/service/task.go +++ /dev/null @@ -1,104 +0,0 @@ -package service - -import ( - "github.com/resonatehq/resonate/internal/kernel/bus" - "github.com/resonatehq/resonate/internal/kernel/t_api" - "github.com/resonatehq/resonate/internal/util" -) - -// CLAIM - -func (s *Service) ClaimTask(header *Header, body *ClaimTaskBody) (*t_api.ClaimTaskResponse, *Error) { - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.ClaimTask, - Tags: map[string]string{ - "id": header.Id(), - "name": "ClaimTask", - "protocol": s.protocol, - }, - ClaimTask: &t_api.ClaimTaskRequest{ - Id: body.Id, - ProcessId: body.ProcessId, - Counter: body.Counter, - Frequency: body.Frequency, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.ClaimTask != nil, "response must not be nil") - return cqe.Completion.ClaimTask, RequestError(cqe.Completion.Status()) -} - -// COMPLETE - -func (s *Service) CompleteTask(header *Header, body *CompleteTaskBody) (*t_api.CompleteTaskResponse, *Error) { - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.CompleteTask, - Tags: map[string]string{ - "id": header.Id(), - "name": "CompleteTask", - "protocol": s.protocol, - }, - CompleteTask: &t_api.CompleteTaskRequest{ - Id: body.Id, - Counter: body.Counter, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.CompleteTask != nil, "response must not be nil") - return cqe.Completion.CompleteTask, RequestError(cqe.Completion.Status()) -} - -// HEARTBEAT - -func (s *Service) HeartbeatTasks(header *Header, body *HeartbeatTaskBody) (*t_api.HeartbeatTasksResponse, *Error) { - id := header.Id() - cq := make(chan *bus.CQE[t_api.Request, t_api.Response], 1) - - s.api.EnqueueSQE(&bus.SQE[t_api.Request, t_api.Response]{ - Id: id, - Callback: s.sendOrPanic(id, cq), - Submission: &t_api.Request{ - Kind: t_api.HeartbeatTasks, - Tags: map[string]string{ - "id": header.Id(), - "name": "HeartbeatTasks", - "protocol": s.protocol, - }, - HeartbeatTasks: &t_api.HeartbeatTasksRequest{ - ProcessId: body.ProcessId, - }, - }, - }) - - cqe := s.api.DequeueCQE(cq) - if cqe.Error != nil { - return nil, ServerError(cqe.Error) - } - - util.Assert(cqe.Completion.HeartbeatTasks != nil, "response must not be nil") - return cqe.Completion.HeartbeatTasks, RequestError(cqe.Completion.Status()) -} diff --git a/internal/app/subsystems/api/test/api.go b/internal/app/subsystems/api/test/api.go index 92fb2f29..745ba333 100644 --- a/internal/app/subsystems/api/test/api.go +++ b/internal/app/subsystems/api/test/api.go @@ -3,7 +3,6 @@ package test import ( "testing" - "github.com/resonatehq/resonate/internal/api" "github.com/resonatehq/resonate/internal/kernel/bus" "github.com/resonatehq/resonate/internal/kernel/t_api" "github.com/stretchr/testify/assert" @@ -25,10 +24,6 @@ func (a *API) String() string { return "api:test" } -func (a *API) AddSubsystem(subsystem api.Subsystem) { - panic("not implemented") -} - func (a *API) Start() error { return nil } diff --git a/internal/app/subsystems/api/test/cases.go b/internal/app/subsystems/api/test/cases.go new file mode 100644 index 00000000..40bba478 --- /dev/null +++ b/internal/app/subsystems/api/test/cases.go @@ -0,0 +1,2368 @@ +package test + +import ( + "github.com/resonatehq/resonate/internal/kernel/t_api" + "github.com/resonatehq/resonate/internal/util" + "github.com/resonatehq/resonate/pkg/callback" + "github.com/resonatehq/resonate/pkg/idempotency" + "github.com/resonatehq/resonate/pkg/lock" + "github.com/resonatehq/resonate/pkg/message" + "github.com/resonatehq/resonate/pkg/promise" + "github.com/resonatehq/resonate/pkg/schedule" + "github.com/resonatehq/resonate/pkg/task" + "google.golang.org/grpc/codes" + "google.golang.org/protobuf/reflect/protoreflect" + + "github.com/resonatehq/resonate/internal/app/subsystems/api/grpc/pb" +) + +type testCase struct { + Name string + Req *t_api.Request + Res *t_api.Response + Http *httpTestCase + Grpc *grpcTestCase +} + +type httpTestCase struct { + Req *httpTestCaseRequest + Res *httpTestCaseResponse +} + +type httpTestCaseRequest struct { + Method string + Path string + Headers map[string]string + Body []byte +} + +type httpTestCaseResponse struct { + Code int + Body []byte +} + +type grpcTestCase struct { + Req protoreflect.ProtoMessage + Res protoreflect.ProtoMessage + Code codes.Code +} + +var TestCases = []*testCase{ + // Promises + { + Name: "ReadPromise", + Req: &t_api.Request{ + Kind: t_api.ReadPromise, + Tags: map[string]string{"id": "ReadPromise", "name": "ReadPromise"}, + ReadPromise: &t_api.ReadPromiseRequest{ + Id: "foo", + }, + }, + Res: &t_api.Response{ + Kind: t_api.ReadPromise, + ReadPromise: &t_api.ReadPromiseResponse{ + Status: t_api.StatusOK, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Pending, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises/foo", + Headers: map[string]string{"Request-Id": "ReadPromise"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ReadPromiseRequest{ + Id: "foo", + RequestId: "ReadPromise", + }, + }, + }, + { + Name: "ReadPromiseWithSlash", + Req: &t_api.Request{ + Kind: t_api.ReadPromise, + Tags: map[string]string{"id": "ReadPromiseWithSlash", "name": "ReadPromise"}, + ReadPromise: &t_api.ReadPromiseRequest{ + Id: "foo/bar", + }, + }, + Res: &t_api.Response{ + Kind: t_api.ReadPromise, + ReadPromise: &t_api.ReadPromiseResponse{ + Status: t_api.StatusOK, + Promise: &promise.Promise{ + Id: "foo/bar", + State: promise.Pending, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises/foo/bar", + Headers: map[string]string{"Request-Id": "ReadPromiseWithSlash"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ReadPromiseRequest{ + Id: "foo/bar", + RequestId: "ReadPromiseWithSlash", + }, + }, + }, + { + Name: "ReadPromiseNotFound", + Req: &t_api.Request{ + Kind: t_api.ReadPromise, + Tags: map[string]string{"id": "ReadPromiseNotFound", "name": "ReadPromise"}, + ReadPromise: &t_api.ReadPromiseRequest{ + Id: "bar", + }, + }, + Res: &t_api.Response{ + Kind: t_api.ReadPromise, + ReadPromise: &t_api.ReadPromiseResponse{ + Status: t_api.StatusPromiseNotFound, + Promise: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises/bar", + Headers: map[string]string{"Request-Id": "ReadPromiseNotFound"}, + }, + Res: &httpTestCaseResponse{ + Code: 404, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ReadPromiseRequest{ + Id: "bar", + RequestId: "ReadPromiseNotFound", + }, + Code: codes.NotFound, + }, + }, + { + Name: "SearchPromises", + Req: &t_api.Request{ + Kind: t_api.SearchPromises, + Tags: map[string]string{"id": "SearchPromises", "name": "SearchPromises"}, + SearchPromises: &t_api.SearchPromisesRequest{ + Id: "*", + States: []promise.State{ + promise.Pending, + promise.Resolved, + promise.Rejected, + promise.Timedout, + promise.Canceled, + }, + Tags: map[string]string{}, + Limit: 10, + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchPromises, + SearchPromises: &t_api.SearchPromisesResponse{ + Status: t_api.StatusOK, + Promises: []*promise.Promise{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=*&limit=10", + Headers: map[string]string{"Request-Id": "SearchPromises"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + Limit: 10, + RequestId: "SearchPromises", + }, + }, + }, + { + Name: "SearchPromisesCursor", + Req: &t_api.Request{ + Kind: t_api.SearchPromises, + Tags: map[string]string{"id": "SearchPromisesCursor", "name": "SearchPromises"}, + SearchPromises: &t_api.SearchPromisesRequest{ + Id: "*", + States: []promise.State{ + promise.Pending, + }, + Tags: map[string]string{}, + Limit: 10, + SortId: util.ToPointer(int64(100)), + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchPromises, + SearchPromises: &t_api.SearchPromisesResponse{ + Status: t_api.StatusOK, + Promises: []*promise.Promise{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?cursor=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJOZXh0Ijp7ImlkIjoiKiIsInN0YXRlcyI6WyJQRU5ESU5HIl0sInRhZ3MiOnt9LCJsaW1pdCI6MTAsInNvcnRJZCI6MTAwfX0.XKusWO-Jl4v7QVIwh5Pn3oIElBvtpf0VPOLJkXPvQLk", + Headers: map[string]string{"Request-Id": "SearchPromisesCursor"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + Cursor: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJOZXh0Ijp7ImlkIjoiKiIsInN0YXRlcyI6WyJQRU5ESU5HIl0sInRhZ3MiOnt9LCJsaW1pdCI6MTAsInNvcnRJZCI6MTAwfX0.XKusWO-Jl4v7QVIwh5Pn3oIElBvtpf0VPOLJkXPvQLk", + RequestId: "SearchPromisesCursor", + }, + }, + }, + { + Name: "SearchPromisesPending", + Req: &t_api.Request{ + Kind: t_api.SearchPromises, + Tags: map[string]string{"id": "SearchPromisesPending", "name": "SearchPromises"}, + SearchPromises: &t_api.SearchPromisesRequest{ + Id: "*", + States: []promise.State{ + promise.Pending, + }, + Tags: map[string]string{}, + Limit: 10, + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchPromises, + SearchPromises: &t_api.SearchPromisesResponse{ + Status: t_api.StatusOK, + Promises: []*promise.Promise{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=*&state=pending&limit=10", + Headers: map[string]string{"Request-Id": "SearchPromisesPending"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + State: pb.SearchState_SEARCH_PENDING, + Limit: 10, + RequestId: "SearchPromisesPending", + }, + }, + }, + { + Name: "SearchPromisesResolved", + Req: &t_api.Request{ + Kind: t_api.SearchPromises, + Tags: map[string]string{"id": "SearchPromisesResolved", "name": "SearchPromises"}, + SearchPromises: &t_api.SearchPromisesRequest{ + Id: "*", + States: []promise.State{ + promise.Resolved, + }, + Tags: map[string]string{}, + Limit: 10, + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchPromises, + SearchPromises: &t_api.SearchPromisesResponse{ + Status: t_api.StatusOK, + Promises: []*promise.Promise{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=*&state=resolved&limit=10", + Headers: map[string]string{"Request-Id": "SearchPromisesResolved"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + State: pb.SearchState_SEARCH_RESOLVED, + Limit: 10, + RequestId: "SearchPromisesResolved", + }, + }, + }, + { + Name: "SearchPromisesRejected", + Req: &t_api.Request{ + Kind: t_api.SearchPromises, + Tags: map[string]string{"id": "SearchPromisesRejected", "name": "SearchPromises"}, + SearchPromises: &t_api.SearchPromisesRequest{ + Id: "*", + States: []promise.State{ + promise.Rejected, + promise.Timedout, + promise.Canceled, + }, + Tags: map[string]string{}, + Limit: 10, + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchPromises, + SearchPromises: &t_api.SearchPromisesResponse{ + Status: t_api.StatusOK, + Promises: []*promise.Promise{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=*&state=rejected&limit=10", + Headers: map[string]string{"Request-Id": "SearchPromisesRejected"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + State: pb.SearchState_SEARCH_REJECTED, + Limit: 10, + RequestId: "SearchPromisesRejected", + }, + }, + }, + { + Name: "SearchPromisesTags", + Req: &t_api.Request{ + Kind: t_api.SearchPromises, + Tags: map[string]string{"id": "SearchPromisesTags", "name": "SearchPromises"}, + SearchPromises: &t_api.SearchPromisesRequest{ + Id: "*", + States: []promise.State{ + promise.Pending, + promise.Resolved, + promise.Rejected, + promise.Timedout, + promise.Canceled, + }, + Tags: map[string]string{ + "foo": "bar", + }, + Limit: 10, + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchPromises, + SearchPromises: &t_api.SearchPromisesResponse{ + Status: t_api.StatusOK, + Promises: []*promise.Promise{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=*&tags[foo]=bar&limit=10", + Headers: map[string]string{"Request-Id": "SearchPromisesTags"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + Tags: map[string]string{ + "foo": "bar", + }, + Limit: 10, + RequestId: "SearchPromisesTags", + }, + }, + }, + { + Name: "SearchPromisesInvalidQuery", + Req: nil, + Res: nil, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=", + }, + Res: &httpTestCaseResponse{ + Code: 400, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "", + }, + Code: codes.InvalidArgument, + }, + }, + { + Name: "SearchPromisesInvalidState", + Req: nil, + Res: nil, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=*&limit=10&state=x", + }, + Res: &httpTestCaseResponse{ + Code: 400, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + Limit: 10, + State: -1, + }, + Code: codes.InvalidArgument, + }, + }, + { + Name: "SearchPromisesDefaultLimit", + Req: &t_api.Request{ + Kind: t_api.SearchPromises, + Tags: map[string]string{"id": "SearchPromisesDefaultLimit", "name": "SearchPromises"}, + SearchPromises: &t_api.SearchPromisesRequest{ + Id: "*", + States: []promise.State{ + promise.Pending, + promise.Resolved, + promise.Rejected, + promise.Timedout, + promise.Canceled, + }, + Tags: map[string]string{}, + Limit: 100, + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchPromises, + SearchPromises: &t_api.SearchPromisesResponse{ + Status: t_api.StatusOK, + Promises: []*promise.Promise{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=*", + Headers: map[string]string{"Request-Id": "SearchPromisesDefaultLimit"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + RequestId: "SearchPromisesDefaultLimit", + }, + }, + }, + { + Name: "SearchPromisesInvalidLimitLower", + Req: nil, + Res: nil, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=*&limit=-1", + }, + Res: &httpTestCaseResponse{ + Code: 400, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + Limit: -1, + }, + Code: codes.InvalidArgument, + }, + }, + { + Name: "SearchPromisesInvalidLimitUpper", + Req: nil, + Res: nil, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "promises?id=*&limit=101", + }, + Res: &httpTestCaseResponse{ + Code: 400, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchPromisesRequest{ + Id: "*", + Limit: 101, + }, + Code: codes.InvalidArgument, + }, + }, + { + Name: "CreatePromise", + Req: &t_api.Request{ + Kind: t_api.CreatePromise, + Tags: map[string]string{"id": "CreatePromise", "name": "CreatePromise"}, + CreatePromise: &t_api.CreatePromiseRequest{ + Id: "foo", + IdempotencyKey: util.ToPointer(idempotency.Key("bar")), + Strict: true, + Param: promise.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("pending"), + }, + Timeout: 1, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CreatePromise, + CreatePromise: &t_api.CreatePromiseResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Pending, + IdempotencyKeyForCreate: util.ToPointer(idempotency.Key("bar")), + Param: promise.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("pending"), + }, + Timeout: 1, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "promises", + Headers: map[string]string{ + "Request-Id": "CreatePromise", + "Idempotency-Key": "bar", + "Strict": "true", + }, + Body: []byte(`{ + "id": "foo", + "param": { + "headers": {"a":"a","b":"b","c":"c"}, + "data": "cGVuZGluZw==" + }, + "timeout": 1 + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CreatePromiseRequest{ + Id: "foo", + IdempotencyKey: "bar", + Strict: true, + Param: &pb.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("pending"), + }, + Timeout: 1, + RequestId: "CreatePromise", + }, + Res: &pb.CreatePromiseResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_PENDING, + IdempotencyKeyForCreate: "bar", + Param: &pb.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("pending"), + }, + Value: &pb.Value{}, + Timeout: 1, + }, + }, + }, + }, + { + Name: "CreatePromiseMinimal", + Req: &t_api.Request{ + Kind: t_api.CreatePromise, + Tags: map[string]string{"id": "CreatePromiseMinimal", "name": "CreatePromise"}, + CreatePromise: &t_api.CreatePromiseRequest{ + Id: "foo", + IdempotencyKey: nil, + Strict: false, + Param: promise.Value{}, + Timeout: 1, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CreatePromise, + CreatePromise: &t_api.CreatePromiseResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Pending, + IdempotencyKeyForCreate: nil, + Param: promise.Value{}, + Timeout: 1, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "promises", + Headers: map[string]string{ + "Request-Id": "CreatePromiseMinimal", + }, + Body: []byte(`{ + "id": "foo", + "timeout": 1 + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CreatePromiseRequest{ + Id: "foo", + Timeout: 1, + RequestId: "CreatePromiseMinimal", + }, + Res: &pb.CreatePromiseResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_PENDING, + IdempotencyKeyForCreate: "", + Param: &pb.Value{}, + Value: &pb.Value{}, + Timeout: 1, + }, + }, + }, + }, + { + Name: "CreatePromiseAndTask", + Req: &t_api.Request{ + Kind: t_api.CreatePromiseAndTask, + Tags: map[string]string{"id": "CreatePromiseAndTask", "name": "CreatePromiseAndTask"}, + CreatePromiseAndTask: &t_api.CreatePromiseAndTaskRequest{ + Promise: &t_api.CreatePromiseRequest{ + Id: "foo", + Timeout: 1, + }, + Task: &t_api.CreateTaskRequest{ + PromiseId: "foo", + ProcessId: "bar", + Frequency: 2, + Timeout: 1, + Recv: []byte(`"baz"`), + }, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CreatePromiseAndTask, + CreatePromiseAndTask: &t_api.CreatePromiseAndTaskResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Pending, + Param: promise.Value{}, + Timeout: 1, + }, + Task: &task.Task{}, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "promises/task", + Headers: map[string]string{ + "Request-Id": "CreatePromiseAndTask", + }, + Body: []byte(`{ + "promise": {"id": "foo", "timeout": 1}, + "task": {"processId": "bar", "frequency": 2, "recv": "baz"} + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CreatePromiseAndTaskRequest{ + Promise: &pb.CreatePromiseRequest{ + Id: "foo", + Timeout: 1, + RequestId: "CreatePromiseAndTask", + }, + Task: &pb.CreatePromiseTaskRequest{ + ProcessId: "bar", + Frequency: 2, + Recv: &pb.Recv{Recv: &pb.Recv_Logical{Logical: "baz"}}, + }, + }, + Res: &pb.CreatePromiseAndTaskResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_PENDING, + IdempotencyKeyForCreate: "", + Param: &pb.Value{}, + Value: &pb.Value{}, + Timeout: 1, + }, + }, + }, + }, + { + Name: "CreatePromiseAndCallback", + Req: &t_api.Request{ + Kind: t_api.CreatePromiseAndCallback, + Tags: map[string]string{"id": "CreatePromiseAndCallback", "name": "CreatePromiseAndCallback"}, + CreatePromiseAndCallback: &t_api.CreatePromiseAndCallbackRequest{ + Promise: &t_api.CreatePromiseRequest{ + Id: "foo", + Timeout: 1, + }, + Callback: &t_api.CreateCallbackRequest{ + PromiseId: "foo", + RootPromiseId: "bar", + Timeout: 2, + Recv: []byte(`"baz"`), + }, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CreatePromiseAndCallback, + CreatePromiseAndCallback: &t_api.CreatePromiseAndCallbackResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Pending, + Param: promise.Value{}, + Timeout: 1, + }, + Callback: &callback.Callback{}, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "promises/callback", + Headers: map[string]string{ + "Request-Id": "CreatePromiseAndCallback", + }, + Body: []byte(`{ + "promise": {"id": "foo", "timeout": 1}, + "callback": {"rootPromiseId": "bar", "timeout": 2, "recv": "baz"} + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CreatePromiseAndCallbackRequest{ + Promise: &pb.CreatePromiseRequest{ + Id: "foo", + Timeout: 1, + RequestId: "CreatePromiseAndCallback", + }, + Callback: &pb.CreatePromiseCallbackRequest{ + RootPromiseId: "bar", + Timeout: 2, + Recv: &pb.Recv{Recv: &pb.Recv_Logical{Logical: "baz"}}, + }, + }, + Res: &pb.CreatePromiseAndCallbackResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_PENDING, + IdempotencyKeyForCreate: "", + Param: &pb.Value{}, + Value: &pb.Value{}, + Timeout: 1, + }, + }, + }, + }, + { + Name: "ResolvePromise", + Req: &t_api.Request{ + Kind: t_api.CompletePromise, + Tags: map[string]string{"id": "ResolvePromise", "name": "CompletePromise"}, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: "foo", + IdempotencyKey: util.ToPointer(idempotency.Key("bar")), + Strict: true, + State: promise.Resolved, + Value: promise.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("resolve"), + }, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Resolved, + IdempotencyKeyForComplete: util.ToPointer(idempotency.Key("bar")), + Value: promise.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("resolve"), + }, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "PATCH", + Path: "promises/foo", + Headers: map[string]string{ + "Request-Id": "ResolvePromise", + "Idempotency-Key": "bar", + "Strict": "true", + }, + Body: []byte(`{ + "state": "RESOLVED", + "value": { + "headers": {"a":"a","b":"b","c":"c"}, + "data": "cmVzb2x2ZQ==" + } + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ResolvePromiseRequest{ + RequestId: "ResolvePromise", + Id: "foo", + IdempotencyKey: "bar", + Strict: true, + Value: &pb.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("resolve"), + }, + }, + Res: &pb.ResolvePromiseResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_RESOLVED, + IdempotencyKeyForComplete: "bar", + Param: &pb.Value{}, + Value: &pb.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("resolve"), + }, + }, + }, + }, + }, + { + Name: "ResolvePromiseMinimal", + Req: &t_api.Request{ + Kind: t_api.CompletePromise, + Tags: map[string]string{"id": "ResolvePromiseMinimal", "name": "CompletePromise"}, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: "foo", + IdempotencyKey: nil, + Strict: false, + State: promise.Resolved, + Value: promise.Value{}, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Resolved, + IdempotencyKeyForComplete: nil, + Value: promise.Value{}, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "PATCH", + Path: "promises/foo", + Headers: map[string]string{ + "Request-Id": "ResolvePromiseMinimal", + }, + Body: []byte(`{ + "state": "RESOLVED" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ResolvePromiseRequest{ + Id: "foo", + RequestId: "ResolvePromiseMinimal", + }, + Res: &pb.ResolvePromiseResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_RESOLVED, + IdempotencyKeyForComplete: "", + Param: &pb.Value{}, + Value: &pb.Value{}, + }, + }, + }, + }, + { + Name: "ResolvePromiseAlreadyCompleted", + Req: &t_api.Request{ + Kind: t_api.CompletePromise, + Tags: map[string]string{"id": "ResolvePromiseAlreadyCompleted", "name": "CompletePromise"}, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: "foo", + IdempotencyKey: nil, + Strict: false, + State: promise.Resolved, + Value: promise.Value{}, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseResponse{ + Status: t_api.StatusPromiseAlreadyResolved, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Resolved, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "PATCH", + Path: "promises/foo", + Headers: map[string]string{ + "Request-Id": "ResolvePromiseAlreadyCompleted", + }, + Body: []byte(`{ + "state": "RESOLVED" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 403, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ResolvePromiseRequest{ + Id: "foo", + RequestId: "ResolvePromiseAlreadyCompleted", + }, + Code: codes.PermissionDenied, + }, + }, + { + Name: "RejectPromise", + Req: &t_api.Request{ + Kind: t_api.CompletePromise, + Tags: map[string]string{"id": "RejectPromise", "name": "CompletePromise"}, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: "foo", + IdempotencyKey: util.ToPointer(idempotency.Key("bar")), + Strict: true, + State: promise.Rejected, + Value: promise.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("reject"), + }, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Rejected, + IdempotencyKeyForComplete: util.ToPointer(idempotency.Key("bar")), + Value: promise.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("reject"), + }, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "PATCH", + Path: "promises/foo", + Headers: map[string]string{ + "Request-Id": "RejectPromise", + "Idempotency-Key": "bar", + "Strict": "true", + }, + Body: []byte(`{ + "state": "REJECTED", + "value": { + "headers": {"a":"a","b":"b","c":"c"}, + "data": "cmVqZWN0" + } + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.RejectPromiseRequest{ + RequestId: "RejectPromise", + Id: "foo", + IdempotencyKey: "bar", + Strict: true, + Value: &pb.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("reject"), + }, + }, + Res: &pb.RejectPromiseResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_REJECTED, + IdempotencyKeyForComplete: "bar", + Param: &pb.Value{}, + Value: &pb.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("reject"), + }, + }, + }, + }, + }, + { + Name: "RejectPromiseMinimal", + Req: &t_api.Request{ + Kind: t_api.CompletePromise, + Tags: map[string]string{"id": "RejectPromiseMinimal", "name": "CompletePromise"}, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: "foo", + IdempotencyKey: nil, + Strict: false, + State: promise.Rejected, + Value: promise.Value{}, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Rejected, + IdempotencyKeyForComplete: nil, + Value: promise.Value{}, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "PATCH", + Path: "promises/foo", + Headers: map[string]string{ + "Request-Id": "RejectPromiseMinimal", + }, + Body: []byte(`{ + "state": "REJECTED" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.RejectPromiseRequest{ + Id: "foo", + RequestId: "RejectPromiseMinimal", + }, + Res: &pb.RejectPromiseResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_REJECTED, + IdempotencyKeyForComplete: "", + Param: &pb.Value{}, + Value: &pb.Value{}, + }, + }, + }, + }, + { + Name: "RejectPromiseAlreadyCompleted", + Req: &t_api.Request{ + Kind: t_api.CompletePromise, + Tags: map[string]string{"id": "RejectPromiseAlreadyCompleted", "name": "CompletePromise"}, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: "foo", + IdempotencyKey: nil, + Strict: false, + State: promise.Rejected, + Value: promise.Value{}, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseResponse{ + Status: t_api.StatusPromiseAlreadyRejected, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Rejected, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "PATCH", + Path: "promises/foo", + Headers: map[string]string{ + "Request-Id": "RejectPromiseAlreadyCompleted", + }, + Body: []byte(`{ + "state": "REJECTED" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 403, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.RejectPromiseRequest{ + Id: "foo", + RequestId: "RejectPromiseAlreadyCompleted", + }, + Code: codes.PermissionDenied, + }, + }, + { + Name: "CancelPromise", + Req: &t_api.Request{ + Kind: t_api.CompletePromise, + Tags: map[string]string{"id": "CancelPromise", "name": "CompletePromise"}, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: "foo", + IdempotencyKey: util.ToPointer(idempotency.Key("bar")), + Strict: true, + State: promise.Canceled, + Value: promise.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("cancel"), + }, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Canceled, + IdempotencyKeyForComplete: util.ToPointer(idempotency.Key("bar")), + Value: promise.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("cancel"), + }, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "PATCH", + Path: "promises/foo", + Headers: map[string]string{ + "Request-Id": "CancelPromise", + "Idempotency-Key": "bar", + "Strict": "true", + }, + Body: []byte(`{ + "state": "REJECTED_CANCELED", + "value": { + "headers": {"a":"a","b":"b","c":"c"}, + "data": "Y2FuY2Vs" + } + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CancelPromiseRequest{ + Id: "foo", + IdempotencyKey: "bar", + Strict: true, + Value: &pb.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("cancel"), + }, + RequestId: "CancelPromise", + }, + Res: &pb.CancelPromiseResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_REJECTED_CANCELED, + IdempotencyKeyForComplete: "bar", + Param: &pb.Value{}, + Value: &pb.Value{ + Headers: map[string]string{"a": "a", "b": "b", "c": "c"}, + Data: []byte("cancel"), + }, + }, + }, + }, + }, + { + Name: "CancelPromiseMinimal", + Req: &t_api.Request{ + Kind: t_api.CompletePromise, + Tags: map[string]string{"id": "CancelPromiseMinimal", "name": "CompletePromise"}, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: "foo", + IdempotencyKey: nil, + Strict: false, + State: promise.Canceled, + Value: promise.Value{}, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseResponse{ + Status: t_api.StatusCreated, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Canceled, + IdempotencyKeyForComplete: nil, + Value: promise.Value{}, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "PATCH", + Path: "promises/foo", + Headers: map[string]string{ + "Request-Id": "CancelPromiseMinimal", + }, + Body: []byte(`{ + "state": "REJECTED_CANCELED" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CancelPromiseRequest{ + RequestId: "CancelPromiseMinimal", + Id: "foo", + }, + Res: &pb.CancelPromiseResponse{ + Noop: false, + Promise: &pb.Promise{ + Id: "foo", + State: pb.State_REJECTED_CANCELED, + IdempotencyKeyForComplete: "", + Param: &pb.Value{}, + Value: &pb.Value{}, + }, + }, + }, + }, + { + Name: "CancelPromiseAlreadyCompleted", + Req: &t_api.Request{ + Kind: t_api.CompletePromise, + Tags: map[string]string{"id": "CancelPromiseAlreadyCompleted", "name": "CompletePromise"}, + CompletePromise: &t_api.CompletePromiseRequest{ + Id: "foo", + IdempotencyKey: nil, + Strict: false, + State: promise.Canceled, + Value: promise.Value{}, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompletePromise, + CompletePromise: &t_api.CompletePromiseResponse{ + Status: t_api.StatusPromiseAlreadyRejected, + Promise: &promise.Promise{ + Id: "foo", + State: promise.Canceled, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "PATCH", + Path: "promises/foo", + Headers: map[string]string{ + "Request-Id": "CancelPromiseAlreadyCompleted", + }, + Body: []byte(`{ + "state": "REJECTED_CANCELED" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 403, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CancelPromiseRequest{ + Id: "foo", + RequestId: "CancelPromiseAlreadyCompleted", + }, + Code: codes.PermissionDenied, + }, + }, + + // Callbacks + { + Name: "CreateCallbackLogicalReceiver", + Req: &t_api.Request{ + Kind: t_api.CreateCallback, + Tags: map[string]string{"id": "CreateCallback", "name": "CreateCallback"}, + CreateCallback: &t_api.CreateCallbackRequest{ + PromiseId: "foo", + RootPromiseId: "bar", + Timeout: 1, + Recv: []byte(`"foo"`), + }, + }, + Res: &t_api.Response{ + Kind: t_api.CreateCallback, + CreateCallback: &t_api.CreateCallbackResponse{ + Status: t_api.StatusCreated, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "callbacks", + Headers: map[string]string{ + "Request-Id": "CreateCallback", + }, + Body: []byte(`{ + "promiseId": "foo", + "rootPromiseId": "bar", + "timeout": 1, + "recv": "foo" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CreateCallbackRequest{ + PromiseId: "foo", + RootPromiseId: "bar", + Timeout: 1, + Recv: &pb.Recv{Recv: &pb.Recv_Logical{Logical: "foo"}}, + RequestId: "CreateCallback", + }, + }, + }, + { + Name: "CreateCallbackPhysicalReceiver", + Req: &t_api.Request{ + Kind: t_api.CreateCallback, + Tags: map[string]string{"id": "CreateCallbackPhysicalReceiver", "name": "CreateCallback"}, + CreateCallback: &t_api.CreateCallbackRequest{ + PromiseId: "foo", + RootPromiseId: "bar", + Timeout: 1, + Recv: []byte(`{"type":"http","data":{"url":"http://localhost:3000"}}`), + }, + }, + Res: &t_api.Response{ + Kind: t_api.CreateCallback, + CreateCallback: &t_api.CreateCallbackResponse{ + Status: t_api.StatusCreated, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "callbacks", + Headers: map[string]string{ + "Request-Id": "CreateCallbackPhysicalReceiver", + }, + Body: []byte(`{ + "promiseId": "foo", + "rootPromiseId": "bar", + "timeout": 1, + "recv": {"type":"http","data":{"url":"http://localhost:3000"}} + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CreateCallbackRequest{ + PromiseId: "foo", + RootPromiseId: "bar", + Timeout: 1, + Recv: &pb.Recv{Recv: &pb.Recv_Physical{Physical: &pb.PhysicalRecv{Type: "http", Data: []byte(`{"url":"http://localhost:3000"}`)}}}, + RequestId: "CreateCallbackPhysicalReceiver", + }, + }, + }, + { + Name: "CreateCallbackNotFound", + Req: &t_api.Request{ + Kind: t_api.CreateCallback, + Tags: map[string]string{"id": "CreateCallbackNotFound", "name": "CreateCallback"}, + CreateCallback: &t_api.CreateCallbackRequest{ + PromiseId: "foo", + RootPromiseId: "bar", + Timeout: 1, + Recv: []byte(`"foo"`), + }, + }, + Res: &t_api.Response{ + Kind: t_api.CreateCallback, + CreateCallback: &t_api.CreateCallbackResponse{ + Status: t_api.StatusPromiseNotFound, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "callbacks", + Headers: map[string]string{ + "Request-Id": "CreateCallbackNotFound", + }, + Body: []byte(`{ + "promiseId": "foo", + "rootPromiseId": "bar", + "timeout": 1, + "recv": "foo" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 404, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CreateCallbackRequest{ + PromiseId: "foo", + RootPromiseId: "bar", + Timeout: 1, + Recv: &pb.Recv{Recv: &pb.Recv_Logical{Logical: "foo"}}, + RequestId: "CreateCallbackNotFound", + }, + Code: codes.NotFound, + }, + }, + + // Schedules + { + Name: "ReadSchedule", + Req: &t_api.Request{ + Kind: t_api.ReadSchedule, + Tags: map[string]string{"id": "ReadSchedule", "name": "ReadSchedule"}, + ReadSchedule: &t_api.ReadScheduleRequest{ + Id: "foo", + }, + }, + Res: &t_api.Response{ + Kind: t_api.ReadSchedule, + ReadSchedule: &t_api.ReadScheduleResponse{ + Status: t_api.StatusOK, + Schedule: &schedule.Schedule{ + Id: "foo", + Description: "", + Cron: "* * * * * *", + PromiseId: "foo.{{.timestamp}}", + PromiseTimeout: 1000000, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "schedules/foo", + Headers: map[string]string{ + "Request-Id": "ReadSchedule", + }, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ReadScheduleRequest{ + Id: "foo", + RequestId: "ReadSchedule", + }, + }, + }, + { + Name: "SearchSchedules", + Req: &t_api.Request{ + Kind: t_api.SearchSchedules, + Tags: map[string]string{"id": "SearchSchedules", "name": "SearchSchedules"}, + SearchSchedules: &t_api.SearchSchedulesRequest{ + Id: "*", + Tags: map[string]string{}, + Limit: 10, + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchSchedules, + SearchSchedules: &t_api.SearchSchedulesResponse{ + Status: t_api.StatusOK, + Schedules: []*schedule.Schedule{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "schedules?id=*&limit=10", + Headers: map[string]string{ + "Request-Id": "SearchSchedules", + }, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchSchedulesRequest{ + RequestId: "SearchSchedules", + Id: "*", + Limit: 10, + }, + }, + }, + { + Name: "SearchSchedulesCursor", + Req: &t_api.Request{ + Kind: t_api.SearchSchedules, + Tags: map[string]string{"id": "SearchSchedulesCursor", "name": "SearchSchedules"}, + SearchSchedules: &t_api.SearchSchedulesRequest{ + Id: "*", + Tags: map[string]string{}, + Limit: 10, + SortId: util.ToPointer(int64(100)), + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchSchedules, + SearchSchedules: &t_api.SearchSchedulesResponse{ + Status: t_api.StatusOK, + Schedules: []*schedule.Schedule{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "schedules?cursor=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJOZXh0Ijp7ImlkIjoiKiIsInRhZ3MiOnt9LCJsaW1pdCI6MTAsInNvcnRJZCI6MTAwfX0.w5_elkl3n5yUHKIbxBzdA1sWRxvKLGVqsnz-H69p_JI", + Headers: map[string]string{"Request-Id": "SearchSchedulesCursor"}, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchSchedulesRequest{ + Id: "*", + Cursor: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJOZXh0Ijp7ImlkIjoiKiIsInRhZ3MiOnt9LCJsaW1pdCI6MTAsInNvcnRJZCI6MTAwfX0.w5_elkl3n5yUHKIbxBzdA1sWRxvKLGVqsnz-H69p_JI", + RequestId: "SearchSchedulesCursor", + }, + }, + }, + { + Name: "SearchSchedulesTags", + Req: &t_api.Request{ + Kind: t_api.SearchSchedules, + Tags: map[string]string{"id": "SearchSchedulesTags", "name": "SearchSchedules"}, + SearchSchedules: &t_api.SearchSchedulesRequest{ + Id: "*", + Tags: map[string]string{ + "foo": "bar", + }, + Limit: 10, + }, + }, + Res: &t_api.Response{ + Kind: t_api.SearchSchedules, + SearchSchedules: &t_api.SearchSchedulesResponse{ + Status: t_api.StatusOK, + Schedules: []*schedule.Schedule{}, + Cursor: nil, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "schedules?id=*&tags[foo]=bar&limit=10", + Headers: map[string]string{ + "Request-Id": "SearchSchedulesTags", + }, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchSchedulesRequest{ + Id: "*", + Tags: map[string]string{ + "foo": "bar", + }, + Limit: 10, + RequestId: "SearchSchedulesTags", + }, + }, + }, + { + Name: "SearchSchedulesInvalidQuery", + Req: nil, + Res: nil, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "schedules?id=", + }, + Res: &httpTestCaseResponse{ + Code: 400, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchSchedulesRequest{ + Id: "", + }, + Code: codes.InvalidArgument, + }, + }, + { + Name: "SearchSchedulesInvalidLimit", + Req: nil, + Res: nil, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "schedules?id=*&limit=0", + }, + Res: &httpTestCaseResponse{ + Code: 400, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchSchedulesRequest{ + Id: "*", + Limit: 0, + }, + Code: codes.InvalidArgument, + }, + }, + { + Name: "SearchSchedulesInvalidLimit", + Req: nil, + Res: nil, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "schedules?id=*&limit=101", + }, + Res: &httpTestCaseResponse{ + Code: 400, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.SearchSchedulesRequest{ + Id: "*", + Limit: 101, + }, + Code: codes.InvalidArgument, + }, + }, + { + Name: "CreateSchedule", + Req: &t_api.Request{ + Kind: t_api.CreateSchedule, + Tags: map[string]string{"id": "CreateSchedule", "name": "CreateSchedule"}, + CreateSchedule: &t_api.CreateScheduleRequest{ + Id: "foo", + IdempotencyKey: util.ToPointer(idempotency.Key("bar")), + Cron: "* * * * *", + PromiseId: "foo.{{.timestamp}}", + PromiseTimeout: 1, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CreateSchedule, + CreateSchedule: &t_api.CreateScheduleResponse{ + Status: t_api.StatusCreated, + Schedule: &schedule.Schedule{ + Id: "foo", + Description: "", + Cron: "* * * * *", + PromiseId: "foo.{{.timestamp}}", + PromiseTimeout: 1, + IdempotencyKey: util.ToPointer(idempotency.Key("bar")), + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "schedules", + Headers: map[string]string{ + "Request-Id": "CreateSchedule", + "Idempotency-Key": "bar", + }, + Body: []byte(`{ + "id": "foo", + "desc": "", + "cron": "* * * * *", + "promiseId": "foo.{{.timestamp}}", + "promiseTimeout": 1 + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CreateScheduleRequest{ + Id: "foo", + Description: "", + Cron: "* * * * *", + PromiseId: "foo.{{.timestamp}}", + PromiseTimeout: 1, + IdempotencyKey: "bar", + RequestId: "CreateSchedule", + }, + Res: &pb.CreatedScheduleResponse{ + Noop: false, + Schedule: &pb.Schedule{ + Id: "foo", + Description: "", + Cron: "* * * * *", + PromiseId: "foo.{{.timestamp}}", + PromiseTimeout: 1, + PromiseParam: &pb.Value{}, + IdempotencyKey: "bar", + }, + }, + }, + }, + { + Name: "DeleteSchedule", + Req: &t_api.Request{ + Kind: t_api.DeleteSchedule, + Tags: map[string]string{"id": "DeleteSchedule", "name": "DeleteSchedule"}, + DeleteSchedule: &t_api.DeleteScheduleRequest{ + Id: "foo", + }, + }, + Res: &t_api.Response{ + Kind: t_api.DeleteSchedule, + DeleteSchedule: &t_api.DeleteScheduleResponse{ + Status: t_api.StatusNoContent, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "DELETE", + Path: "schedules/foo", + Headers: map[string]string{ + "Request-Id": "DeleteSchedule", + }, + }, + Res: &httpTestCaseResponse{ + Code: 204, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.DeleteScheduleRequest{ + Id: "foo", + RequestId: "DeleteSchedule", + }, + }, + }, + + // Locks + { + Name: "AcquireLock", + Req: &t_api.Request{ + Kind: t_api.AcquireLock, + Tags: map[string]string{"id": "AcquireLock", "name": "AcquireLock"}, + AcquireLock: &t_api.AcquireLockRequest{ + ResourceId: "foo", + ProcessId: "bar", + ExecutionId: "baz", + ExpiryInMilliseconds: 1, + }, + }, + Res: &t_api.Response{ + Kind: t_api.AcquireLock, + AcquireLock: &t_api.AcquireLockResponse{ + Status: t_api.StatusCreated, + Lock: &lock.Lock{ + ResourceId: "foo", + ProcessId: "bar", + ExecutionId: "baz", + ExpiryInMilliseconds: 1, + }, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "locks/acquire", + Headers: map[string]string{ + "Request-Id": "AcquireLock", + }, + Body: []byte(`{ + "resourceId": "foo", + "processId": "bar", + "executionId": "baz", + "expiryInMilliseconds": 1 + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.AcquireLockRequest{ + RequestId: "AcquireLock", + ResourceId: "foo", + ProcessId: "bar", + ExecutionId: "baz", + ExpiryInMilliseconds: 1, + }, + }, + }, + { + Name: "ReleaseLock", + Req: &t_api.Request{ + Kind: t_api.ReleaseLock, + Tags: map[string]string{"id": "ReleaseLock", "name": "ReleaseLock"}, + ReleaseLock: &t_api.ReleaseLockRequest{ + ResourceId: "foo", + ExecutionId: "bar", + }, + }, + Res: &t_api.Response{ + Kind: t_api.ReleaseLock, + ReleaseLock: &t_api.ReleaseLockResponse{ + Status: t_api.StatusNoContent, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "locks/release", + Headers: map[string]string{ + "Request-Id": "ReleaseLock", + }, + Body: []byte(`{ + "resourceId": "foo", + "executionId": "bar" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 204, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ReleaseLockRequest{ + RequestId: "ReleaseLock", + ResourceId: "foo", + ExecutionId: "bar", + }, + }, + }, + { + Name: "HeartbeatLocks", + Req: &t_api.Request{ + Kind: t_api.HeartbeatLocks, + Tags: map[string]string{"id": "HeartbeatLocks", "name": "HeartbeatLocks"}, + HeartbeatLocks: &t_api.HeartbeatLocksRequest{ + ProcessId: "foo", + }, + }, + Res: &t_api.Response{ + Kind: t_api.HeartbeatLocks, + HeartbeatLocks: &t_api.HeartbeatLocksResponse{ + Status: t_api.StatusOK, + LocksAffected: 1, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "locks/heartbeat", + Headers: map[string]string{ + "Request-Id": "HeartbeatLocks", + }, + Body: []byte(`{ + "processId": "foo" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.HeartbeatLocksRequest{ + RequestId: "HeartbeatLocks", + ProcessId: "foo", + }, + }, + }, + + // Tasks + { + Name: "ClaimTask", + Req: &t_api.Request{ + Kind: t_api.ClaimTask, + Tags: map[string]string{"id": "ClaimTask", "name": "ClaimTask"}, + ClaimTask: &t_api.ClaimTaskRequest{ + Id: "foo", + Counter: 1, + ProcessId: "bar", + Frequency: 1, + }, + }, + Res: &t_api.Response{ + Kind: t_api.ClaimTask, + ClaimTask: &t_api.ClaimTaskResponse{ + Status: t_api.StatusCreated, + Task: &task.Task{Mesg: &message.Mesg{}}, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "tasks/claim", + Headers: map[string]string{ + "Request-Id": "ClaimTask", + }, + Body: []byte(`{ + "id": "foo", + "counter": 1, + "processId": "bar", + "frequency": 1 + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ClaimTaskRequest{ + Id: "foo", + Counter: 1, + ProcessId: "bar", + Frequency: 1, + RequestId: "ClaimTask", + }, + }, + }, + { + Name: "ClaimTaskGet", + Req: &t_api.Request{ + Kind: t_api.ClaimTask, + Tags: map[string]string{"id": "ClaimTaskGet", "name": "ClaimTask"}, + ClaimTask: &t_api.ClaimTaskRequest{ + Id: "foo", + Counter: 1, + ProcessId: "foo/1", // default process id for get endpoint + Frequency: 60000, + }, + }, + Res: &t_api.Response{ + Kind: t_api.ClaimTask, + ClaimTask: &t_api.ClaimTaskResponse{ + Status: t_api.StatusCreated, + Task: &task.Task{Mesg: &message.Mesg{}}, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "tasks/claim/foo/1", + Headers: map[string]string{ + "Request-Id": "ClaimTaskGet", + }, + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ClaimTaskRequest{ + Id: "foo", + Counter: 1, + ProcessId: "foo/1", + Frequency: 60000, + RequestId: "ClaimTaskGet", + }, + }, + }, + { + Name: "ClaimTaskInvoke", + Req: &t_api.Request{ + Kind: t_api.ClaimTask, + Tags: map[string]string{"id": "ClaimTaskInvoke", "name": "ClaimTask"}, + ClaimTask: &t_api.ClaimTaskRequest{ + Id: "foo", + Counter: 1, + ProcessId: "bar", + Frequency: 1, + }, + }, + Res: &t_api.Response{ + Kind: t_api.ClaimTask, + ClaimTask: &t_api.ClaimTaskResponse{ + Status: t_api.StatusCreated, + Task: &task.Task{Mesg: &message.Mesg{Type: message.Invoke, Root: "foo"}}, + RootPromise: &promise.Promise{Id: "foo", State: promise.Pending}, + RootPromiseHref: "http://localhost:8001/promises/foo", + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "tasks/claim", + Headers: map[string]string{ + "Request-Id": "ClaimTaskInvoke", + }, + Body: []byte(`{ + "id": "foo", + "counter": 1, + "processId": "bar", + "frequency": 1 + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + Body: []byte(util.RemoveWhitespace(`{ + "promises":{ + "root":{"data":{"id":"foo","state":"PENDING","param":{},"value":{},"timeout":0},"href":"http://localhost:8001/promises/foo","id":"foo"} + }, + "type":"invoke" + }`)), + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ClaimTaskRequest{ + Id: "foo", + Counter: 1, + ProcessId: "bar", + Frequency: 1, + RequestId: "ClaimTaskInvoke", + }, + Res: &pb.ClaimTaskResponse{ + Claimed: true, + Mesg: &pb.Mesg{ + Type: "invoke", + Promises: map[string]*pb.MesgPromise{ + "root": { + Id: "foo", + Href: "http://localhost:8001/promises/foo", + Data: &pb.Promise{Id: "foo", State: pb.State_PENDING, Param: &pb.Value{}, Value: &pb.Value{}}, + }, + }, + }, + }, + }, + }, + { + Name: "ClaimTaskResume", + Req: &t_api.Request{ + Kind: t_api.ClaimTask, + Tags: map[string]string{ + "id": "ClaimTaskResume", + "name": "ClaimTask", + "protocol": "http", + }, + ClaimTask: &t_api.ClaimTaskRequest{ + Id: "foo", + Counter: 2, + ProcessId: "bar", + Frequency: 1, + }, + }, + Res: &t_api.Response{ + Kind: t_api.ClaimTask, + ClaimTask: &t_api.ClaimTaskResponse{ + Status: t_api.StatusCreated, + Task: &task.Task{Mesg: &message.Mesg{Type: message.Resume, Root: "foo", Leaf: "bar"}}, + RootPromise: &promise.Promise{Id: "foo", State: promise.Pending}, + LeafPromise: &promise.Promise{Id: "bar", State: promise.Resolved}, + RootPromiseHref: "http://localhost:8001/promises/foo", + LeafPromiseHref: "http://localhost:8001/promises/bar", + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "tasks/claim", + Headers: map[string]string{ + "Request-Id": "ClaimTaskResume", + }, + Body: []byte(`{ + "id": "foo", + "processId": "bar", + "counter": 2, + "frequency": 1 + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + Body: []byte(util.RemoveWhitespace(`{ + "promises":{ + "leaf":{"data":{"id":"bar","state":"RESOLVED","param":{},"value":{},"timeout":0},"href":"http://localhost:8001/promises/bar","id":"bar"}, + "root":{"data":{"id":"foo","state":"PENDING","param":{},"value":{},"timeout":0},"href":"http://localhost:8001/promises/foo","id":"foo"} + }, + "type":"resume" + }`)), + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.ClaimTaskRequest{ + Id: "foo", + Counter: 2, + ProcessId: "bar", + Frequency: 1, + RequestId: "ClaimTaskResume", + }, + Res: &pb.ClaimTaskResponse{ + Claimed: true, + Mesg: &pb.Mesg{ + Type: "resume", + Promises: map[string]*pb.MesgPromise{ + "root": { + Id: "foo", + Href: "http://localhost:8001/promises/foo", + Data: &pb.Promise{Id: "foo", State: pb.State_PENDING, Param: &pb.Value{}, Value: &pb.Value{}}, + }, + "leaf": { + Id: "bar", + Href: "http://localhost:8001/promises/bar", + Data: &pb.Promise{Id: "bar", State: pb.State_RESOLVED, Param: &pb.Value{}, Value: &pb.Value{}}, + }, + }, + }, + }, + }, + }, + { + Name: "CompleteTask", + Req: &t_api.Request{ + Kind: t_api.CompleteTask, + Tags: map[string]string{"id": "CompleteTask", "name": "CompleteTask"}, + CompleteTask: &t_api.CompleteTaskRequest{ + Id: "foo", + Counter: 1, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompleteTask, + CompleteTask: &t_api.CompleteTaskResponse{ + Status: t_api.StatusCreated, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "tasks/complete", + Headers: map[string]string{ + "Request-Id": "CompleteTask", + }, + Body: []byte(`{ + "id": "foo", + "counter": 1 + }`), + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CompleteTaskRequest{ + Id: "foo", + Counter: 1, + RequestId: "CompleteTask", + }, + }, + }, + { + Name: "CompleteTaskGet", + Req: &t_api.Request{ + Kind: t_api.CompleteTask, + Tags: map[string]string{"id": "CompleteTaskGet", "name": "CompleteTask"}, + CompleteTask: &t_api.CompleteTaskRequest{ + Id: "foo", + Counter: 1, + }, + }, + Res: &t_api.Response{ + Kind: t_api.CompleteTask, + CompleteTask: &t_api.CompleteTaskResponse{ + Status: t_api.StatusCreated, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "tasks/complete/foo/1", + Headers: map[string]string{ + "Request-Id": "CompleteTaskGet", + }, + }, + Res: &httpTestCaseResponse{ + Code: 201, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.CompleteTaskRequest{ + Id: "foo", + Counter: 1, + RequestId: "CompleteTaskGet", + }, + }, + }, + { + Name: "HeartbeatTasks", + Req: &t_api.Request{ + Kind: t_api.HeartbeatTasks, + Tags: map[string]string{"id": "HeartbeatTasks", "name": "HeartbeatTasks"}, + HeartbeatTasks: &t_api.HeartbeatTasksRequest{ + ProcessId: "foo", + }, + }, + Res: &t_api.Response{ + Kind: t_api.HeartbeatTasks, + HeartbeatTasks: &t_api.HeartbeatTasksResponse{ + Status: t_api.StatusOK, + TasksAffected: 1, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "POST", + Path: "tasks/heartbeat", + Headers: map[string]string{ + "Request-Id": "HeartbeatTasks", + }, + Body: []byte(`{ + "processId": "foo" + }`), + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.HeartbeatTasksRequest{ + ProcessId: "foo", + RequestId: "HeartbeatTasks", + }, + }, + }, + { + Name: "HeartbeatTasksGet", + Req: &t_api.Request{ + Kind: t_api.HeartbeatTasks, + Tags: map[string]string{"id": "HeartbeatTasksGet", "name": "HeartbeatTasks"}, + HeartbeatTasks: &t_api.HeartbeatTasksRequest{ + ProcessId: "foo/1", + }, + }, + Res: &t_api.Response{ + Kind: t_api.HeartbeatTasks, + HeartbeatTasks: &t_api.HeartbeatTasksResponse{ + Status: t_api.StatusOK, + TasksAffected: 1, + }, + }, + Http: &httpTestCase{ + Req: &httpTestCaseRequest{ + Method: "GET", + Path: "tasks/heartbeat/foo/1", + Headers: map[string]string{ + "Request-Id": "HeartbeatTasksGet", + }, + }, + Res: &httpTestCaseResponse{ + Code: 200, + }, + }, + Grpc: &grpcTestCase{ + Req: &pb.HeartbeatTasksRequest{ + ProcessId: "foo/1", + RequestId: "HeartbeatTasksGet", + }, + }, + }, +} diff --git a/internal/kernel/system/system.go b/internal/kernel/system/system.go index 9493246a..417c10a6 100644 --- a/internal/kernel/system/system.go +++ b/internal/kernel/system/system.go @@ -193,6 +193,10 @@ func (s *System) AddOnRequest(kind t_api.Kind, constructor func(gocoro.Coroutine util.Assert(req.Tags != nil, "request tags must be non nil") util.Assert(req.Tags["id"] != "", "id tag must be set") + // set config + c.Set("config", s.config) + + // run coroutine res, err := constructor(c, req) s.api.EnqueueCQE(&bus.CQE[t_api.Request, t_api.Response]{ diff --git a/internal/kernel/t_aio/router.go b/internal/kernel/t_aio/router.go index 248238a0..02446a93 100644 --- a/internal/kernel/t_aio/router.go +++ b/internal/kernel/t_aio/router.go @@ -16,7 +16,7 @@ func (s *RouterSubmission) String() string { type RouterCompletion struct { Matched bool - Command *CreateTaskCommand + Recv []byte } func (c *RouterCompletion) String() string { diff --git a/internal/kernel/t_aio/sender.go b/internal/kernel/t_aio/sender.go index e83346f1..e8f67898 100644 --- a/internal/kernel/t_aio/sender.go +++ b/internal/kernel/t_aio/sender.go @@ -7,7 +7,10 @@ import ( ) type SenderSubmission struct { - Task *task.Task + Task *task.Task + ClaimHref string + CompleteHref string + HeartbeatHref string } func (s *SenderSubmission) String() string { diff --git a/internal/kernel/t_aio/store.go b/internal/kernel/t_aio/store.go index 7ce3806f..9ea77385 100644 --- a/internal/kernel/t_aio/store.go +++ b/internal/kernel/t_aio/store.go @@ -3,9 +3,9 @@ package t_aio import ( "fmt" - "github.com/resonatehq/resonate/pkg/callback" "github.com/resonatehq/resonate/pkg/idempotency" "github.com/resonatehq/resonate/pkg/lock" + "github.com/resonatehq/resonate/pkg/message" "github.com/resonatehq/resonate/pkg/promise" "github.com/resonatehq/resonate/pkg/schedule" "github.com/resonatehq/resonate/pkg/task" @@ -266,9 +266,9 @@ type AlterPromisesResult struct { type CreateCallbackCommand struct { PromiseId string - Timeout int64 Recv []byte - Mesg []byte + Mesg *message.Mesg + Timeout int64 CreatedOn int64 } @@ -278,11 +278,6 @@ type DeleteCallbacksCommand struct { // Callback results -type QueryCallbacksResult struct { - RowsReturned int64 - Records []*callback.CallbackRecord -} - type AlterCallbacksResult struct { RowsAffected int64 LastInsertId string @@ -355,10 +350,14 @@ type ReadTasksCommand struct { } type CreateTaskCommand struct { - Recv []byte - Mesg []byte - Timeout int64 - CreatedOn int64 + Recv []byte + Mesg *message.Mesg + Timeout int64 + ProcessId *string + State task.State + Frequency int + Expiration int64 + CreatedOn int64 } type CreateTasksCommand struct { @@ -393,6 +392,7 @@ type QueryTasksResult struct { type AlterTasksResult struct { RowsAffected int64 + LastInsertId string } // Lock commands diff --git a/internal/kernel/t_api/api.go b/internal/kernel/t_api/api.go index f8e4f7c7..6db0bbcf 100644 --- a/internal/kernel/t_api/api.go +++ b/internal/kernel/t_api/api.go @@ -7,6 +7,8 @@ const ( ReadPromise Kind = iota SearchPromises CreatePromise + CreatePromiseAndTask + CreatePromiseAndCallback CompletePromise // CALLBACKS @@ -41,6 +43,10 @@ func (k Kind) String() string { return "SearchPromises" case CreatePromise: return "CreatePromise" + case CreatePromiseAndTask: + return "CreatePromiseAndTask" + case CreatePromiseAndCallback: + return "CreatePromiseAndCallback" case CompletePromise: return "CompletePromise" // CALLBACKS diff --git a/internal/kernel/t_api/request.go b/internal/kernel/t_api/request.go index 614e6642..11d7889c 100644 --- a/internal/kernel/t_api/request.go +++ b/internal/kernel/t_api/request.go @@ -1,9 +1,10 @@ package t_api import ( + "encoding/json" "fmt" - "strconv" + "github.com/resonatehq/resonate/internal/util" "github.com/resonatehq/resonate/pkg/idempotency" "github.com/resonatehq/resonate/pkg/promise" ) @@ -13,10 +14,12 @@ type Request struct { Tags map[string]string // PROMISES - ReadPromise *ReadPromiseRequest - SearchPromises *SearchPromisesRequest - CreatePromise *CreatePromiseRequest - CompletePromise *CompletePromiseRequest + ReadPromise *ReadPromiseRequest + SearchPromises *SearchPromisesRequest + CreatePromise *CreatePromiseRequest + CreatePromiseAndTask *CreatePromiseAndTaskRequest + CreatePromiseAndCallback *CreatePromiseAndCallbackRequest + CompletePromise *CompletePromiseRequest // CALLBACKS CreateCallback *CreateCallbackRequest @@ -47,6 +50,10 @@ type ReadPromiseRequest struct { Id string `json:"id"` } +func (r *ReadPromiseRequest) String() string { + return fmt.Sprintf("ReadPromise(id=%s)", r.Id) +} + type SearchPromisesRequest struct { Id string `json:"id"` States []promise.State `json:"states"` @@ -55,6 +62,10 @@ type SearchPromisesRequest struct { SortId *int64 `json:"sortId"` } +func (r *SearchPromisesRequest) String() string { + return fmt.Sprintf("SearchPromises(id=%s, states=%v, tags=%v, limit=%d, sortId=%d)", r.Id, r.States, r.Tags, r.Limit, util.SafeDeref(r.SortId)) +} + type CreatePromiseRequest struct { Id string `json:"id"` IdempotencyKey *idempotency.Key `json:"idemptencyKey,omitempty"` @@ -64,42 +75,51 @@ type CreatePromiseRequest struct { Tags map[string]string `json:"tags,omitempty"` } -type CompletePromiseRequest struct { - Id string `json:"id"` - IdempotencyKey *idempotency.Key `json:"idemptencyKey,omitempty"` - Strict bool `json:"strict"` - State promise.State `json:"state"` - Value promise.Value `json:"value,omitempty"` +func (r *CreatePromiseRequest) String() string { + return fmt.Sprintf("CreatePromise(id=%s, idempotencyKey=%v, strict=%v, param=%v, timeout=%d, tags=%v)", r.Id, r.IdempotencyKey, r.Strict, r.Param, r.Timeout, r.Tags) } -type CancelPromiseRequest struct { - Id string `json:"id"` - IdempotencyKey *idempotency.Key `json:"idemptencyKey,omitempty"` - Strict bool `json:"strict"` - Value promise.Value `json:"value,omitempty"` +type CreatePromiseAndTaskRequest struct { + Promise *CreatePromiseRequest + Task *CreateTaskRequest } -type ResolvePromiseRequest struct { - Id string `json:"id"` - IdempotencyKey *idempotency.Key `json:"idemptencyKey,omitempty"` - Strict bool `json:"strict"` - Value promise.Value `json:"value,omitempty"` +func (r *CreatePromiseAndTaskRequest) String() string { + return fmt.Sprintf("CreatePromiseAndTask(promise=%v, task=%v)", r.Promise, r.Task) +} + +type CreatePromiseAndCallbackRequest struct { + Promise *CreatePromiseRequest + Callback *CreateCallbackRequest +} + +func (r *CreatePromiseAndCallbackRequest) String() string { + return fmt.Sprintf("CreatePromiseAndCallback(promise=%v, callback=%v)", r.Promise, r.Callback) } -type RejectPromiseRequest struct { +type CompletePromiseRequest struct { Id string `json:"id"` IdempotencyKey *idempotency.Key `json:"idemptencyKey,omitempty"` Strict bool `json:"strict"` + State promise.State `json:"state"` Value promise.Value `json:"value,omitempty"` } +func (r *CompletePromiseRequest) String() string { + return fmt.Sprintf("CompletePromise(id=%s, idempotencyKey=%v, strict=%v, state=%v, value=%v)", r.Id, r.IdempotencyKey, r.Strict, r.State, r.Value) +} + // Callbacks type CreateCallbackRequest struct { - PromiseId string `json:"promiseId"` - RootPromiseId string `json:"rootPromiseId"` // TODO: we should be able to know this from the promiseId - Timeout int64 `json:"timeout"` - Recv []byte `json:"recv"` + PromiseId string `json:"promiseId"` + RootPromiseId string `json:"rootPromiseId"` // TODO: we should be able to know this from the promise itself + Timeout int64 `json:"timeout"` + Recv json.RawMessage `json:"recv"` +} + +func (r *CreateCallbackRequest) String() string { + return fmt.Sprintf("CreateCallback(promiseId=%s, rootPromiseId=%s, timeout=%d, recv=%s)", r.PromiseId, r.RootPromiseId, r.Timeout, r.Recv) } // Schedules @@ -108,6 +128,10 @@ type ReadScheduleRequest struct { Id string `json:"id"` } +func (r *ReadScheduleRequest) String() string { + return fmt.Sprintf("ReadSchedule(id=%s)", r.Id) +} + type SearchSchedulesRequest struct { Id string `json:"id"` Tags map[string]string `json:"tags"` @@ -115,6 +139,10 @@ type SearchSchedulesRequest struct { SortId *int64 `json:"sortId"` } +func (r *SearchSchedulesRequest) String() string { + return fmt.Sprintf("SearchSchedules(id=%s, tags=%v, limit=%d, sortId=%d)", r.Id, r.Tags, r.Limit, util.SafeDeref(r.SortId)) +} + type CreateScheduleRequest struct { Id string `json:"id"` Description string `json:"desc,omitempty"` @@ -127,10 +155,29 @@ type CreateScheduleRequest struct { IdempotencyKey *idempotency.Key `json:"idemptencyKey,omitempty"` } +func (r *CreateScheduleRequest) String() string { + return fmt.Sprintf( + "CreateSchedule(id=%s, desc=%s, cron=%s, tags=%v, promiseId=%s, promiseTimeout=%d, promiseParam=%v, promiseTags=%v, idempotencyKey=%v)", + r.Id, + r.Description, + r.Cron, + r.Tags, + r.PromiseId, + r.PromiseTimeout, + r.PromiseParam, + r.PromiseTags, + r.IdempotencyKey, + ) +} + type DeleteScheduleRequest struct { Id string `json:"id"` } +func (r *DeleteScheduleRequest) String() string { + return fmt.Sprintf("DeleteSchedule(id=%s)", r.Id) +} + // Locks type AcquireLockRequest struct { @@ -140,17 +187,41 @@ type AcquireLockRequest struct { ExpiryInMilliseconds int64 `json:"expiryInMilliseconds"` } +func (r *AcquireLockRequest) String() string { + return fmt.Sprintf("AcquireLock(resourceId=%s, executionId=%s, processId=%s, expiryInMilliseconds=%d)", r.ResourceId, r.ExecutionId, r.ProcessId, r.ExpiryInMilliseconds) +} + type ReleaseLockRequest struct { ResourceId string `json:"resourceId"` ExecutionId string `json:"executionId"` } +func (r *ReleaseLockRequest) String() string { + return fmt.Sprintf("ReleaseLock(resourceId=%s, executionId=%s)", r.ResourceId, r.ExecutionId) +} + type HeartbeatLocksRequest struct { ProcessId string `json:"processId"` } +func (r *HeartbeatLocksRequest) String() string { + return fmt.Sprintf("HeartbeatLocks(processId=%s)", r.ProcessId) +} + // Tasks +type CreateTaskRequest struct { + PromiseId string `json:"promiseId"` + ProcessId string `json:"processId"` + Frequency int `json:"frequency"` + Timeout int64 `json:"timeout"` + Recv json.RawMessage `json:"recv"` +} + +func (r *CreateTaskRequest) String() string { + return fmt.Sprintf("CreateTask(promiseId=%s, processId=%s, frequency=%d, timeout=%d, recv=%s)", r.PromiseId, r.ProcessId, r.Frequency, r.Timeout, r.Recv) +} + type ClaimTaskRequest struct { Id string `json:"id"` Counter int `json:"counter"` @@ -158,150 +229,87 @@ type ClaimTaskRequest struct { Frequency int `json:"frequency"` } +func (r *ClaimTaskRequest) String() string { + return fmt.Sprintf("ClaimTask(id=%s, counter=%d, processId=%s, frequency=%d)", r.Id, r.Counter, r.ProcessId, r.Frequency) +} + type CompleteTaskRequest struct { Id string `json:"id"` Counter int `json:"counter"` } +func (r *CompleteTaskRequest) String() string { + return fmt.Sprintf("CompleteTask(id=%s, counter=%d)", r.Id, r.Counter) +} + type HeartbeatTasksRequest struct { ProcessId string `json:"processId"` } +func (r *HeartbeatTasksRequest) String() string { + return fmt.Sprintf("HeartbeatTasks(processId=%s)", r.ProcessId) +} + // Echo type EchoRequest struct { Data string `json:"data"` } +func (r *EchoRequest) String() string { + return fmt.Sprintf("Echo(data=%s)", r.Data) +} + func (r *Request) String() string { switch r.Kind { // PROMISES case ReadPromise: - return fmt.Sprintf( - "ReadPromise(id=%s)", - r.ReadPromise.Id, - ) + return r.ReadPromise.String() case SearchPromises: - sortId := "" - if r.SearchPromises.SortId != nil { - sortId = strconv.FormatInt(*r.SearchPromises.SortId, 10) - } - - return fmt.Sprintf( - "SearchPromises(id=%s, states=%s, tags=%s, limit=%d, sortId=%s)", - r.SearchPromises.Id, - r.SearchPromises.States, - r.SearchPromises.Tags, - r.SearchPromises.Limit, - sortId, - ) + return r.SearchPromises.String() case CreatePromise: - return fmt.Sprintf( - "CreatePromise(id=%s, idempotencyKey=%s, strict=%t, timeout=%d)", - r.CreatePromise.Id, - r.CreatePromise.IdempotencyKey, - r.CreatePromise.Strict, - r.CreatePromise.Timeout, - ) + return r.CreatePromise.String() + case CreatePromiseAndTask: + return r.CreatePromiseAndTask.String() + case CreatePromiseAndCallback: + return r.CreatePromiseAndCallback.String() case CompletePromise: - return fmt.Sprintf( - "CompletePromise(id=%s, idempotencyKey=%s, strict=%t, state=%s)", - r.CompletePromise.Id, - r.CompletePromise.IdempotencyKey, - r.CompletePromise.Strict, - r.CompletePromise.State, - ) + return r.CompletePromise.String() // CALLBACKS case CreateCallback: - return fmt.Sprintf( - "CreateCallback(promiseId=%s, rootPromiseId=%s, timeout=%d)", - r.CreateCallback.PromiseId, - r.CreateCallback.RootPromiseId, - r.CreateCallback.Timeout, - ) + return r.CreateCallback.String() // SCHEDULES case ReadSchedule: - return fmt.Sprintf( - "ReadSchedule(id=%s)", - r.ReadSchedule.Id, - ) + return r.ReadSchedule.String() case SearchSchedules: - sortId := "" - if r.SearchSchedules.SortId != nil { - sortId = strconv.FormatInt(*r.SearchSchedules.SortId, 10) - } - - return fmt.Sprintf( - "SearchSchedules(id=%s, tags=%s, limit=%d, sortId=%s)", - r.SearchSchedules.Id, - r.SearchSchedules.Tags, - r.SearchSchedules.Limit, - sortId, - ) + return r.SearchSchedules.String() case CreateSchedule: - return fmt.Sprintf( - "CreateSchedule(id=%s, idempotencyKey=%s, description=%s, cron=%s)", - r.CreateSchedule.Id, - r.CreateSchedule.IdempotencyKey, - r.CreateSchedule.Description, - r.CreateSchedule.Cron, - ) + return r.CreateSchedule.String() case DeleteSchedule: - return fmt.Sprintf( - "DeleteSchedule(id=%s)", - r.DeleteSchedule.Id, - ) + return r.DeleteSchedule.String() // LOCKS case AcquireLock: - return fmt.Sprintf( - "AcquireLock(resourceId=%s, executionId=%s, processId=%s, expiryInMilliseconds=%d)", - r.AcquireLock.ResourceId, - r.AcquireLock.ExecutionId, - r.AcquireLock.ProcessId, - r.AcquireLock.ExpiryInMilliseconds, - ) + return r.AcquireLock.String() case ReleaseLock: - return fmt.Sprintf( - "ReleaseLock(resourceId=%s, executionId=%s)", - r.ReleaseLock.ResourceId, - r.ReleaseLock.ExecutionId, - ) + return r.ReleaseLock.String() case HeartbeatLocks: - return fmt.Sprintf( - "HeartbeatLocks(processId=%s)", - r.HeartbeatLocks.ProcessId, - ) + return r.HeartbeatLocks.String() // TASKS case ClaimTask: - return fmt.Sprintf( - "ClaimTask(id=%s, processId=%s, counter=%d, frequency=%d)", - r.ClaimTask.Id, - r.ClaimTask.ProcessId, - r.ClaimTask.Counter, - r.ClaimTask.Frequency, - ) + return r.ClaimTask.String() case CompleteTask: - return fmt.Sprintf( - "CompleteTask(id=%s, counter=%d)", - r.CompleteTask.Id, - r.CompleteTask.Counter, - ) + return r.CompleteTask.String() case HeartbeatTasks: - return fmt.Sprintf( - "HeartbeatTasks(processId=%s)", - r.HeartbeatTasks.ProcessId, - ) + return r.HeartbeatTasks.String() // ECHO case Echo: - return fmt.Sprintf( - "Echo(data=%s)", - r.Echo.Data, - ) + return r.Echo.String() + default: return "Request" } diff --git a/internal/kernel/t_api/response.go b/internal/kernel/t_api/response.go index af363de4..ca6d9c98 100644 --- a/internal/kernel/t_api/response.go +++ b/internal/kernel/t_api/response.go @@ -5,9 +5,9 @@ import ( "github.com/resonatehq/resonate/pkg/callback" "github.com/resonatehq/resonate/pkg/lock" - "github.com/resonatehq/resonate/pkg/message" "github.com/resonatehq/resonate/pkg/promise" "github.com/resonatehq/resonate/pkg/schedule" + "github.com/resonatehq/resonate/pkg/task" ) type Response struct { @@ -15,18 +15,20 @@ type Response struct { Tags map[string]string // Promises - CreatePromise *CreatePromiseResponse - ReadPromise *ReadPromiseResponse - SearchPromises *SearchPromisesResponse - CompletePromise *CompletePromiseResponse + ReadPromise *ReadPromiseResponse + SearchPromises *SearchPromisesResponse + CreatePromise *CreatePromiseResponse + CreatePromiseAndTask *CreatePromiseAndTaskResponse + CreatePromiseAndCallback *CreatePromiseAndCallbackResponse + CompletePromise *CompletePromiseResponse // CALLBACKS CreateCallback *CreateCallbackResponse // SCHEDULES - CreateSchedule *CreateScheduleResponse - SearchSchedules *SearchSchedulesResponse ReadSchedule *ReadScheduleResponse + SearchSchedules *SearchSchedulesResponse + CreateSchedule *CreateScheduleResponse DeleteSchedule *DeleteScheduleResponse // LOCKS @@ -45,20 +47,52 @@ type Response struct { // Promises -type CreatePromiseResponse struct { +type ReadPromiseResponse struct { Status StatusCode `json:"status"` Promise *promise.Promise `json:"promise,omitempty"` } -type ReadPromiseResponse struct { - Status StatusCode `json:"status"` - Promise *promise.Promise `json:"promise,omitempty"` +func (r *ReadPromiseResponse) String() string { + return fmt.Sprintf("ReadPromise(status=%d, promise=%v)", r.Status, r.Promise) } type SearchPromisesResponse struct { Status StatusCode `json:"status"` - Cursor *Cursor[SearchPromisesRequest] `json:"cursor,omitempty"` Promises []*promise.Promise `json:"promises,omitempty"` + Cursor *Cursor[SearchPromisesRequest] `json:"cursor,omitempty"` +} + +func (r *SearchPromisesResponse) String() string { + return fmt.Sprintf("SearchPromises(status=%d, promises=%v, cursor=%v)", r.Status, r.Promises, r.Cursor) +} + +type CreatePromiseResponse struct { + Status StatusCode `json:"status"` + Promise *promise.Promise `json:"promise,omitempty"` +} + +func (r *CreatePromiseResponse) String() string { + return fmt.Sprintf("CreatePromise(status=%d, promise=%v)", r.Status, r.Promise) +} + +type CreatePromiseAndTaskResponse struct { + Status StatusCode `json:"status"` + Promise *promise.Promise `json:"promise,omitempty"` + Task *task.Task `json:"task,omitempty"` +} + +func (r *CreatePromiseAndTaskResponse) String() string { + return fmt.Sprintf("CreatePromiseAndTask(status=%d, promise=%v, task=%v)", r.Status, r.Promise, r.Task) +} + +type CreatePromiseAndCallbackResponse struct { + Status StatusCode `json:"status"` + Promise *promise.Promise `json:"promise,omitempty"` + Callback *callback.Callback `json:"callback,omitempty"` +} + +func (r *CreatePromiseAndCallbackResponse) String() string { + return fmt.Sprintf("CreatePromiseAndCallback(status=%d, promise=%v, callback=%v)", r.Status, r.Promise, r.Callback) } type CompletePromiseResponse struct { @@ -66,6 +100,10 @@ type CompletePromiseResponse struct { Promise *promise.Promise `json:"promise,omitempty"` } +func (r *CompletePromiseResponse) String() string { + return fmt.Sprintf("CompletePromise(status=%d, promise=%v)", r.Status, r.Promise) +} + // Callbacks type CreateCallbackResponse struct { @@ -74,28 +112,48 @@ type CreateCallbackResponse struct { Callback *callback.Callback `json:"callback,omitempty"` } +func (r *CreateCallbackResponse) String() string { + return fmt.Sprintf("CreateCallback(status=%d, promise=%v, callback=%v)", r.Status, r.Promise, r.Callback) +} + // Schedules -type CreateScheduleResponse struct { +type ReadScheduleResponse struct { Status StatusCode `json:"status"` Schedule *schedule.Schedule `json:"schedule,omitempty"` } +func (r *ReadScheduleResponse) String() string { + return fmt.Sprintf("ReadSchedule(status=%d, schedule=%v)", r.Status, r.Schedule) +} + type SearchSchedulesResponse struct { Status StatusCode `json:"status"` - Cursor *Cursor[SearchSchedulesRequest] `json:"cursor,omitempty"` Schedules []*schedule.Schedule `json:"schedules,omitempty"` + Cursor *Cursor[SearchSchedulesRequest] `json:"cursor,omitempty"` } -type ReadScheduleResponse struct { +func (r *SearchSchedulesResponse) String() string { + return fmt.Sprintf("SearchSchedules(status=%d, schedules=%v, cursor=%v)", r.Status, r.Schedules, r.Cursor) +} + +type CreateScheduleResponse struct { Status StatusCode `json:"status"` Schedule *schedule.Schedule `json:"schedule,omitempty"` } +func (r *CreateScheduleResponse) String() string { + return fmt.Sprintf("CreateSchedule(status=%d, schedule=%v)", r.Status, r.Schedule) +} + type DeleteScheduleResponse struct { Status StatusCode `json:"status"` } +func (r *DeleteScheduleResponse) String() string { + return fmt.Sprintf("DeleteSchedule(status=%d)", r.Status) +} + // Locks type AcquireLockResponse struct { @@ -103,24 +161,49 @@ type AcquireLockResponse struct { Lock *lock.Lock `json:"lock,omitempty"` } +func (r *AcquireLockResponse) String() string { + return fmt.Sprintf("AcquireLock(status=%d, lock=%v)", r.Status, r.Lock) +} + type ReleaseLockResponse struct { Status StatusCode `json:"status"` } +func (r *ReleaseLockResponse) String() string { + return fmt.Sprintf("ReleaseLock(status=%d)", r.Status) +} + type HeartbeatLocksResponse struct { Status StatusCode `json:"status"` LocksAffected int64 `json:"locksAffected"` } +func (r *HeartbeatLocksResponse) String() string { + return fmt.Sprintf("HeartbeatLocks(status=%d, locksAffected=%d)", r.Status, r.LocksAffected) +} + // Tasks type ClaimTaskResponse struct { - Status StatusCode `json:"status"` - Mesg *message.Mesg `json:"mesg,omitempty"` + Status StatusCode `json:"status"` + Task *task.Task `json:"task,omitempty"` + RootPromise *promise.Promise `json:"rootPromise,omitempty"` + LeafPromise *promise.Promise `json:"leafPromise,omitempty"` + RootPromiseHref string `json:"rootPromiseHref,omitempty"` + LeafPromiseHref string `json:"leafPromiseHref,omitempty"` +} + +func (r *ClaimTaskResponse) String() string { + return fmt.Sprintf("ClaimTask(status=%d, task=%v)", r.Status, r.Task) } type CompleteTaskResponse struct { Status StatusCode `json:"status"` + Task *task.Task `json:"task,omitempty"` +} + +func (r *CompleteTaskResponse) String() string { + return fmt.Sprintf("CompleteTask(status=%d, task=%v)", r.Status, r.Task) } type HeartbeatTasksResponse struct { @@ -128,12 +211,20 @@ type HeartbeatTasksResponse struct { TasksAffected int64 `json:"tasksAffected"` } +func (r *HeartbeatTasksResponse) String() string { + return fmt.Sprintf("HeartbeatTasks(status=%d, tasksAffected=%d)", r.Status, r.TasksAffected) +} + // Echo type EchoResponse struct { Data string `json:"data"` } +func (r *EchoResponse) String() string { + return fmt.Sprintf("Echo(data=%s)", r.Data) +} + func (r *Response) Status() StatusCode { switch r.Kind { // PROMISES @@ -143,11 +234,17 @@ func (r *Response) Status() StatusCode { return r.SearchPromises.Status case CreatePromise: return r.CreatePromise.Status + case CreatePromiseAndTask: + return r.CreatePromiseAndTask.Status + case CreatePromiseAndCallback: + return r.CreatePromiseAndCallback.Status case CompletePromise: return r.CompletePromise.Status + // CALLBACKS case CreateCallback: return r.CreateCallback.Status + // SCHEDULES case ReadSchedule: return r.ReadSchedule.Status @@ -157,6 +254,7 @@ func (r *Response) Status() StatusCode { return r.CreateSchedule.Status case DeleteSchedule: return r.DeleteSchedule.Status + // LOCKS case AcquireLock: return r.AcquireLock.Status @@ -164,6 +262,7 @@ func (r *Response) Status() StatusCode { return r.ReleaseLock.Status case HeartbeatLocks: return r.HeartbeatLocks.Status + // TASKS case ClaimTask: return r.ClaimTask.Status @@ -171,9 +270,11 @@ func (r *Response) Status() StatusCode { return r.CompleteTask.Status case HeartbeatTasks: return r.HeartbeatTasks.Status + // ECHO case Echo: return 200 + default: panic(fmt.Sprintf("invalid response kind: %s", r.Kind)) } @@ -183,110 +284,52 @@ func (r *Response) String() string { switch r.Kind { // PROMISES case ReadPromise: - return fmt.Sprintf( - "ReadPromise(status=%d, promise=%s)", - r.ReadPromise.Status, - r.ReadPromise.Promise, - ) + return r.ReadPromise.String() case SearchPromises: - return fmt.Sprintf( - "SearchPromises(status=%d, cursor=%s, promises=%s)", - r.SearchPromises.Status, - r.SearchPromises.Cursor, - r.SearchPromises.Promises, - ) + return r.SearchPromises.String() case CreatePromise: - return fmt.Sprintf( - "CreatePromise(status=%d, promise=%s)", - r.CreatePromise.Status, - r.CreatePromise.Promise, - ) + return r.CreatePromise.String() + case CreatePromiseAndTask: + return r.CreatePromiseAndTask.String() + case CreatePromiseAndCallback: + return r.CreatePromiseAndCallback.String() case CompletePromise: - return fmt.Sprintf( - "CompletePromise(status=%d, promise=%s)", - r.CompletePromise.Status, - r.CompletePromise.Promise, - ) + return r.CompletePromise.String() // CALLBACKS case CreateCallback: - return fmt.Sprintf( - "CreateCallback(status=%d, promise=%s, callback=%s)", - r.CreateCallback.Status, - r.CreateCallback.Promise, - r.CreateCallback.Callback, - ) + return r.CreateCallback.String() // SCHEDULES case ReadSchedule: - return fmt.Sprintf( - "ReadSchedule(status=%d, schedule=%s)", - r.ReadSchedule.Status, - r.ReadSchedule.Schedule, - ) + return r.ReadSchedule.String() case SearchSchedules: - return fmt.Sprintf( - "SearchSchedules(status=%d, cursor=%s, schedules=%s)", - r.SearchSchedules.Status, - r.SearchSchedules.Cursor, - r.SearchSchedules.Schedules, - ) + return r.SearchSchedules.String() case CreateSchedule: - return fmt.Sprintf( - "CreateSchedule(status=%d, schedule=%s)", - r.CreateSchedule.Status, - r.CreateSchedule.Schedule, - ) + return r.CreateSchedule.String() case DeleteSchedule: - return fmt.Sprintf( - "DeleteSchedule(status=%d)", - r.DeleteSchedule.Status, - ) + return r.DeleteSchedule.String() // LOCKS case AcquireLock: - return fmt.Sprintf( - "AcquireLock(status=%d, lock=%s)", - r.AcquireLock.Status, - r.AcquireLock.Lock, - ) + return r.AcquireLock.String() case ReleaseLock: - return fmt.Sprintf( - "ReleaseLock(status=%d)", - r.ReleaseLock.Status, - ) + return r.ReleaseLock.String() case HeartbeatLocks: - return fmt.Sprintf( - "HeartbeatLocks(status=%d, locksAffected=%d)", - r.HeartbeatLocks.Status, - r.HeartbeatLocks.LocksAffected, - ) + return r.HeartbeatLocks.String() // TASKS case ClaimTask: - return fmt.Sprintf( - "ClaimTask(status=%d, mesg=%s)", - r.ClaimTask.Status, - r.ClaimTask.Mesg, - ) + return r.ClaimTask.String() case CompleteTask: - return fmt.Sprintf( - "CompleteTask(status=%d)", - r.CompleteTask.Status, - ) + return r.CompleteTask.String() case HeartbeatTasks: - return fmt.Sprintf( - "HeartbeatTasks(status=%d, tasksAffected=%d)", - r.HeartbeatTasks.Status, - r.HeartbeatTasks.TasksAffected, - ) + return r.HeartbeatTasks.String() // ECHO case Echo: - return fmt.Sprintf( - "Echo(data=%s)", - r.Echo.Data, - ) + return r.Echo.String() + default: return "Response" } diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index b80a6728..2c51cead 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -7,6 +7,7 @@ type Metrics struct { AioInFlight *prometheus.GaugeVec AioWorker *prometheus.GaugeVec AioWorkerInFlight *prometheus.GaugeVec + AioConnection *prometheus.GaugeVec ApiTotal *prometheus.CounterVec ApiInFlight *prometheus.GaugeVec CoroutinesTotal *prometheus.CounterVec @@ -31,6 +32,10 @@ func New(reg prometheus.Registerer) *Metrics { Name: "aio_worker_in_flight_submissions", Help: "number of in flight aio submissions", }, []string{"type", "worker"}), + AioConnection: prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Name: "aio_connection", + Help: "number of aio subsystem connections", + }, []string{"type"}), ApiTotal: prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "api_total_requests", Help: "total number of api requests", @@ -58,6 +63,7 @@ func (m *Metrics) Enable(reg prometheus.Registerer) { reg.MustRegister(m.AioInFlight) reg.MustRegister(m.AioWorker) reg.MustRegister(m.AioWorkerInFlight) + reg.MustRegister(m.AioConnection) reg.MustRegister(m.ApiTotal) reg.MustRegister(m.ApiInFlight) reg.MustRegister(m.CoroutinesTotal) @@ -69,6 +75,7 @@ func (m *Metrics) Disable(reg prometheus.Registerer) { reg.Unregister(m.AioInFlight) reg.Unregister(m.AioWorker) reg.Unregister(m.AioWorkerInFlight) + reg.Unregister(m.AioConnection) reg.Unregister(m.ApiTotal) reg.Unregister(m.ApiInFlight) reg.Unregister(m.CoroutinesTotal) diff --git a/internal/util/util.go b/internal/util/util.go index 7a5f903d..0a3530a2 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -6,7 +6,9 @@ import ( "errors" "reflect" "sort" + "strings" "time" + "unicode" "github.com/robfig/cron/v3" "github.com/spf13/viper" @@ -113,3 +115,12 @@ func UnmarshalChain(data []byte, vs ...any) error { return errors.Join(errs...) } + +func RemoveWhitespace(s string) string { + return strings.Map(func(r rune) rune { + if unicode.IsSpace(r) { + return -1 + } + return r + }, s) +} diff --git a/pkg/callback/callback.go b/pkg/callback/callback.go index 3bffafc9..c500d39d 100644 --- a/pkg/callback/callback.go +++ b/pkg/callback/callback.go @@ -3,24 +3,28 @@ package callback import ( "encoding/json" "fmt" + + "github.com/resonatehq/resonate/pkg/message" ) type Callback struct { - Id string `json:"id"` - PromiseId string `json:"promiseId"` - RootPromiseId string `json:"rootPromiseId"` - Timeout int64 `json:"timeout"` - Recv json.RawMessage `json:"recv"` - CreatedOn int64 `json:"createdOn"` + Id string `json:"id"` + PromiseId string `json:"promiseId"` + Recv json.RawMessage `json:"recv,omitempty"` + Mesg *message.Mesg `json:"mesg,omitempty"` + Timeout int64 `json:"timeout"` + CreatedOn int64 `json:"createdOn"` } func (c *Callback) String() string { return fmt.Sprintf( - "Callback(id=%s, promiseId=%s, rootPromiseId=%s, timeout=%d)", + "Callback(id=%s, promiseId=%s, recv=%s, mesg=%v, timeout=%d, createdOn=%d)", c.Id, c.PromiseId, - c.RootPromiseId, + c.Recv, + c.Mesg, c.Timeout, + c.CreatedOn, ) } diff --git a/pkg/callback/record.go b/pkg/callback/record.go deleted file mode 100644 index fcde9f95..00000000 --- a/pkg/callback/record.go +++ /dev/null @@ -1,21 +0,0 @@ -package callback - -type CallbackRecord struct { - Id string - PromiseId string - RootPromiseId string - Timeout int64 - Recv []byte - CreatedOn int64 -} - -func (r *CallbackRecord) Callback() (*Callback, error) { - return &Callback{ - Id: r.Id, - PromiseId: r.PromiseId, - RootPromiseId: r.RootPromiseId, - Timeout: r.Timeout, - Recv: r.Recv, - CreatedOn: r.CreatedOn, - }, nil -} diff --git a/pkg/message/message.go b/pkg/message/message.go index 71e36dd4..44ecfdc5 100644 --- a/pkg/message/message.go +++ b/pkg/message/message.go @@ -1,38 +1,17 @@ package message import ( - "github.com/resonatehq/resonate/internal/util" - "github.com/resonatehq/resonate/pkg/promise" + "fmt" ) type Mesg struct { - Type Type `json:"type"` - Root string `json:"root,omitempty"` - Leaf string `json:"leaf,omitempty"` - Promises map[string]*promise.Promise `json:"promises,omitempty"` + Type Type `json:"type"` + Root string `json:"root"` + Leaf string `json:"leaf"` } func (m *Mesg) String() string { - return string(m.Type) -} - -func (m *Mesg) SetPromises(root *promise.Promise, leaf *promise.Promise) { - util.Assert(root == nil || root.Id == m.Root, "root id must match") - util.Assert(leaf == nil || leaf.Id == m.Leaf, "leaf id must match") - - // set promises - m.Promises = map[string]*promise.Promise{} - - // hack, unset root and leaf - m.Root = "" - m.Leaf = "" - - if root != nil { - m.Promises["root"] = root - } - if leaf != nil { - m.Promises["leaf"] = leaf - } + return fmt.Sprintf("Mesg(type=%s, root=%s, leaf=%s)", m.Type, m.Root, m.Leaf) } type Type string diff --git a/pkg/promise/promise.go b/pkg/promise/promise.go index 46af3c65..35582869 100644 --- a/pkg/promise/promise.go +++ b/pkg/promise/promise.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" + "github.com/resonatehq/resonate/internal/util" "github.com/resonatehq/resonate/pkg/idempotency" ) @@ -16,15 +17,15 @@ type Promise struct { Timeout int64 `json:"timeout"` IdempotencyKeyForCreate *idempotency.Key `json:"idempotencyKeyForCreate,omitempty"` IdempotencyKeyForComplete *idempotency.Key `json:"idempotencyKeyForComplete,omitempty"` + Tags map[string]string `json:"tags,omitempty"` CreatedOn *int64 `json:"createdOn,omitempty"` CompletedOn *int64 `json:"completedOn,omitempty"` - Tags map[string]string `json:"tags,omitempty"` SortId int64 `json:"-"` // unexported } func (p *Promise) String() string { return fmt.Sprintf( - "Promise(id=%s, state=%s, param=%s, value=%s, timeout=%d, idempotencyKeyForCreate=%s, idempotencyKeyForUpdate=%s, tags=%s)", + "Promise(id=%s, state=%s, param=%s, value=%s, timeout=%d, idempotencyKeyForCreate=%s, idempotencyKeyForUpdate=%s, tags=%s, createdOn=%d, completedOn=%d)", p.Id, p.State, p.Param, @@ -33,6 +34,8 @@ func (p *Promise) String() string { p.IdempotencyKeyForCreate, p.IdempotencyKeyForComplete, p.Tags, + util.SafeDeref(p.CreatedOn), + util.SafeDeref(p.CompletedOn), ) } @@ -119,9 +122,5 @@ type Value struct { } func (v Value) String() string { - return fmt.Sprintf( - "Value(headers=%s, data=%s)", - v.Headers, - string(v.Data), - ) + return fmt.Sprintf("Value(headers=%s, data=%s)", v.Headers, v.Data) } diff --git a/pkg/receiver/recv.go b/pkg/receiver/recv.go index 516de309..92f6730f 100644 --- a/pkg/receiver/recv.go +++ b/pkg/receiver/recv.go @@ -6,7 +6,3 @@ type Recv struct { Type string `json:"type"` Data json.RawMessage `json:"data"` // preserve byte array, unmarshal later in plugin } - -func (r *Recv) String() string { - return r.Type -} diff --git a/pkg/schedule/schedule.go b/pkg/schedule/schedule.go index 9ca8c0e7..3372e59b 100644 --- a/pkg/schedule/schedule.go +++ b/pkg/schedule/schedule.go @@ -26,7 +26,7 @@ type Schedule struct { func (s *Schedule) String() string { return fmt.Sprintf( - "Schedule(id=%s, description=%s, cron=%s, tags=%s, promiseId=%s, promiseTimeout=%d, promiseParam=%s, promiseTags=%s, lastRunTime=%d, nextRunTime=%d, idempotencyKey=%s, createdOn=%d)", + "Schedule(id=%s, desc=%s, cron=%s, tags=%s, promiseId=%s, promiseTimeout=%d, promiseParam=%s, promiseTags=%s, lastRunTime=%d, nextRunTime=%d, idempotencyKey=%s, createdOn=%d)", s.Id, s.Description, s.Cron, diff --git a/pkg/task/task.go b/pkg/task/task.go index 965ef7ec..46c80c30 100644 --- a/pkg/task/task.go +++ b/pkg/task/task.go @@ -10,30 +10,34 @@ import ( type Task struct { Id string `json:"id"` - ProcessId *string `json:"processId"` - State State `json:"state"` - Recv json.RawMessage `json:"recv"` - Mesg *message.Mesg `json:"mesg"` - Timeout int64 `json:"timeout"` Counter int `json:"counter"` - Attempt int `json:"attempt"` - Frequency int `json:"frequency"` - Expiration int64 `json:"expiration"` - CreatedOn *int64 `json:"createdOn"` - CompletedOn *int64 `json:"completedOn"` + Timeout int64 `json:"timeout"` + ProcessId *string `json:"processId,omitempty"` + State State `json:"-"` + Recv json.RawMessage `json:"-"` + Mesg *message.Mesg `json:"-"` + Attempt int `json:"-"` + Frequency int `json:"-"` + Expiration int64 `json:"-"` + CreatedOn *int64 `json:"createdOn,omitempty"` + CompletedOn *int64 `json:"completedOn,omitempty"` } func (t *Task) String() string { return fmt.Sprintf( - "Task(id=%s, processId=%s, state=%s, timeout=%d, counter=%d, attempt=%d, frequency=%d, expiration=%d)", + "Task(id=%s, processId=%s, state=%s, recv=%s, mesg=%v, timeout=%d, counter=%d, attempt=%d, frequency=%d, expiration=%d, createdOn=%d, completedOn=%d)", t.Id, util.SafeDeref(t.ProcessId), t.State, + t.Recv, + t.Mesg, t.Timeout, t.Counter, t.Attempt, t.Frequency, t.Expiration, + util.SafeDeref(t.CreatedOn), + util.SafeDeref(t.CompletedOn), ) } diff --git a/test/dst/dst.go b/test/dst/dst.go index b85f672c..2bf429ce 100644 --- a/test/dst/dst.go +++ b/test/dst/dst.go @@ -37,7 +37,6 @@ type Config struct { Headers int Data int Tags int - Searches int FaultInjection bool Backchannel chan interface{} } @@ -87,6 +86,8 @@ func (d *DST) Run(r *rand.Rand, api api.API, aio aio.AIO, system *system.System) d.Add(t_api.ReadPromise, d.generator.GenerateReadPromise, d.validator.ValidateReadPromise) d.Add(t_api.SearchPromises, d.generator.GenerateSearchPromises, d.validator.ValidateSearchPromises) d.Add(t_api.CreatePromise, d.generator.GenerateCreatePromise, d.validator.ValidateCreatePromise) + d.Add(t_api.CreatePromiseAndTask, d.generator.GenerateCreatePromiseAndTask, d.validator.ValidateCreatePromiseAndTask) + d.Add(t_api.CreatePromiseAndCallback, d.generator.GenerateCreatePromiseAndCallback, d.validator.ValidateCreatePromiseAndCallback) d.Add(t_api.CompletePromise, d.generator.GenerateCompletePromise, d.validator.ValidateCompletePromise) // callbacks @@ -166,6 +167,48 @@ func (d *DST) Run(r *rand.Rand, api api.API, aio aio.AIO, system *system.System) Output: &Res{Op, resTime, res, err}, }) + // Warning: + // A CreatePromiseAndTask request applies to two partitions, the + // promise partition and the task partition. Merging the + // partitions results in long checking time, so as a workaround + // we create an independent CreatePromise request. The mapping + // of requests to partitions is as follows: + // CreatePromise -> p partition + // CreatePromiseAndTask -> t partition + // + // Note: + // A similar approach is not needed for CreatePromiseAndCallback + // because callbacks and promises are part of the same + // partition. + if req.Kind == t_api.CreatePromiseAndTask { + j++ + + req = &t_api.Request{ + Kind: t_api.CreatePromise, + Tags: req.Tags, + CreatePromise: req.CreatePromiseAndTask.Promise, + } + + if res != nil { + res = &t_api.Response{ + Kind: t_api.CreatePromise, + Tags: res.Tags, + CreatePromise: &t_api.CreatePromiseResponse{ + Status: res.CreatePromiseAndTask.Status, + Promise: res.CreatePromiseAndTask.Promise, + }, + } + } + + ops = append(ops, porcupine.Operation{ + ClientId: int(j % d.config.MaxReqsPerTick), + Call: reqTime, + Return: resTime, + Input: &Req{Op, reqTime, req, nil}, + Output: &Res{Op, resTime, res, err}, + }) + } + j++ }, }) @@ -195,8 +238,8 @@ func (d *DST) Run(r *rand.Rand, api api.API, aio aio.AIO, system *system.System) Kind: t_api.ClaimTask, ClaimTask: &t_api.ClaimTaskRequest{ Id: obj.Id, - ProcessId: obj.Id, Counter: counter, + ProcessId: obj.Id, Frequency: RangeIntn(r, 1000, 5000), }, }) @@ -272,13 +315,13 @@ func (d *DST) Model() porcupine.Model { switch req.kind { case Op: switch req.req.Kind { - case t_api.ReadPromise, t_api.SearchPromises, t_api.CreatePromise, t_api.CompletePromise, t_api.CreateCallback: + case t_api.ReadPromise, t_api.SearchPromises, t_api.CreatePromise, t_api.CreatePromiseAndCallback, t_api.CompletePromise, t_api.CreateCallback: p = append(p, op) case t_api.ReadSchedule, t_api.SearchSchedules, t_api.CreateSchedule, t_api.DeleteSchedule: s = append(s, op) case t_api.AcquireLock, t_api.ReleaseLock, t_api.HeartbeatLocks: l = append(l, op) - case t_api.ClaimTask, t_api.CompleteTask, t_api.HeartbeatTasks: + case t_api.ClaimTask, t_api.CompleteTask, t_api.HeartbeatTasks, t_api.CreatePromiseAndTask: t = append(t, op) default: panic(fmt.Sprintf("unknown request kind: %s", req.req.Kind)) @@ -580,13 +623,12 @@ func (d *DST) Time(t int64) int64 { func (d *DST) String() string { return fmt.Sprintf( - "DST(ids=%d, idempotencyKeys=%d, headers=%d, data=%d, tags=%d, searches=%d, backchannel=%d)", + "DST(ids=%d, idempotencyKeys=%d, headers=%d, data=%d, tags=%d, backchannel=%d)", d.config.Ids, d.config.IdempotencyKeys, d.config.Headers, d.config.Data, d.config.Tags, - d.config.Searches, cap(d.config.Backchannel), ) } diff --git a/test/dst/dst_test.go b/test/dst/dst_test.go index 08413bb5..78bcd24b 100644 --- a/test/dst/dst_test.go +++ b/test/dst/dst_test.go @@ -78,6 +78,9 @@ func dst(t *testing.T, p float64, l bool, vp string) { system.AddOnRequest(t_api.ReadPromise, coroutines.ReadPromise) system.AddOnRequest(t_api.SearchPromises, coroutines.SearchPromises) system.AddOnRequest(t_api.CreatePromise, coroutines.CreatePromise) + system.AddOnRequest(t_api.CreatePromiseAndTask, coroutines.CreatePromiseAndTask) + system.AddOnRequest(t_api.CreatePromiseAndCallback, coroutines.CreatePromiseAndCallback) + system.AddOnRequest(t_api.CompletePromise, coroutines.CompletePromise) system.AddOnRequest(t_api.CompletePromise, coroutines.CompletePromise) system.AddOnRequest(t_api.CreateCallback, coroutines.CreateCallback) system.AddOnRequest(t_api.ReadSchedule, coroutines.ReadSchedule) @@ -125,7 +128,6 @@ func dst(t *testing.T, p float64, l bool, vp string) { Headers: 10, Data: 10, Tags: 10, - Searches: 10, FaultInjection: p != 0, Backchannel: backchannel, }) diff --git a/test/dst/generator.go b/test/dst/generator.go index 82977dd6..57169ca7 100644 --- a/test/dst/generator.go +++ b/test/dst/generator.go @@ -20,7 +20,6 @@ type Generator struct { headersSet []map[string]string dataSet [][]byte tagsSet []map[string]string - searchSet []string callback uint64 requests map[t_api.Kind][]*t_api.Request generators []RequestGenerator @@ -68,18 +67,12 @@ func NewGenerator(r *rand.Rand, config *Config) *Generator { } if r.Intn(2) == 0 { - tags["resonate:invoke"] = "default" // create a task + tags["resonate:invoke"] = "dst" // create a task } tagsSet = append(tagsSet, tags, nil) // half of all tags are nil } - searchSet := make([]string, config.Searches*2) - for i := 0; i < config.Searches*2; i = i + 2 { - searchSet[i+0] = fmt.Sprintf("*%d", i) - searchSet[i+1] = fmt.Sprintf("%d*", i) - } - return &Generator{ ticks: config.Ticks, timeElapsedPerTick: config.TimeElapsedPerTick, @@ -89,7 +82,6 @@ func NewGenerator(r *rand.Rand, config *Config) *Generator { headersSet: headersSet, dataSet: dataSet, tagsSet: tagsSet, - searchSet: searchSet, requests: map[t_api.Kind][]*t_api.Request{}, generators: []RequestGenerator{}, } @@ -121,7 +113,7 @@ func (g *Generator) Generate(r *rand.Rand, t int64, n int) []*t_api.Request { // PROMISES func (g *Generator) GenerateReadPromise(r *rand.Rand, t int64) *t_api.Request { - id := g.idSet[r.Intn(len(g.idSet))] + id := g.promiseId(r) return &t_api.Request{ Kind: t_api.ReadPromise, @@ -137,7 +129,7 @@ func (g *Generator) GenerateSearchPromises(r *rand.Rand, t int64) *t_api.Request return req } - id := g.searchSet[r.Intn(len(g.searchSet))] + id := g.promiseSearch(r) limit := RangeIntn(r, 1, 11) tags := g.tagsSet[r.Intn(len(g.tagsSet))] states := []promise.State{} @@ -170,50 +162,78 @@ func (g *Generator) GenerateSearchPromises(r *rand.Rand, t int64) *t_api.Request } func (g *Generator) GenerateCreatePromise(r *rand.Rand, t int64) *t_api.Request { - id := g.idSet[r.Intn(len(g.idSet))] - + id := g.promiseId(r) idempotencyKey := g.idemotencyKeySet[r.Intn(len(g.idemotencyKeySet))] - data := g.dataSet[r.Intn(len(g.dataSet))] + strict := r.Intn(2) == 0 headers := g.headersSet[r.Intn(len(g.headersSet))] - tags := g.tagsSet[r.Intn(len(g.tagsSet))] + data := g.dataSet[r.Intn(len(g.dataSet))] timeout := RangeInt63n(r, t, t+(g.timeoutTicks*g.timeElapsedPerTick)) - strict := r.Intn(2) == 0 + tags := g.tagsSet[r.Intn(len(g.tagsSet))] return &t_api.Request{ Kind: t_api.CreatePromise, CreatePromise: &t_api.CreatePromiseRequest{ - Id: id, - Param: promise.Value{ - Headers: headers, - Data: data, - }, - Timeout: timeout, + Id: id, IdempotencyKey: idempotencyKey, - Tags: tags, Strict: strict, + Param: promise.Value{Headers: headers, Data: data}, + Timeout: timeout, + Tags: tags, + }, + } +} + +func (g *Generator) GenerateCreatePromiseAndTask(r *rand.Rand, t int64) *t_api.Request { + req := g.GenerateCreatePromise(r, t) + + return &t_api.Request{ + Kind: t_api.CreatePromiseAndTask, + CreatePromiseAndTask: &t_api.CreatePromiseAndTaskRequest{ + Promise: req.CreatePromise, + Task: &t_api.CreateTaskRequest{ + PromiseId: req.CreatePromise.Id, + ProcessId: req.CreatePromise.Id, + Frequency: RangeIntn(r, 1000, 5000), + Timeout: req.CreatePromise.Timeout, + Recv: []byte(`"dst"`), + }, + }, + } +} + +func (g *Generator) GenerateCreatePromiseAndCallback(r *rand.Rand, t int64) *t_api.Request { + req := g.GenerateCreatePromise(r, t) + + return &t_api.Request{ + Kind: t_api.CreatePromiseAndCallback, + CreatePromiseAndCallback: &t_api.CreatePromiseAndCallbackRequest{ + Promise: req.CreatePromise, + Callback: &t_api.CreateCallbackRequest{ + PromiseId: req.CreatePromise.Id, + RootPromiseId: g.promiseId(r), + Timeout: RangeInt63n(r, t, g.ticks*g.timeElapsedPerTick), + Recv: []byte(`"dst"`), + }, }, } } func (g *Generator) GenerateCompletePromise(r *rand.Rand, t int64) *t_api.Request { - id := g.idSet[r.Intn(len(g.idSet))] + id := g.promiseId(r) idempotencyKey := g.idemotencyKeySet[r.Intn(len(g.idemotencyKeySet))] - data := g.dataSet[r.Intn(len(g.dataSet))] - headers := g.headersSet[r.Intn(len(g.headersSet))] strict := r.Intn(2) == 0 state := promise.State(math.Exp2(float64(r.Intn(3) + 1))) + headers := g.headersSet[r.Intn(len(g.headersSet))] + data := g.dataSet[r.Intn(len(g.dataSet))] return &t_api.Request{ Kind: t_api.CompletePromise, CompletePromise: &t_api.CompletePromiseRequest{ - Id: id, - State: state, - Value: promise.Value{ - Headers: headers, - Data: data, - }, + Id: id, IdempotencyKey: idempotencyKey, Strict: strict, + State: state, + Value: promise.Value{Headers: headers, Data: data}, }, } } @@ -221,20 +241,18 @@ func (g *Generator) GenerateCompletePromise(r *rand.Rand, t int64) *t_api.Reques // CALLBACKS func (g *Generator) GenerateCreateCallback(r *rand.Rand, t int64) *t_api.Request { - promiseId := g.idSet[r.Intn(len(g.idSet))] - rootPromiseId := g.idSet[r.Intn(len(g.idSet))] + promiseId := g.promiseId(r) + rootPromiseId := g.promiseId(r) timeout := RangeInt63n(r, t, g.ticks*g.timeElapsedPerTick) g.callback++ - // Note: recv is ignored in dst so we do not include a value in the - // create callback request - return &t_api.Request{ Kind: t_api.CreateCallback, CreateCallback: &t_api.CreateCallbackRequest{ PromiseId: promiseId, RootPromiseId: rootPromiseId, Timeout: timeout, + Recv: []byte(`"dst"`), // ignored in dst, use hardcoded value }, } } @@ -242,7 +260,7 @@ func (g *Generator) GenerateCreateCallback(r *rand.Rand, t int64) *t_api.Request // SCHEDULES func (g *Generator) GenerateReadSchedule(r *rand.Rand, t int64) *t_api.Request { - id := g.idSet[r.Intn(len(g.idSet))] + id := g.scheduleId(r) return &t_api.Request{ Kind: t_api.ReadSchedule, @@ -258,7 +276,7 @@ func (g *Generator) GenerateSearchSchedules(r *rand.Rand, t int64) *t_api.Reques return req } - id := g.searchSet[r.Intn(len(g.searchSet))] + id := g.scheduleSearch(r) limit := RangeIntn(r, 1, 11) tags := g.tagsSet[r.Intn(len(g.tagsSet))] @@ -273,7 +291,7 @@ func (g *Generator) GenerateSearchSchedules(r *rand.Rand, t int64) *t_api.Reques } func (g *Generator) GenerateCreateSchedule(r *rand.Rand, t int64) *t_api.Request { - id := g.idSet[r.Intn(len(g.idSet))] + id := g.scheduleId(r) cron := fmt.Sprintf("%d * * * *", r.Intn(60)) tags := g.tagsSet[r.Intn(len(g.tagsSet))] idempotencyKey := g.idemotencyKeySet[r.Intn(len(g.idemotencyKeySet))] @@ -300,7 +318,7 @@ func (g *Generator) GenerateCreateSchedule(r *rand.Rand, t int64) *t_api.Request } func (g *Generator) GenerateDeleteSchedule(r *rand.Rand, t int64) *t_api.Request { - id := g.idSet[r.Intn(len(g.idSet))] + id := g.scheduleId(r) return &t_api.Request{ Kind: t_api.DeleteSchedule, @@ -375,6 +393,31 @@ func (g *Generator) GenerateHeartbeatTasks(r *rand.Rand, t int64) *t_api.Request // Helpers +func (g *Generator) promiseId(r *rand.Rand) string { + return "p" + g.idSet[r.Intn(len(g.idSet))] +} + +func (g *Generator) scheduleId(r *rand.Rand) string { + return "s" + g.idSet[r.Intn(len(g.idSet))] +} + +func (g *Generator) promiseSearch(r *rand.Rand) string { + return "p" + g.search(r) +} + +func (g *Generator) scheduleSearch(r *rand.Rand) string { + return "s" + g.search(r) +} + +func (g *Generator) search(r *rand.Rand) string { + switch r.Intn(2) { + case 0: + return fmt.Sprintf("*%d", r.Intn(10)) + default: + return fmt.Sprintf("%d*", r.Intn(10)) + } +} + func (g *Generator) pop(r *rand.Rand, kind t_api.Kind) *t_api.Request { reqs := g.requests[kind] diff --git a/test/dst/validator.go b/test/dst/validator.go index a4f8d863..4cb3cd82 100644 --- a/test/dst/validator.go +++ b/test/dst/validator.go @@ -19,10 +19,12 @@ type Validator struct { type ResponseValidator func(*Model, int64, int64, *t_api.Request, *t_api.Response) (*Model, error) func NewValidator(r *rand.Rand, config *Config) *Validator { - regexes := make(map[string]*regexp.Regexp, config.Searches*2) - for i := 0; i < config.Searches*2; i = i + 2 { - regexes[fmt.Sprintf("*%d", i)] = regexp.MustCompile(fmt.Sprintf("^.*%d$", i)) - regexes[fmt.Sprintf("%d*", i)] = regexp.MustCompile(fmt.Sprintf("^%d.*$", i)) + regexes := map[string]*regexp.Regexp{} + for i := 0; i < 10; i++ { + regexes[fmt.Sprintf("p*%d", i)] = regexp.MustCompile(fmt.Sprintf("^p.*%d$", i)) + regexes[fmt.Sprintf("p%d*", i)] = regexp.MustCompile(fmt.Sprintf("^p%d.*$", i)) + regexes[fmt.Sprintf("s*%d", i)] = regexp.MustCompile(fmt.Sprintf("^s.*%d$", i)) + regexes[fmt.Sprintf("s%d*", i)] = regexp.MustCompile(fmt.Sprintf("^s%d.*$", i)) } return &Validator{ @@ -121,47 +123,96 @@ func (v *Validator) ValidateSearchPromises(model *Model, reqTime int64, resTime } func (v *Validator) ValidateCreatePromise(model *Model, reqTime int64, resTime int64, req *t_api.Request, res *t_api.Response) (*Model, error) { - p := model.promises.get(req.CreatePromise.Id) + return v.validateCreatePromise(model, reqTime, resTime, req.CreatePromise, res.CreatePromise) +} + +func (v *Validator) ValidateCreatePromiseAndTask(model *Model, reqTime int64, resTime int64, req *t_api.Request, res *t_api.Response) (*Model, error) { + // Do NOT validate the create promise, as a workaround we create a + // "duplicate" CreatePromise request and map the requests as + // follows: + // CreatePromise -> p partition + // CreatePromiseAndTask -> t partition - switch res.CreatePromise.Status { + switch res.CreatePromiseAndTask.Status { + case t_api.StatusCreated: + if model.tasks.get(res.CreatePromiseAndTask.Task.Id) != nil { + return model, fmt.Errorf("task '%s' exists", res.CreatePromiseAndTask.Task.Id) + } + + model = model.Copy() + model.tasks.set(res.CreatePromiseAndTask.Task.Id, res.CreatePromiseAndTask.Task) + } + + return model, nil +} + +func (v *Validator) ValidateCreatePromiseAndCallback(model *Model, reqTime int64, resTime int64, req *t_api.Request, res *t_api.Response) (*Model, error) { + // first validate the create promise + model, err := v.validateCreatePromise(model, reqTime, resTime, req.CreatePromiseAndCallback.Promise, &t_api.CreatePromiseResponse{ + Status: res.CreatePromiseAndCallback.Status, + Promise: res.CreatePromiseAndCallback.Promise, + }) + if err != nil { + return model, err + } + + // now validate the callback + switch res.CreatePromiseAndCallback.Status { + case t_api.StatusCreated: + if model.callbacks.get(res.CreatePromiseAndCallback.Callback.Id) != nil { + return model, fmt.Errorf("callback '%s' exists", res.CreatePromiseAndCallback.Callback.Id) + } + + // model has already been copied + model.callbacks.set(res.CreatePromiseAndCallback.Callback.Id, res.CreatePromiseAndCallback.Callback) + } + + return model, nil +} + +func (v *Validator) validateCreatePromise(model *Model, reqTime int64, resTime int64, req *t_api.CreatePromiseRequest, res *t_api.CreatePromiseResponse) (*Model, error) { + p := model.promises.get(req.Id) + + switch res.Status { case t_api.StatusCreated: if p != nil { - return model, fmt.Errorf("promise '%s' exists", req.CreatePromise.Id) + return model, fmt.Errorf("promise '%s' exists", req.Id) } - if res.CreatePromise.Promise.State != promise.Pending { - return model, fmt.Errorf("invalid state transition (INIT -> %s) for promise '%s'", res.CreatePromise.Promise.State, req.CreatePromise.Id) + if res.Promise.State != promise.Pending { + return model, fmt.Errorf("invalid state transition (INIT -> %s) for promise '%s'", res.Promise.State, req.Id) } // update model state model = model.Copy() - model.promises.set(req.CreatePromise.Id, res.CreatePromise.Promise) + model.promises.set(req.Id, res.Promise) + return model, nil case t_api.StatusOK: if p == nil { - return model, fmt.Errorf("promise '%s' does not exist", req.CreatePromise.Id) + return model, fmt.Errorf("promise '%s' does not exist", req.Id) } - if p.State != res.CreatePromise.Promise.State { + if p.State != res.Promise.State { // the only way this can happen is if the promise timedout - if res.CreatePromise.Promise.State == promise.GetTimedoutState(p) && resTime >= p.Timeout { + if res.Promise.State == promise.GetTimedoutState(p) && resTime >= p.Timeout { model = model.Copy() - model.promises.set(req.CreatePromise.Id, res.CreatePromise.Promise) + model.promises.set(req.Id, res.Promise) } else { - return model, fmt.Errorf("invalid state transition (%s -> %s) for promise '%s'", p.State, res.CreatePromise.Promise.State, req.CreatePromise.Id) + return model, fmt.Errorf("invalid state transition (%s -> %s) for promise '%s'", p.State, res.Promise.State, req.Id) } } - if !p.IdempotencyKeyForCreate.Match(res.CreatePromise.Promise.IdempotencyKeyForCreate) { - return model, fmt.Errorf("ikey mismatch (%s, %s) for promise '%s'", p.IdempotencyKeyForCreate, res.CreatePromise.Promise.IdempotencyKeyForCreate, req.CreatePromise.Id) - } else if req.CreatePromise.Strict && p.State != promise.Pending { - return model, fmt.Errorf("unexpected prior state '%s' when strict true for promise '%s'", p.State, req.CreatePromise.Id) + if !p.IdempotencyKeyForCreate.Match(res.Promise.IdempotencyKeyForCreate) { + return model, fmt.Errorf("ikey mismatch (%s, %s) for promise '%s'", p.IdempotencyKeyForCreate, res.Promise.IdempotencyKeyForCreate, req.Id) + } else if req.Strict && p.State != promise.Pending { + return model, fmt.Errorf("unexpected prior state '%s' when strict true for promise '%s'", p.State, req.Id) } return model, nil case t_api.StatusPromiseAlreadyExists: if p == nil { - return model, fmt.Errorf("promise '%s' does not exist", req.CreatePromise.Id) + return model, fmt.Errorf("promise '%s' does not exist", req.Id) } return model, nil default: - return model, fmt.Errorf("unexpected resonse status '%d'", res.CreatePromise.Status) + return model, fmt.Errorf("unexpected resonse status '%d'", res.Status) } } @@ -487,15 +538,7 @@ func (v *Validator) ValidateClaimTask(model *Model, reqTime int64, resTime int64 } model = model.Copy() - model.tasks.set(req.ClaimTask.Id, &task.Task{ - Id: t.Id, - ProcessId: &req.ClaimTask.ProcessId, - State: task.Claimed, - Timeout: t.Timeout, - Counter: req.ClaimTask.Counter, - Frequency: req.ClaimTask.Frequency, - Expiration: reqTime + int64(req.ClaimTask.Frequency), // approximation - }) + model.tasks.set(req.ClaimTask.Id, res.ClaimTask.Task) return model, nil case t_api.StatusTaskAlreadyClaimed: if t == nil { @@ -547,15 +590,7 @@ func (v *Validator) ValidateCompleteTask(model *Model, reqTime int64, resTime in } model = model.Copy() - model.tasks.set(req.CompleteTask.Id, &task.Task{ - Id: t.Id, - ProcessId: nil, - State: task.Completed, - Timeout: t.Timeout, - Counter: t.Counter, - Frequency: t.Frequency, - Expiration: 0, - }) + model.tasks.set(req.CompleteTask.Id, res.CompleteTask.Task) return model, nil case t_api.StatusTaskAlreadyCompleted: if t == nil { @@ -616,16 +651,9 @@ func (v *Validator) ValidateHeartbeatTasks(model *Model, reqTime int64, resTime } // we can only update the model for tasks that are unambiguously - // heartbeated - model.tasks.set(t.Id, &task.Task{ - Id: t.Id, - ProcessId: t.ProcessId, - State: task.Claimed, - Timeout: t.Timeout, - Counter: t.Counter, - Frequency: t.Frequency, - Expiration: reqTime + int64(t.Frequency), // approximation - }) + // heartbeated, and it's only an approximation + t.Expiration = reqTime + int64(t.Frequency) + model.tasks.set(t.Id, t) } return model, nil