diff --git a/internal/app/coroutines/createPromise.go b/internal/app/coroutines/createPromise.go index 7598366f..ce373131 100644 --- a/internal/app/coroutines/createPromise.go +++ b/internal/app/coroutines/createPromise.go @@ -15,7 +15,7 @@ import ( 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 createPromiseAndTask(c, r, r.CreatePromise) + return createPromiseAndTask(c, r, r.CreatePromise, nil) } func CreatePromiseAndTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r *t_api.Request) (*t_api.Response, error) { @@ -23,18 +23,15 @@ func CreatePromiseAndTask(c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completio 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 createPromiseAndTask(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, - Ttl: r.CreatePromiseAndTask.Task.Ttl, - ExpiresAt: c.Time() + int64(r.CreatePromiseAndTask.Task.Ttl), - CreatedOn: c.Time(), - }, + return createPromiseAndTask(c, r, r.CreatePromiseAndTask.Promise, &t_aio.CreateTaskCommand{ + Recv: nil, + 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, + Ttl: r.CreatePromiseAndTask.Task.Ttl, + ExpiresAt: c.Time() + int64(r.CreatePromiseAndTask.Task.Ttl), + CreatedOn: c.Time(), }) } @@ -42,7 +39,7 @@ func createPromiseAndTask( c gocoro.Coroutine[*t_aio.Submission, *t_aio.Completion, any], r *t_api.Request, createPromiseReq *t_api.CreatePromiseRequest, - additionalCmds ...*t_aio.Command, + taskCmd *t_aio.CreateTaskCommand, ) (*t_api.Response, error) { util.Assert(r.Kind == t_api.CreatePromise || r.Kind == t_api.CreatePromiseAndTask, "must be create promise or variant") @@ -82,7 +79,7 @@ func createPromiseAndTask( util.Assert(result.RowsReturned == 0 || result.RowsReturned == 1, "result must return 0 or 1 rows") if result.RowsReturned == 0 { - cmd := &t_aio.CreatePromiseCommand{ + promiseCmd := &t_aio.CreatePromiseCommand{ Id: createPromiseReq.Id, Param: createPromiseReq.Param, Timeout: createPromiseReq.Timeout, @@ -92,7 +89,7 @@ func createPromiseAndTask( } // if the promise does not exist, create it - completion, err := gocoro.SpawnAndAwait(c, createPromise(r.Tags, cmd, additionalCmds...)) + completion, err := gocoro.SpawnAndAwait(c, createPromise(r.Tags, promiseCmd, taskCmd)) if err != nil { return nil, err } @@ -100,7 +97,7 @@ func createPromiseAndTask( 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 createPromiseAndTask(c, r, createPromiseReq, additionalCmds...) + return createPromiseAndTask(c, r, createPromiseReq, taskCmd) } // set status @@ -108,33 +105,32 @@ func createPromiseAndTask( // set promise p = &promise.Promise{ - Id: cmd.Id, + Id: promiseCmd.Id, State: promise.Pending, - Param: cmd.Param, - Timeout: cmd.Timeout, - IdempotencyKeyForCreate: cmd.IdempotencyKey, - Tags: cmd.Tags, - CreatedOn: &cmd.CreatedOn, + Param: promiseCmd.Param, + Timeout: promiseCmd.Timeout, + IdempotencyKeyForCreate: promiseCmd.IdempotencyKey, + Tags: promiseCmd.Tags, + CreatedOn: &promiseCmd.CreatedOn, } switch r.Kind { case t_api.CreatePromiseAndTask: - util.Assert(additionalCmds[0].Kind == t_aio.CreateTask, "command must be create task") + util.Assert(taskCmd != nil, "create task cmd must not be nil") 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, + ProcessId: taskCmd.ProcessId, + State: taskCmd.State, + Recv: taskCmd.Recv, + Mesg: taskCmd.Mesg, + Timeout: taskCmd.Timeout, Counter: 1, Attempt: 0, - Ttl: cmd.Ttl, - ExpiresAt: cmd.ExpiresAt, - CreatedOn: &cmd.CreatedOn, + Ttl: taskCmd.Ttl, + ExpiresAt: taskCmd.ExpiresAt, + CreatedOn: &taskCmd.CreatedOn, } } } else { @@ -161,7 +157,7 @@ func createPromiseAndTask( 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 createPromiseAndTask(c, r, createPromiseReq, additionalCmds...) + return createPromiseAndTask(c, r, createPromiseReq, taskCmd) } // set status to ok if not strict and idempotency keys match @@ -196,64 +192,77 @@ func createPromiseAndTask( 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, *t_aio.Completion] { - if cmd.Param.Headers == nil { - cmd.Param.Headers = map[string]string{} +func createPromise(tags map[string]string, promiseCmd *t_aio.CreatePromiseCommand, taskCmd *t_aio.CreateTaskCommand, additionalCmds ...*t_aio.Command) gocoro.CoroutineFunc[*t_aio.Submission, *t_aio.Completion, *t_aio.Completion] { + if promiseCmd.Param.Headers == nil { + promiseCmd.Param.Headers = map[string]string{} } - if cmd.Param.Data == nil { - cmd.Param.Data = []byte{} + if promiseCmd.Param.Data == nil { + promiseCmd.Param.Data = []byte{} } - if cmd.Tags == nil { - cmd.Tags = map[string]string{} + if promiseCmd.Tags == nil { + promiseCmd.Tags = map[string]string{} } 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, - CreatePromise: cmd, + CreatePromise: promiseCmd, }} - // add additional commands - commands = append(commands, additionalCmds...) - // 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, Router: &t_aio.RouterSubmission{ Promise: &promise.Promise{ - Id: cmd.Id, + Id: promiseCmd.Id, State: promise.Pending, - Param: cmd.Param, - Timeout: cmd.Timeout, - IdempotencyKeyForCreate: cmd.IdempotencyKey, - Tags: cmd.Tags, - CreatedOn: &cmd.CreatedOn, + Param: promiseCmd.Param, + Timeout: promiseCmd.Timeout, + IdempotencyKeyForCreate: promiseCmd.IdempotencyKey, + Tags: promiseCmd.Tags, + CreatedOn: &promiseCmd.CreatedOn, }, }, }) if err != nil { - slog.Warn("failed to match promise", "cmd", cmd, "err", err) + slog.Warn("failed to match promise", "cmd", promiseCmd, "err", err) + } + + if taskCmd != nil && (err != nil || !completion.Router.Matched) { + slog.Error("failed to match promise when creating a task", "cmd", promiseCmd, "taskCmd", taskCmd) + return nil, t_api.NewError(t_api.StatusPromiseRecvNotFound, err) } if err == nil && completion.Router.Matched { 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: &t_aio.CreateTaskCommand{ + // If there is a taskCmd just update the Recv otherwise create a tasks for the match + if taskCmd != nil { + taskCmd.Recv = completion.Router.Recv + } else { + taskCmd = &t_aio.CreateTaskCommand{ Recv: completion.Router.Recv, - Mesg: &message.Mesg{Type: message.Invoke, Root: cmd.Id, Leaf: cmd.Id}, - Timeout: cmd.Timeout, + Mesg: &message.Mesg{Type: message.Invoke, Root: promiseCmd.Id, Leaf: promiseCmd.Id}, + Timeout: promiseCmd.Timeout, State: task.Init, - CreatedOn: cmd.CreatedOn, - }, + CreatedOn: promiseCmd.CreatedOn, + } + + } + + // add create task command if matched + commands = append(commands, &t_aio.Command{ + Kind: t_aio.CreateTask, + CreateTask: taskCmd, }) } + // add additional commands + commands = append(commands, additionalCmds...) + // yield commands completion, err = gocoro.YieldAndAwait(c, &t_aio.Submission{ Kind: t_aio.Store, diff --git a/internal/app/coroutines/schedulePromises.go b/internal/app/coroutines/schedulePromises.go index 6be5ed83..3ee86c83 100644 --- a/internal/app/coroutines/schedulePromises.go +++ b/internal/app/coroutines/schedulePromises.go @@ -86,7 +86,7 @@ func SchedulePromises(config *system.Config, tags map[string]string) gocoro.Coro CreatedOn: c.Time(), } - awaiting[i] = gocoro.Spawn(c, createPromise(tags, commands[i], &t_aio.Command{ + awaiting[i] = gocoro.Spawn(c, createPromise(tags, commands[i], nil, &t_aio.Command{ Kind: t_aio.UpdateSchedule, UpdateSchedule: &t_aio.UpdateScheduleCommand{ Id: s.Id, diff --git a/internal/app/subsystems/api/grpc/pb/promise.pb.go b/internal/app/subsystems/api/grpc/pb/promise.pb.go index e1cb8f5e..1b19b61b 100644 --- a/internal/app/subsystems/api/grpc/pb/promise.pb.go +++ b/internal/app/subsystems/api/grpc/pb/promise.pb.go @@ -514,7 +514,6 @@ type CreatePromiseTaskRequest struct { ProcessId string `protobuf:"bytes,1,opt,name=processId,proto3" json:"processId,omitempty"` Ttl int32 `protobuf:"varint,2,opt,name=ttl,proto3" json:"ttl,omitempty"` - Recv *Recv `protobuf:"bytes,3,opt,name=recv,proto3" json:"recv,omitempty"` } func (x *CreatePromiseTaskRequest) Reset() { @@ -561,13 +560,6 @@ func (x *CreatePromiseTaskRequest) GetTtl() int32 { return 0 } -func (x *CreatePromiseTaskRequest) GetRecv() *Recv { - if x != nil { - return x.Recv - } - return nil -} - type CreatePromiseAndTaskResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1091,54 +1083,35 @@ var file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDesc = []byte{ 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, 0x70, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, + 0x04, 0x74, 0x61, 0x73, 0x6b, 0x22, 0x4a, 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, 0x10, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x74, - 0x6c, 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, 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, + 0x6c, 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, 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, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 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, @@ -1149,61 +1122,77 @@ var file_internal_app_subsystems_api_grpc_pb_promise_proto_rawDesc = []byte{ 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, + 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, 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, 0xdd, 0x04, 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, + 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, 0xdd, 0x04, 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, 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, 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, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x41, 0x6e, 0x64, 0x54, 0x61, 0x73, 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 ( @@ -1241,7 +1230,6 @@ var file_internal_app_subsystems_api_grpc_pb_promise_proto_goTypes = []any{ nil, // 17: promise.CreatePromiseRequest.TagsEntry (*Promise)(nil), // 18: promise_t.Promise (*Value)(nil), // 19: promise_t.Value - (*Recv)(nil), // 20: callback_t.Recv } var file_internal_app_subsystems_api_grpc_pb_promise_proto_depIdxs = []int32{ 18, // 0: promise.ReadPromiseResponse.promise:type_name -> promise_t.Promise @@ -1253,33 +1241,32 @@ var file_internal_app_subsystems_api_grpc_pb_promise_proto_depIdxs = []int32{ 18, // 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 - 20, // 9: promise.CreatePromiseTaskRequest.recv:type_name -> callback_t.Recv - 18, // 10: promise.CreatePromiseAndTaskResponse.promise:type_name -> promise_t.Promise - 19, // 11: promise.ResolvePromiseRequest.value:type_name -> promise_t.Value - 18, // 12: promise.ResolvePromiseResponse.promise:type_name -> promise_t.Promise - 19, // 13: promise.RejectPromiseRequest.value:type_name -> promise_t.Value - 18, // 14: promise.RejectPromiseResponse.promise:type_name -> promise_t.Promise - 19, // 15: promise.CancelPromiseRequest.value:type_name -> promise_t.Value - 18, // 16: promise.CancelPromiseResponse.promise:type_name -> promise_t.Promise - 1, // 17: promise.Promises.ReadPromise:input_type -> promise.ReadPromiseRequest - 3, // 18: promise.Promises.SearchPromises:input_type -> promise.SearchPromisesRequest - 5, // 19: promise.Promises.CreatePromise:input_type -> promise.CreatePromiseRequest - 7, // 20: promise.Promises.CreatePromiseAndTask:input_type -> promise.CreatePromiseAndTaskRequest - 10, // 21: promise.Promises.ResolvePromise:input_type -> promise.ResolvePromiseRequest - 12, // 22: promise.Promises.RejectPromise:input_type -> promise.RejectPromiseRequest - 14, // 23: promise.Promises.CancelPromise:input_type -> promise.CancelPromiseRequest - 2, // 24: promise.Promises.ReadPromise:output_type -> promise.ReadPromiseResponse - 4, // 25: promise.Promises.SearchPromises:output_type -> promise.SearchPromisesResponse - 6, // 26: promise.Promises.CreatePromise:output_type -> promise.CreatePromiseResponse - 9, // 27: promise.Promises.CreatePromiseAndTask:output_type -> promise.CreatePromiseAndTaskResponse - 11, // 28: promise.Promises.ResolvePromise:output_type -> promise.ResolvePromiseResponse - 13, // 29: promise.Promises.RejectPromise:output_type -> promise.RejectPromiseResponse - 15, // 30: promise.Promises.CancelPromise:output_type -> promise.CancelPromiseResponse - 24, // [24:31] is the sub-list for method output_type - 17, // [17:24] 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 + 18, // 9: promise.CreatePromiseAndTaskResponse.promise:type_name -> promise_t.Promise + 19, // 10: promise.ResolvePromiseRequest.value:type_name -> promise_t.Value + 18, // 11: promise.ResolvePromiseResponse.promise:type_name -> promise_t.Promise + 19, // 12: promise.RejectPromiseRequest.value:type_name -> promise_t.Value + 18, // 13: promise.RejectPromiseResponse.promise:type_name -> promise_t.Promise + 19, // 14: promise.CancelPromiseRequest.value:type_name -> promise_t.Value + 18, // 15: promise.CancelPromiseResponse.promise:type_name -> promise_t.Promise + 1, // 16: promise.Promises.ReadPromise:input_type -> promise.ReadPromiseRequest + 3, // 17: promise.Promises.SearchPromises:input_type -> promise.SearchPromisesRequest + 5, // 18: promise.Promises.CreatePromise:input_type -> promise.CreatePromiseRequest + 7, // 19: promise.Promises.CreatePromiseAndTask:input_type -> promise.CreatePromiseAndTaskRequest + 10, // 20: promise.Promises.ResolvePromise:input_type -> promise.ResolvePromiseRequest + 12, // 21: promise.Promises.RejectPromise:input_type -> promise.RejectPromiseRequest + 14, // 22: promise.Promises.CancelPromise:input_type -> promise.CancelPromiseRequest + 2, // 23: promise.Promises.ReadPromise:output_type -> promise.ReadPromiseResponse + 4, // 24: promise.Promises.SearchPromises:output_type -> promise.SearchPromisesResponse + 6, // 25: promise.Promises.CreatePromise:output_type -> promise.CreatePromiseResponse + 9, // 26: promise.Promises.CreatePromiseAndTask:output_type -> promise.CreatePromiseAndTaskResponse + 11, // 27: promise.Promises.ResolvePromise:output_type -> promise.ResolvePromiseResponse + 13, // 28: promise.Promises.RejectPromise:output_type -> promise.RejectPromiseResponse + 15, // 29: promise.Promises.CancelPromise:output_type -> promise.CancelPromiseResponse + 23, // [23:30] is the sub-list for method output_type + 16, // [16:23] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_internal_app_subsystems_api_grpc_pb_promise_proto_init() } diff --git a/internal/app/subsystems/api/grpc/pb/promise.proto b/internal/app/subsystems/api/grpc/pb/promise.proto index c67f9d4e..26306bb6 100644 --- a/internal/app/subsystems/api/grpc/pb/promise.proto +++ b/internal/app/subsystems/api/grpc/pb/promise.proto @@ -70,7 +70,6 @@ message CreatePromiseAndTaskRequest { message CreatePromiseTaskRequest { string processId = 1; int32 ttl = 2; - callback_t.Recv recv = 3; } message CreatePromiseAndTaskResponse { diff --git a/internal/app/subsystems/api/grpc/promise.go b/internal/app/subsystems/api/grpc/promise.go index 5b77f653..a04f1964 100644 --- a/internal/app/subsystems/api/grpc/promise.go +++ b/internal/app/subsystems/api/grpc/promise.go @@ -128,11 +128,6 @@ func (s *server) CreatePromiseAndTask(c context.Context, r *pb.CreatePromiseAndT 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{ @@ -149,7 +144,6 @@ func (s *server) CreatePromiseAndTask(c context.Context, r *pb.CreatePromiseAndT ProcessId: r.Task.ProcessId, Ttl: int(r.Task.Ttl), Timeout: r.Promise.Timeout, - Recv: recv, }, }, }) diff --git a/internal/app/subsystems/api/http/promise.go b/internal/app/subsystems/api/http/promise.go index 7dc3df91..fcc20bad 100644 --- a/internal/app/subsystems/api/http/promise.go +++ b/internal/app/subsystems/api/http/promise.go @@ -1,7 +1,6 @@ package http import ( - "encoding/json" "errors" "github.com/resonatehq/resonate/internal/app/subsystems/api" @@ -161,9 +160,8 @@ type createPromiseAndTaskBody struct { } type createPromiseTaskBody struct { - ProcessId string `json:"processId" binding:"required"` - Ttl int `json:"ttl"` - Recv json.RawMessage `json:"recv" binding:"required"` + ProcessId string `json:"processId" binding:"required"` + Ttl int `json:"ttl"` } func (s *server) createPromiseAndTask(c *gin.Context) { @@ -199,7 +197,6 @@ func (s *server) createPromiseAndTask(c *gin.Context) { ProcessId: body.Task.ProcessId, Ttl: body.Task.Ttl, Timeout: body.Promise.Timeout, - Recv: body.Task.Recv, }, }, }) diff --git a/internal/app/subsystems/api/test/cases.go b/internal/app/subsystems/api/test/cases.go index 9e0bdbe9..564c5c0e 100644 --- a/internal/app/subsystems/api/test/cases.go +++ b/internal/app/subsystems/api/test/cases.go @@ -692,13 +692,13 @@ var TestCases = []*testCase{ Promise: &t_api.CreatePromiseRequest{ Id: "foo", Timeout: 1, + Tags: map[string]string{"resonate:invoke": "baz"}, }, Task: &t_api.CreateTaskRequest{ PromiseId: "foo", ProcessId: "bar", Ttl: 2, Timeout: 1, - Recv: []byte(`"baz"`), }, }, }, @@ -723,8 +723,8 @@ var TestCases = []*testCase{ "Request-Id": "CreatePromiseAndTask", }, Body: []byte(`{ - "promise": {"id": "foo", "timeout": 1}, - "task": {"processId": "bar", "ttl": 2, "recv": "baz"} + "promise": {"id": "foo", "timeout": 1, "tags": {"resonate:invoke": "baz"}}, + "task": {"processId": "bar", "ttl": 2} }`), }, Res: &httpTestCaseResponse{ @@ -737,11 +737,11 @@ var TestCases = []*testCase{ Id: "foo", Timeout: 1, RequestId: "CreatePromiseAndTask", + Tags: map[string]string{"resonate:invoke": "baz"}, }, Task: &pb.CreatePromiseTaskRequest{ ProcessId: "bar", Ttl: 2, - Recv: &pb.Recv{Recv: &pb.Recv_Logical{Logical: "baz"}}, }, }, Res: &pb.CreatePromiseAndTaskResponse{ diff --git a/internal/kernel/t_api/request.go b/internal/kernel/t_api/request.go index 8e8ef872..1315ab5a 100644 --- a/internal/kernel/t_api/request.go +++ b/internal/kernel/t_api/request.go @@ -14,11 +14,11 @@ type Request struct { Tags map[string]string // PROMISES - ReadPromise *ReadPromiseRequest - SearchPromises *SearchPromisesRequest - CreatePromise *CreatePromiseRequest - CreatePromiseAndTask *CreatePromiseAndTaskRequest - CompletePromise *CompletePromiseRequest + ReadPromise *ReadPromiseRequest + SearchPromises *SearchPromisesRequest + CreatePromise *CreatePromiseRequest + CreatePromiseAndTask *CreatePromiseAndTaskRequest + CompletePromise *CompletePromiseRequest // CALLBACKS CreateCallback *CreateCallbackRequest @@ -179,7 +179,13 @@ type AcquireLockRequest struct { } func (r *AcquireLockRequest) String() string { - return fmt.Sprintf("AcquireLock(resourceId=%s, executionId=%s, processId=%s, ttl=%d)", r.ResourceId, r.ExecutionId, r.ProcessId, r.Ttl) + return fmt.Sprintf( + "AcquireLock(resourceId=%s, executionId=%s, processId=%s, ttl=%d)", + r.ResourceId, + r.ExecutionId, + r.ProcessId, + r.Ttl, + ) } type ReleaseLockRequest struct { @@ -202,15 +208,20 @@ func (r *HeartbeatLocksRequest) String() string { // Tasks type CreateTaskRequest struct { - PromiseId string `json:"promiseId"` - ProcessId string `json:"processId"` - Ttl int `json:"ttl"` - Timeout int64 `json:"timeout"` - Recv json.RawMessage `json:"recv"` + PromiseId string `json:"promiseId"` + ProcessId string `json:"processId"` + Ttl int `json:"ttl"` + Timeout int64 `json:"timeout"` } func (r *CreateTaskRequest) String() string { - return fmt.Sprintf("CreateTask(promiseId=%s, processId=%s, ttl=%d, timeout=%d, recv=%s)", r.PromiseId, r.ProcessId, r.Ttl, r.Timeout, r.Recv) + return fmt.Sprintf( + "CreateTask(promiseId=%s, processId=%s, ttl=%d, timeout=%d)", + r.PromiseId, + r.ProcessId, + r.Ttl, + r.Timeout, + ) } type ClaimTaskRequest struct { diff --git a/internal/kernel/t_api/status.go b/internal/kernel/t_api/status.go index f934299a..ecee67be 100644 --- a/internal/kernel/t_api/status.go +++ b/internal/kernel/t_api/status.go @@ -27,6 +27,7 @@ const ( StatusScheduleNotFound StatusCode = 4041 StatusLockNotFound StatusCode = 4042 StatusTaskNotFound StatusCode = 4043 + StatusPromiseRecvNotFound StatusCode = 4044 StatusPromiseAlreadyExists StatusCode = 4090 StatusScheduleAlreadyExists StatusCode = 4091 diff --git a/pkg/idempotency/idempotency.go b/pkg/idempotency/idempotency.go index a5d1f6d9..b2e19cd8 100644 --- a/pkg/idempotency/idempotency.go +++ b/pkg/idempotency/idempotency.go @@ -1,5 +1,7 @@ package idempotency +import "strings" + type Key string func (i1 *Key) Match(i2 *Key) bool { @@ -14,3 +16,11 @@ func (i1 *Key) Equals(i2 *Key) bool { func (i *Key) String() string { return string(*i) } + +func (i *Key) Clone() *Key { + if i == nil { + return nil + } + k := Key(strings.Clone(i.String())) + return &k +} diff --git a/test/dst/generator.go b/test/dst/generator.go index b361e9d7..5a550ace 100644 --- a/test/dst/generator.go +++ b/test/dst/generator.go @@ -2,6 +2,7 @@ package dst import ( "fmt" + "maps" "math" "math/rand" // nosemgrep "strconv" @@ -130,7 +131,7 @@ func (g *Generator) GenerateSearchPromises(r *rand.Rand, t int64) *t_api.Request id := g.promiseSearch(r) limit := RangeIntn(r, 1, 11) - tags := g.tagsSet[r.Intn(len(g.tagsSet))] + tags := g.tags(r) states := []promise.State{} // states @@ -162,12 +163,12 @@ 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.promiseId(r) - idempotencyKey := g.idemotencyKeySet[r.Intn(len(g.idemotencyKeySet))] + idempotencyKey := g.idempotencyKey(r) strict := r.Intn(2) == 0 - headers := g.headersSet[r.Intn(len(g.headersSet))] + headers := g.headers(r) data := g.dataSet[r.Intn(len(g.dataSet))] timeout := RangeInt63n(r, t, t+(g.timeoutTicks*g.timeElapsedPerTick)) - tags := g.tagsSet[r.Intn(len(g.tagsSet))] + tags := g.tags(r) return &t_api.Request{ Kind: t_api.CreatePromise, @@ -184,6 +185,11 @@ func (g *Generator) GenerateCreatePromise(r *rand.Rand, t int64) *t_api.Request func (g *Generator) GenerateCreatePromiseAndTask(r *rand.Rand, t int64) *t_api.Request { req := g.GenerateCreatePromise(r, t) + if req.CreatePromise.Tags == nil { + req.CreatePromise.Tags = map[string]string{"resonate:invoke": "dst"} + } else { + req.CreatePromise.Tags["resonate:invoke"] = "dst" + } return &t_api.Request{ Kind: t_api.CreatePromiseAndTask, @@ -194,7 +200,6 @@ func (g *Generator) GenerateCreatePromiseAndTask(r *rand.Rand, t int64) *t_api.R ProcessId: req.CreatePromise.Id, Ttl: RangeIntn(r, 1000, 5000), Timeout: req.CreatePromise.Timeout, - Recv: []byte(`"dst"`), }, }, } @@ -202,10 +207,10 @@ func (g *Generator) GenerateCreatePromiseAndTask(r *rand.Rand, t int64) *t_api.R func (g *Generator) GenerateCompletePromise(r *rand.Rand, t int64) *t_api.Request { id := g.promiseId(r) - idempotencyKey := g.idemotencyKeySet[r.Intn(len(g.idemotencyKeySet))] + idempotencyKey := g.idempotencyKey(r) strict := r.Intn(2) == 0 state := promise.State(math.Exp2(float64(r.Intn(3) + 1))) - headers := g.headersSet[r.Intn(len(g.headersSet))] + headers := g.headers(r) data := g.dataSet[r.Intn(len(g.dataSet))] return &t_api.Request{ @@ -261,7 +266,7 @@ func (g *Generator) GenerateSearchSchedules(r *rand.Rand, t int64) *t_api.Reques id := g.scheduleSearch(r) limit := RangeIntn(r, 1, 11) - tags := g.tagsSet[r.Intn(len(g.tagsSet))] + tags := g.tags(r) return &t_api.Request{ Kind: t_api.SearchSchedules, @@ -276,13 +281,13 @@ 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.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))] + tags := g.tags(r) + idempotencyKey := g.idempotencyKey(r) promiseTimeout := RangeInt63n(r, t, g.ticks*g.timeElapsedPerTick) - promiseHeaders := g.headersSet[r.Intn(len(g.headersSet))] + promiseHeaders := g.headers(r) promiseData := g.dataSet[r.Intn(len(g.dataSet))] - promiseTags := g.tagsSet[r.Intn(len(g.tagsSet))] + promiseTags := g.tags(r) return &t_api.Request{ Kind: t_api.CreateSchedule, @@ -454,3 +459,18 @@ func (g *Generator) nextTasks(r *rand.Rand, id string, pid string, counter int) } } } + +func (g *Generator) tags(r *rand.Rand) map[string]string { + tags := g.tagsSet[r.Intn(len(g.tagsSet))] + return maps.Clone(tags) +} + +func (g *Generator) headers(r *rand.Rand) map[string]string { + headers := g.headersSet[r.Intn(len(g.headersSet))] + return maps.Clone(headers) +} + +func (g *Generator) idempotencyKey(r *rand.Rand) *idempotency.Key { + iKey := g.idemotencyKeySet[r.Intn(len(g.idemotencyKeySet))] + return iKey.Clone() +}