From 16c30a75a74b92c358231d2dbb756c6557c8f5fc Mon Sep 17 00:00:00 2001 From: David Farr Date: Mon, 2 Oct 2023 10:24:35 -0700 Subject: [PATCH] Refactor idempotency key (#74) * Refactor idempotency key param_ikey -> idempotency_key_for_create value_ikey -> idempotency_key_for_complete --- internal/app/coroutines/cancelPromise.go | 40 +- internal/app/coroutines/createPromise.go | 37 +- internal/app/coroutines/readPromise.go | 11 +- internal/app/coroutines/rejectPromise.go | 40 +- internal/app/coroutines/resolvePromise.go | 38 +- internal/app/coroutines/timeoutPromise.go | 1 - .../subsystems/aio/store/postgres/postgres.go | 58 +-- .../app/subsystems/aio/store/sqlite/sqlite.go | 46 +-- .../app/subsystems/aio/store/test/util.go | 260 ++++++------ .../app/subsystems/api/grpc/api/promise.pb.go | 385 ++++++++++-------- .../app/subsystems/api/grpc/api/promise.proto | 15 +- internal/app/subsystems/api/grpc/grpc.go | 66 +-- internal/kernel/types/aio_store.go | 22 +- internal/kernel/types/api_request.go | 48 ++- pkg/promise/promise.go | 35 +- pkg/promise/record.go | 48 +-- test/dst/generator.go | 28 +- test/dst/model.go | 28 +- 18 files changed, 646 insertions(+), 560 deletions(-) diff --git a/internal/app/coroutines/cancelPromise.go b/internal/app/coroutines/cancelPromise.go index 46e720fe..ccb6da80 100644 --- a/internal/app/coroutines/cancelPromise.go +++ b/internal/app/coroutines/cancelPromise.go @@ -81,13 +81,14 @@ func CancelPromise(t int64, req *types.Request, res func(int64, *types.Response, Param: p.Param, Value: promise.Value{ Headers: map[string]string{}, - Ikey: nil, Data: []byte{}, }, - Timeout: p.Timeout, - Tags: p.Tags, - CreatedOn: p.CreatedOn, - CompletedOn: &p.Timeout, + Timeout: p.Timeout, + IdempotencyKeyForCreate: p.IdempotencyKeyForCreate, + IdempotencyKeyForComplete: p.IdempotencyKeyForComplete, + Tags: p.Tags, + CreatedOn: p.CreatedOn, + CompletedOn: &p.Timeout, }, }, }, nil) @@ -101,10 +102,11 @@ func CancelPromise(t int64, req *types.Request, res func(int64, *types.Response, { Kind: types.StoreUpdatePromise, UpdatePromise: &types.UpdatePromiseCommand{ - Id: req.CancelPromise.Id, - State: promise.Canceled, - Value: req.CancelPromise.Value, - CompletedOn: t, + Id: req.CancelPromise.Id, + State: promise.Canceled, + Value: req.CancelPromise.Value, + IdempotencyKey: req.CancelPromise.IdemptencyKey, + CompletedOn: t, }, }, { @@ -143,14 +145,16 @@ func CancelPromise(t int64, req *types.Request, res func(int64, *types.Response, CancelPromise: &types.CancelPromiseResponse{ Status: types.ResponseCreated, Promise: &promise.Promise{ - Id: p.Id, - State: promise.Canceled, - Param: p.Param, - Value: req.CancelPromise.Value, - Timeout: p.Timeout, - Tags: p.Tags, - CreatedOn: p.CreatedOn, - CompletedOn: &t, + Id: p.Id, + State: promise.Canceled, + Param: p.Param, + Value: req.CancelPromise.Value, + Timeout: p.Timeout, + IdempotencyKeyForCreate: p.IdempotencyKeyForCreate, + IdempotencyKeyForComplete: req.CancelPromise.IdemptencyKey, + Tags: p.Tags, + CreatedOn: p.CreatedOn, + CompletedOn: &t, }, }, }, nil) @@ -163,7 +167,7 @@ func CancelPromise(t int64, req *types.Request, res func(int64, *types.Response, status := types.ResponseForbidden strict := req.CancelPromise.Strict && p.State != promise.Canceled - if !strict && p.Value.Ikey.Match(req.CancelPromise.Value.Ikey) { + if !strict && p.IdempotencyKeyForComplete.Match(req.CancelPromise.IdemptencyKey) { status = types.ResponseOK } diff --git a/internal/app/coroutines/createPromise.go b/internal/app/coroutines/createPromise.go index 7d711660..98f8b4eb 100644 --- a/internal/app/coroutines/createPromise.go +++ b/internal/app/coroutines/createPromise.go @@ -59,11 +59,12 @@ func CreatePromise(t int64, req *types.Request, res func(int64, *types.Response, { Kind: types.StoreCreatePromise, CreatePromise: &types.CreatePromiseCommand{ - Id: req.CreatePromise.Id, - Param: req.CreatePromise.Param, - Timeout: req.CreatePromise.Timeout, - Tags: req.CreatePromise.Tags, - CreatedOn: t, + Id: req.CreatePromise.Id, + Param: req.CreatePromise.Param, + Timeout: req.CreatePromise.Timeout, + IdempotencyKey: req.CreatePromise.IdemptencyKey, + Tags: req.CreatePromise.Tags, + CreatedOn: t, }, }, }, @@ -89,12 +90,13 @@ func CreatePromise(t int64, req *types.Request, res func(int64, *types.Response, CreatePromise: &types.CreatePromiseResponse{ Status: types.ResponseCreated, Promise: &promise.Promise{ - Id: req.CreatePromise.Id, - State: promise.Pending, - Param: req.CreatePromise.Param, - Timeout: req.CreatePromise.Timeout, - Tags: req.CreatePromise.Tags, - CreatedOn: &t, + Id: req.CreatePromise.Id, + State: promise.Pending, + Param: req.CreatePromise.Param, + Timeout: req.CreatePromise.Timeout, + IdempotencyKeyForCreate: req.CreatePromise.IdemptencyKey, + Tags: req.CreatePromise.Tags, + CreatedOn: &t, }, }, }, nil) @@ -113,7 +115,7 @@ func CreatePromise(t int64, req *types.Request, res func(int64, *types.Response, status := types.ResponseForbidden strict := req.CreatePromise.Strict && p.State != promise.Pending - if !strict && p.Param.Ikey.Match(req.CreatePromise.Param.Ikey) { + if !strict && p.IdempotencyKeyForCreate.Match(req.CreatePromise.IdemptencyKey) { status = types.ResponseOK } @@ -135,13 +137,14 @@ func CreatePromise(t int64, req *types.Request, res func(int64, *types.Response, Param: p.Param, Value: promise.Value{ Headers: map[string]string{}, - Ikey: nil, Data: []byte{}, }, - Timeout: p.Timeout, - Tags: p.Tags, - CreatedOn: p.CreatedOn, - CompletedOn: &p.Timeout, + Timeout: p.Timeout, + IdempotencyKeyForCreate: p.IdempotencyKeyForCreate, + IdempotencyKeyForComplete: p.IdempotencyKeyForComplete, + Tags: p.Tags, + CreatedOn: p.CreatedOn, + CompletedOn: &p.Timeout, }, }, }, nil) diff --git a/internal/app/coroutines/readPromise.go b/internal/app/coroutines/readPromise.go index 1995dea8..d3be261e 100644 --- a/internal/app/coroutines/readPromise.go +++ b/internal/app/coroutines/readPromise.go @@ -73,13 +73,14 @@ func ReadPromise(t int64, req *types.Request, res func(int64, *types.Response, e Param: p.Param, Value: promise.Value{ Headers: map[string]string{}, - Ikey: nil, Data: nil, }, - Timeout: p.Timeout, - Tags: p.Tags, - CreatedOn: p.CreatedOn, - CompletedOn: &p.Timeout, + Timeout: p.Timeout, + IdempotencyKeyForCreate: p.IdempotencyKeyForCreate, + IdempotencyKeyForComplete: p.IdempotencyKeyForComplete, + Tags: p.Tags, + CreatedOn: p.CreatedOn, + CompletedOn: &p.Timeout, }, }, }, nil) diff --git a/internal/app/coroutines/rejectPromise.go b/internal/app/coroutines/rejectPromise.go index 617bac29..567488f7 100644 --- a/internal/app/coroutines/rejectPromise.go +++ b/internal/app/coroutines/rejectPromise.go @@ -81,13 +81,14 @@ func RejectPromise(t int64, req *types.Request, res func(int64, *types.Response, Param: p.Param, Value: promise.Value{ Headers: map[string]string{}, - Ikey: nil, Data: []byte{}, }, - Timeout: p.Timeout, - Tags: p.Tags, - CreatedOn: p.CreatedOn, - CompletedOn: &p.Timeout, + Timeout: p.Timeout, + IdempotencyKeyForCreate: p.IdempotencyKeyForCreate, + IdempotencyKeyForComplete: p.IdempotencyKeyForComplete, + Tags: p.Tags, + CreatedOn: p.CreatedOn, + CompletedOn: &p.Timeout, }, }, }, nil) @@ -101,10 +102,11 @@ func RejectPromise(t int64, req *types.Request, res func(int64, *types.Response, { Kind: types.StoreUpdatePromise, UpdatePromise: &types.UpdatePromiseCommand{ - Id: req.RejectPromise.Id, - State: promise.Rejected, - Value: req.RejectPromise.Value, - CompletedOn: t, + Id: req.RejectPromise.Id, + State: promise.Rejected, + Value: req.RejectPromise.Value, + IdempotencyKey: req.RejectPromise.IdemptencyKey, + CompletedOn: t, }, }, { @@ -143,14 +145,16 @@ func RejectPromise(t int64, req *types.Request, res func(int64, *types.Response, RejectPromise: &types.RejectPromiseResponse{ Status: types.ResponseCreated, Promise: &promise.Promise{ - Id: p.Id, - State: promise.Rejected, - Param: p.Param, - Value: req.RejectPromise.Value, - Timeout: p.Timeout, - Tags: p.Tags, - CreatedOn: p.CreatedOn, - CompletedOn: &t, + Id: p.Id, + State: promise.Rejected, + Param: p.Param, + Value: req.RejectPromise.Value, + Timeout: p.Timeout, + IdempotencyKeyForCreate: p.IdempotencyKeyForCreate, + IdempotencyKeyForComplete: req.RejectPromise.IdemptencyKey, + Tags: p.Tags, + CreatedOn: p.CreatedOn, + CompletedOn: &t, }, }, }, nil) @@ -163,7 +167,7 @@ func RejectPromise(t int64, req *types.Request, res func(int64, *types.Response, status := types.ResponseForbidden strict := req.RejectPromise.Strict && p.State != promise.Rejected - if !strict && p.Value.Ikey.Match(req.RejectPromise.Value.Ikey) { + if !strict && p.IdempotencyKeyForComplete.Match(req.RejectPromise.IdemptencyKey) { status = types.ResponseOK } diff --git a/internal/app/coroutines/resolvePromise.go b/internal/app/coroutines/resolvePromise.go index 34bd9e54..aa9349bb 100644 --- a/internal/app/coroutines/resolvePromise.go +++ b/internal/app/coroutines/resolvePromise.go @@ -81,13 +81,14 @@ func ResolvePromise(t int64, req *types.Request, res func(int64, *types.Response Param: p.Param, Value: promise.Value{ Headers: map[string]string{}, - Ikey: nil, Data: []byte{}, }, - Timeout: p.Timeout, - Tags: p.Tags, - CreatedOn: p.CreatedOn, - CompletedOn: &p.Timeout, + Timeout: p.Timeout, + IdempotencyKeyForCreate: p.IdempotencyKeyForCreate, + IdempotencyKeyForComplete: p.IdempotencyKeyForComplete, + Tags: p.Tags, + CreatedOn: p.CreatedOn, + CompletedOn: &p.Timeout, }, }, }, nil) @@ -101,10 +102,11 @@ func ResolvePromise(t int64, req *types.Request, res func(int64, *types.Response { Kind: types.StoreUpdatePromise, UpdatePromise: &types.UpdatePromiseCommand{ - Id: req.ResolvePromise.Id, - State: promise.Resolved, - Value: req.ResolvePromise.Value, - CompletedOn: t, + Id: req.ResolvePromise.Id, + State: promise.Resolved, + Value: req.ResolvePromise.Value, + IdempotencyKey: req.ResolvePromise.IdemptencyKey, + CompletedOn: t, }, }, { @@ -143,13 +145,15 @@ func ResolvePromise(t int64, req *types.Request, res func(int64, *types.Response ResolvePromise: &types.ResolvePromiseResponse{ Status: types.ResponseCreated, Promise: &promise.Promise{ - Id: p.Id, - State: promise.Resolved, - Param: p.Param, - Value: req.ResolvePromise.Value, - Timeout: p.Timeout, - CreatedOn: p.CreatedOn, - CompletedOn: &t, + Id: p.Id, + State: promise.Resolved, + Param: p.Param, + Value: req.ResolvePromise.Value, + Timeout: p.Timeout, + IdempotencyKeyForCreate: p.IdempotencyKeyForCreate, + IdempotencyKeyForComplete: req.ResolvePromise.IdemptencyKey, + CreatedOn: p.CreatedOn, + CompletedOn: &t, }, }, }, nil) @@ -162,7 +166,7 @@ func ResolvePromise(t int64, req *types.Request, res func(int64, *types.Response status := types.ResponseForbidden strict := req.ResolvePromise.Strict && p.State != promise.Resolved - if !strict && p.Value.Ikey.Match(req.ResolvePromise.Value.Ikey) { + if !strict && p.IdempotencyKeyForComplete.Match(req.ResolvePromise.IdemptencyKey) { status = types.ResponseOK } diff --git a/internal/app/coroutines/timeoutPromise.go b/internal/app/coroutines/timeoutPromise.go index 96d7cdbf..d43826aa 100644 --- a/internal/app/coroutines/timeoutPromise.go +++ b/internal/app/coroutines/timeoutPromise.go @@ -24,7 +24,6 @@ func TimeoutPromise(t int64, p *promise.Promise, retry *scheduler.Coroutine, res State: promise.Timedout, Value: promise.Value{ Headers: map[string]string{}, - Ikey: nil, Data: []byte{}, }, CompletedOn: p.Timeout, diff --git a/internal/app/subsystems/aio/store/postgres/postgres.go b/internal/app/subsystems/aio/store/postgres/postgres.go index f2130ee3..f52774bf 100644 --- a/internal/app/subsystems/aio/store/postgres/postgres.go +++ b/internal/app/subsystems/aio/store/postgres/postgres.go @@ -26,19 +26,19 @@ import ( const ( CREATE_TABLE_STATEMENT = ` CREATE TABLE IF NOT EXISTS promises ( - id TEXT, - sort_id SERIAL, - state INTEGER DEFAULT 1, - param_headers BYTEA, - param_ikey TEXT, - param_data BYTEA, - value_headers BYTEA, - value_ikey TEXT, - value_data BYTEA, - timeout BIGINT, - tags BYTEA, - created_on BIGINT, - completed_on BIGINT, + id TEXT, + sort_id SERIAL, + state INTEGER DEFAULT 1, + param_headers BYTEA, + param_data BYTEA, + value_headers BYTEA, + value_data BYTEA, + timeout BIGINT, + idempotency_key_for_create TEXT, + idempotency_key_for_complete TEXT, + tags BYTEA, + created_on BIGINT, + completed_on BIGINT, PRIMARY KEY(id) ); @@ -80,7 +80,7 @@ const ( PROMISE_SELECT_STATEMENT = ` SELECT - id, state, param_headers, param_ikey, param_data, value_headers, value_ikey, value_data, timeout, tags, created_on, completed_on + id, state, param_headers, param_data, value_headers, value_data, timeout, idempotency_key_for_create, idempotency_key_for_complete, tags, created_on, completed_on FROM promises WHERE @@ -88,7 +88,7 @@ const ( PROMISE_SEARCH_STATEMENT = ` SELECT - id, state, param_headers, param_ikey, param_data, value_headers, value_ikey, value_data, timeout, tags, created_on, completed_on, sort_id + id, state, param_headers, param_data, value_headers, value_data, timeout, idempotency_key_for_create, idempotency_key_for_complete, tags, created_on, completed_on, sort_id FROM promises WHERE @@ -102,7 +102,7 @@ const ( PROMISE_INSERT_STATEMENT = ` INSERT INTO promises - (id, state, param_headers, param_ikey, param_data, timeout, tags, created_on) + (id, state, param_headers, param_data, timeout, idempotency_key_for_create, tags, created_on) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT(id) DO NOTHING` @@ -111,17 +111,17 @@ const ( UPDATE promises SET - state = $1, value_headers = $2, value_ikey = $3, value_data = $4, completed_on = $5 + state = $1, value_headers = $2, value_data = $3, idempotency_key_for_complete = $4, completed_on = $5 WHERE id = $6 AND state = 1` PROMISE_UPDATE_TIMEOUT_STATEMENT = ` - UPDATE - promises - SET - state = 8, completed_on = timeout - WHERE - state = 1 AND timeout <= $1` + UPDATE + promises + SET + state = 8, completed_on = timeout + WHERE + state = 1 AND timeout <= $1` TIMEOUT_SELECT_STATEMENT = ` SELECT @@ -503,12 +503,12 @@ func (w *PostgresStoreWorker) readPromise(tx *sql.Tx, cmd *types.ReadPromiseComm &record.Id, &record.State, &record.ParamHeaders, - &record.ParamIkey, &record.ParamData, &record.ValueHeaders, - &record.ValueIkey, &record.ValueData, &record.Timeout, + &record.IdempotencyKeyForCreate, + &record.IdempotencyKeyForComplete, &record.Tags, &record.CreatedOn, &record.CompletedOn, @@ -564,12 +564,12 @@ func (w *PostgresStoreWorker) searchPromises(tx *sql.Tx, cmd *types.SearchPromis &record.Id, &record.State, &record.ParamHeaders, - &record.ParamIkey, &record.ParamData, &record.ValueHeaders, - &record.ValueIkey, &record.ValueData, &record.Timeout, + &record.IdempotencyKeyForCreate, + &record.IdempotencyKeyForComplete, &record.Tags, &record.CreatedOn, &record.CompletedOn, @@ -609,7 +609,7 @@ func (w *PostgresStoreWorker) createPromise(tx *sql.Tx, stmt *sql.Stmt, cmd *typ } // insert - res, err := stmt.Exec(cmd.Id, promise.Pending, headers, cmd.Param.Ikey, cmd.Param.Data, cmd.Timeout, tags, cmd.CreatedOn) + res, err := stmt.Exec(cmd.Id, promise.Pending, headers, cmd.Param.Data, cmd.Timeout, cmd.IdempotencyKey, tags, cmd.CreatedOn) if err != nil { return nil, err } @@ -638,7 +638,7 @@ func (w *PostgresStoreWorker) updatePromise(tx *sql.Tx, stmt *sql.Stmt, cmd *typ } // update - res, err := stmt.Exec(cmd.State, headers, cmd.Value.Ikey, cmd.Value.Data, cmd.CompletedOn, cmd.Id) + res, err := stmt.Exec(cmd.State, headers, cmd.Value.Data, cmd.IdempotencyKey, cmd.CompletedOn, cmd.Id) if err != nil { return nil, err } diff --git a/internal/app/subsystems/aio/store/sqlite/sqlite.go b/internal/app/subsystems/aio/store/sqlite/sqlite.go index 2b16065d..e34b09d2 100644 --- a/internal/app/subsystems/aio/store/sqlite/sqlite.go +++ b/internal/app/subsystems/aio/store/sqlite/sqlite.go @@ -25,19 +25,19 @@ import ( const ( CREATE_TABLE_STATEMENT = ` CREATE TABLE IF NOT EXISTS promises ( - id TEXT UNIQUE, - sort_id INTEGER PRIMARY KEY AUTOINCREMENT, - state INTEGER DEFAULT 1, - param_headers BLOB, - param_ikey TEXT, - param_data BLOB, - value_headers BLOB, - value_ikey TEXT, - value_data BLOB, - timeout INTEGER, - tags BLOB, - created_on INTEGER, - completed_on INTEGER + id TEXT UNIQUE, + sort_id INTEGER PRIMARY KEY AUTOINCREMENT, + state INTEGER DEFAULT 1, + param_headers BLOB, + param_data BLOB, + value_headers BLOB, + value_data BLOB, + timeout INTEGER, + idempotency_key_for_create TEXT, + idempotency_key_for_complete TEXT, + tags BLOB, + created_on INTEGER, + completed_on INTEGER ); CREATE INDEX IF NOT EXISTS idx_promises_id ON promises(id); @@ -72,7 +72,7 @@ const ( PROMISE_SELECT_STATEMENT = ` SELECT - id, state, param_headers, param_ikey, param_data, value_headers, value_ikey, value_data, timeout, tags, created_on, completed_on + id, state, param_headers, param_data, value_headers, value_data, timeout, idempotency_key_for_create, idempotency_key_for_complete, tags, created_on, completed_on FROM promises WHERE @@ -80,7 +80,7 @@ const ( PROMISE_SEARCH_STATEMENT = ` SELECT - id, state, param_headers, param_ikey, param_data, value_headers, value_ikey, value_data, timeout, tags, created_on, completed_on, sort_id + id, state, param_headers, param_data, value_headers, value_data, timeout, idempotency_key_for_create, idempotency_key_for_complete, tags, created_on, completed_on, sort_id FROM promises WHERE @@ -94,7 +94,7 @@ const ( PROMISE_INSERT_STATEMENT = ` INSERT INTO promises - (id, state, param_headers, param_ikey, param_data, timeout, tags, created_on) + (id, state, param_headers, param_data, timeout, idempotency_key_for_create, tags, created_on) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO NOTHING` @@ -103,7 +103,7 @@ const ( UPDATE promises SET - state = ?, value_headers = ?, value_ikey = ?, value_data = ?, completed_on = ? + state = ?, value_headers = ?, value_data = ?, idempotency_key_for_complete = ?, completed_on = ? WHERE id = ? AND state = 1` @@ -478,12 +478,12 @@ func (w *SqliteStoreWorker) readPromise(tx *sql.Tx, cmd *types.ReadPromiseComman &record.Id, &record.State, &record.ParamHeaders, - &record.ParamIkey, &record.ParamData, &record.ValueHeaders, - &record.ValueIkey, &record.ValueData, &record.Timeout, + &record.IdempotencyKeyForCreate, + &record.IdempotencyKeyForComplete, &record.Tags, &record.CreatedOn, &record.CompletedOn, @@ -539,12 +539,12 @@ func (w *SqliteStoreWorker) searchPromises(tx *sql.Tx, cmd *types.SearchPromises &record.Id, &record.State, &record.ParamHeaders, - &record.ParamIkey, &record.ParamData, &record.ValueHeaders, - &record.ValueIkey, &record.ValueData, &record.Timeout, + &record.IdempotencyKeyForCreate, + &record.IdempotencyKeyForComplete, &record.Tags, &record.CreatedOn, &record.CompletedOn, @@ -584,7 +584,7 @@ func (w *SqliteStoreWorker) createPromise(tx *sql.Tx, stmt *sql.Stmt, cmd *types } // insert - res, err := stmt.Exec(cmd.Id, promise.Pending, headers, cmd.Param.Ikey, cmd.Param.Data, cmd.Timeout, tags, cmd.CreatedOn) + res, err := stmt.Exec(cmd.Id, promise.Pending, headers, cmd.Param.Data, cmd.Timeout, cmd.IdempotencyKey, tags, cmd.CreatedOn) if err != nil { return nil, err } @@ -613,7 +613,7 @@ func (w *SqliteStoreWorker) updatePromise(tx *sql.Tx, stmt *sql.Stmt, cmd *types } // update - res, err := stmt.Exec(cmd.State, headers, cmd.Value.Ikey, cmd.Value.Data, cmd.CompletedOn, cmd.Id) + res, err := stmt.Exec(cmd.State, headers, cmd.Value.Data, cmd.IdempotencyKey, cmd.CompletedOn, cmd.Id) if err != nil { return nil, err } diff --git a/internal/app/subsystems/aio/store/test/util.go b/internal/app/subsystems/aio/store/test/util.go index 05a1d272..4fe553d2 100644 --- a/internal/app/subsystems/aio/store/test/util.go +++ b/internal/app/subsystems/aio/store/test/util.go @@ -113,15 +113,15 @@ var TestCases = []*testCase{ { Kind: types.StoreCreatePromise, CreatePromise: &types.CreatePromiseCommand{ - Id: "bar", - Timeout: 2, + Id: "bar", Param: promise.Value{ Headers: map[string]string{}, - Ikey: ikey("bar"), Data: []byte{}, }, - Tags: map[string]string{}, - CreatedOn: 1, + Timeout: 2, + IdempotencyKey: ikey("bar"), + Tags: map[string]string{}, + CreatedOn: 1, }, }, { @@ -143,14 +143,14 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "bar", - State: 1, - ParamHeaders: []byte("{}"), - ParamIkey: ikey("bar"), - ParamData: []byte{}, - Timeout: 2, - Tags: []byte("{}"), - CreatedOn: int64ToPointer(1), + Id: "bar", + State: 1, + ParamHeaders: []byte("{}"), + IdempotencyKeyForCreate: ikey("bar"), + ParamData: []byte{}, + Timeout: 2, + Tags: []byte("{}"), + CreatedOn: int64ToPointer(1), }}, }, }, @@ -162,15 +162,15 @@ var TestCases = []*testCase{ { Kind: types.StoreCreatePromise, CreatePromise: &types.CreatePromiseCommand{ - Id: "baz", - Timeout: 3, + Id: "baz", Param: promise.Value{ Headers: map[string]string{}, - Ikey: ikey("baz"), Data: []byte("baz"), }, - Tags: map[string]string{}, - CreatedOn: 1, + Timeout: 3, + IdempotencyKey: ikey("baz"), + Tags: map[string]string{}, + CreatedOn: 1, }, }, { @@ -192,14 +192,14 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "baz", - State: 1, - ParamHeaders: []byte("{}"), - ParamIkey: ikey("baz"), - ParamData: []byte("baz"), - Timeout: 3, - Tags: []byte("{}"), - CreatedOn: int64ToPointer(1), + Id: "baz", + State: 1, + ParamHeaders: []byte("{}"), + IdempotencyKeyForCreate: ikey("baz"), + ParamData: []byte("baz"), + Timeout: 3, + Tags: []byte("{}"), + CreatedOn: int64ToPointer(1), }}, }, }, @@ -211,19 +211,19 @@ var TestCases = []*testCase{ { Kind: types.StoreCreatePromise, CreatePromise: &types.CreatePromiseCommand{ - Id: "baz", - Timeout: 3, + Id: "baz", Param: promise.Value{ Headers: map[string]string{ "a": "a", "b": "b", "c": "c", }, - Ikey: ikey("baz"), Data: []byte("baz"), }, - Tags: map[string]string{}, - CreatedOn: 1, + Timeout: 3, + IdempotencyKey: ikey("baz"), + Tags: map[string]string{}, + CreatedOn: 1, }, }, { @@ -245,14 +245,14 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "baz", - State: 1, - ParamHeaders: []byte(`{"a":"a","b":"b","c":"c"}`), - ParamIkey: ikey("baz"), - ParamData: []byte("baz"), - Timeout: 3, - Tags: []byte("{}"), - CreatedOn: int64ToPointer(1), + Id: "baz", + State: 1, + ParamHeaders: []byte(`{"a":"a","b":"b","c":"c"}`), + IdempotencyKeyForCreate: ikey("baz"), + ParamData: []byte("baz"), + Timeout: 3, + Tags: []byte("{}"), + CreatedOn: int64ToPointer(1), }}, }, }, @@ -264,17 +264,17 @@ var TestCases = []*testCase{ { Kind: types.StoreCreatePromise, CreatePromise: &types.CreatePromiseCommand{ - Id: "baz", - Timeout: 3, + Id: "baz", Param: promise.Value{ Headers: map[string]string{ "a": "a", "b": "b", "c": "c", }, - Ikey: ikey("baz"), Data: []byte("baz"), }, + Timeout: 3, + IdempotencyKey: ikey("baz"), Tags: map[string]string{ "x": "x", "y": "y", @@ -302,14 +302,14 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "baz", - State: 1, - ParamHeaders: []byte(`{"a":"a","b":"b","c":"c"}`), - ParamIkey: ikey("baz"), - ParamData: []byte("baz"), - Timeout: 3, - Tags: []byte(`{"x":"x","y":"y","z":"z"}`), - CreatedOn: int64ToPointer(1), + Id: "baz", + State: 1, + ParamHeaders: []byte(`{"a":"a","b":"b","c":"c"}`), + IdempotencyKeyForCreate: ikey("baz"), + ParamData: []byte("baz"), + Timeout: 3, + Tags: []byte(`{"x":"x","y":"y","z":"z"}`), + CreatedOn: int64ToPointer(1), }}, }, }, @@ -510,10 +510,10 @@ var TestCases = []*testCase{ State: 2, Value: promise.Value{ Headers: map[string]string{}, - Ikey: ikey("foo"), Data: []byte{}, }, - CompletedOn: 2, + IdempotencyKey: ikey("foo"), + CompletedOn: 2, }, }, { @@ -542,10 +542,10 @@ var TestCases = []*testCase{ State: 4, Value: promise.Value{ Headers: map[string]string{}, - Ikey: ikey("bar"), Data: []byte{}, }, - CompletedOn: 2, + IdempotencyKey: ikey("bar"), + CompletedOn: 2, }, }, { @@ -573,17 +573,17 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "foo", - State: 2, - ParamHeaders: []byte("{}"), - ParamData: []byte{}, - ValueHeaders: []byte("{}"), - ValueData: []byte{}, - ValueIkey: ikey("foo"), - Timeout: 1, - Tags: []byte("{}"), - CreatedOn: int64ToPointer(1), - CompletedOn: int64ToPointer(2), + Id: "foo", + State: 2, + ParamHeaders: []byte("{}"), + ParamData: []byte{}, + ValueHeaders: []byte("{}"), + ValueData: []byte{}, + IdempotencyKeyForComplete: ikey("foo"), + Timeout: 1, + Tags: []byte("{}"), + CreatedOn: int64ToPointer(1), + CompletedOn: int64ToPointer(2), }}, }, }, @@ -604,17 +604,17 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "bar", - State: 4, - ParamHeaders: []byte("{}"), - ParamData: []byte{}, - ValueHeaders: []byte("{}"), - ValueData: []byte{}, - ValueIkey: ikey("bar"), - Timeout: 2, - Tags: []byte("{}"), - CreatedOn: int64ToPointer(1), - CompletedOn: int64ToPointer(2), + Id: "bar", + State: 4, + ParamHeaders: []byte("{}"), + ParamData: []byte{}, + ValueHeaders: []byte("{}"), + ValueData: []byte{}, + IdempotencyKeyForComplete: ikey("bar"), + Timeout: 2, + Tags: []byte("{}"), + CreatedOn: int64ToPointer(1), + CompletedOn: int64ToPointer(2), }}, }, }, @@ -643,10 +643,10 @@ var TestCases = []*testCase{ State: 2, Value: promise.Value{ Headers: map[string]string{}, - Ikey: ikey("foo"), Data: []byte("foo"), }, - CompletedOn: 2, + IdempotencyKey: ikey("foo"), + CompletedOn: 2, }, }, { @@ -675,10 +675,10 @@ var TestCases = []*testCase{ State: 4, Value: promise.Value{ Headers: map[string]string{}, - Ikey: ikey("bar"), Data: []byte("bar"), }, - CompletedOn: 2, + IdempotencyKey: ikey("bar"), + CompletedOn: 2, }, }, { @@ -706,17 +706,17 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "foo", - State: 2, - ParamHeaders: []byte("{}"), - ParamData: []byte{}, - ValueHeaders: []byte("{}"), - ValueIkey: ikey("foo"), - ValueData: []byte("foo"), - Timeout: 1, - Tags: []byte("{}"), - CreatedOn: int64ToPointer(1), - CompletedOn: int64ToPointer(2), + Id: "foo", + State: 2, + ParamHeaders: []byte("{}"), + ParamData: []byte{}, + ValueHeaders: []byte("{}"), + IdempotencyKeyForComplete: ikey("foo"), + ValueData: []byte("foo"), + Timeout: 1, + Tags: []byte("{}"), + CreatedOn: int64ToPointer(1), + CompletedOn: int64ToPointer(2), }}, }, }, @@ -737,17 +737,17 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "bar", - State: 4, - ParamHeaders: []byte("{}"), - ParamData: []byte{}, - ValueHeaders: []byte("{}"), - ValueIkey: ikey("bar"), - ValueData: []byte("bar"), - Timeout: 2, - Tags: []byte("{}"), - CreatedOn: int64ToPointer(1), - CompletedOn: int64ToPointer(2), + Id: "bar", + State: 4, + ParamHeaders: []byte("{}"), + ParamData: []byte{}, + ValueHeaders: []byte("{}"), + IdempotencyKeyForComplete: ikey("bar"), + ValueData: []byte("bar"), + Timeout: 2, + Tags: []byte("{}"), + CreatedOn: int64ToPointer(1), + CompletedOn: int64ToPointer(2), }}, }, }, @@ -780,10 +780,10 @@ var TestCases = []*testCase{ "b": "b", "c": "c", }, - Ikey: ikey("foo"), Data: []byte("foo"), }, - CompletedOn: 2, + IdempotencyKey: ikey("foo"), + CompletedOn: 2, }, }, { @@ -816,10 +816,10 @@ var TestCases = []*testCase{ "b": "b", "c": "c", }, - Ikey: ikey("bar"), Data: []byte("bar"), }, - CompletedOn: 2, + IdempotencyKey: ikey("bar"), + CompletedOn: 2, }, }, { @@ -847,17 +847,17 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "foo", - State: 2, - ParamHeaders: []byte("{}"), - ParamData: []byte{}, - ValueHeaders: []byte(`{"a":"a","b":"b","c":"c"}`), - ValueIkey: ikey("foo"), - ValueData: []byte("foo"), - Timeout: 1, - Tags: []byte("{}"), - CreatedOn: int64ToPointer(1), - CompletedOn: int64ToPointer(2), + Id: "foo", + State: 2, + ParamHeaders: []byte("{}"), + ParamData: []byte{}, + ValueHeaders: []byte(`{"a":"a","b":"b","c":"c"}`), + IdempotencyKeyForComplete: ikey("foo"), + ValueData: []byte("foo"), + Timeout: 1, + Tags: []byte("{}"), + CreatedOn: int64ToPointer(1), + CompletedOn: int64ToPointer(2), }}, }, }, @@ -878,17 +878,17 @@ var TestCases = []*testCase{ ReadPromise: &types.QueryPromisesResult{ RowsReturned: 1, Records: []*promise.PromiseRecord{{ - Id: "bar", - State: 4, - ParamHeaders: []byte("{}"), - ParamData: []byte{}, - ValueHeaders: []byte(`{"a":"a","b":"b","c":"c"}`), - ValueIkey: ikey("bar"), - ValueData: []byte("bar"), - Timeout: 2, - Tags: []byte("{}"), - CreatedOn: int64ToPointer(1), - CompletedOn: int64ToPointer(2), + Id: "bar", + State: 4, + ParamHeaders: []byte("{}"), + ParamData: []byte{}, + ValueHeaders: []byte(`{"a":"a","b":"b","c":"c"}`), + IdempotencyKeyForComplete: ikey("bar"), + ValueData: []byte("bar"), + Timeout: 2, + Tags: []byte("{}"), + CreatedOn: int64ToPointer(1), + CompletedOn: int64ToPointer(2), }}, }, }, @@ -2961,8 +2961,8 @@ var TestCases = []*testCase{ }, } -func ikey(s string) *promise.Ikey { - ikey := promise.Ikey(s) +func ikey(s string) *promise.IdempotencyKey { + ikey := promise.IdempotencyKey(s) return &ikey } diff --git a/internal/app/subsystems/api/grpc/api/promise.pb.go b/internal/app/subsystems/api/grpc/api/promise.pb.go index 57f30153..bbe0c7c1 100644 --- a/internal/app/subsystems/api/grpc/api/promise.pb.go +++ b/internal/app/subsystems/api/grpc/api/promise.pb.go @@ -190,11 +190,13 @@ type Promise struct { 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"` + 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"` } func (x *Promise) Reset() { @@ -264,13 +266,26 @@ func (x *Promise) GetTimeout() int64 { 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 "" +} + 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"` - Ikey string `protobuf:"bytes,2,opt,name=ikey,proto3" json:"ikey,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` } @@ -313,13 +328,6 @@ func (x *Value) GetHeaders() map[string]string { return nil } -func (x *Value) GetIkey() string { - if x != nil { - return x.Ikey - } - return "" -} - func (x *Value) GetData() []byte { if x != nil { return x.Data @@ -568,10 +576,11 @@ type CreatePromiseRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Param *Value `protobuf:"bytes,2,opt,name=param,proto3" json:"param,omitempty"` - Timeout int64 `protobuf:"varint,3,opt,name=timeout,proto3" json:"timeout,omitempty"` - Strict bool `protobuf:"varint,4,opt,name=strict,proto3" json:"strict,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Param *Value `protobuf:"bytes,2,opt,name=param,proto3" json:"param,omitempty"` + Timeout int64 `protobuf:"varint,3,opt,name=timeout,proto3" json:"timeout,omitempty"` + IdempotencyKey string `protobuf:"bytes,4,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + Strict bool `protobuf:"varint,5,opt,name=strict,proto3" json:"strict,omitempty"` } func (x *CreatePromiseRequest) Reset() { @@ -627,6 +636,13 @@ func (x *CreatePromiseRequest) GetTimeout() int64 { return 0 } +func (x *CreatePromiseRequest) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + func (x *CreatePromiseRequest) GetStrict() bool { if x != nil { return x.Strict @@ -694,9 +710,10 @@ type CancelPromiseRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Value *Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Value *Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + IdempotencyKey string `protobuf:"bytes,3,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + Strict bool `protobuf:"varint,4,opt,name=strict,proto3" json:"strict,omitempty"` } func (x *CancelPromiseRequest) Reset() { @@ -745,6 +762,13 @@ func (x *CancelPromiseRequest) GetValue() *Value { return nil } +func (x *CancelPromiseRequest) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + func (x *CancelPromiseRequest) GetStrict() bool { if x != nil { return x.Strict @@ -812,9 +836,10 @@ type ResolvePromiseRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Value *Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Value *Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + IdempotencyKey string `protobuf:"bytes,3,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + Strict bool `protobuf:"varint,4,opt,name=strict,proto3" json:"strict,omitempty"` } func (x *ResolvePromiseRequest) Reset() { @@ -863,6 +888,13 @@ func (x *ResolvePromiseRequest) GetValue() *Value { return nil } +func (x *ResolvePromiseRequest) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + func (x *ResolvePromiseRequest) GetStrict() bool { if x != nil { return x.Strict @@ -930,9 +962,10 @@ type RejectPromiseRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Value *Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - Strict bool `protobuf:"varint,3,opt,name=strict,proto3" json:"strict,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Value *Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + IdempotencyKey string `protobuf:"bytes,3,opt,name=idempotencyKey,proto3" json:"idempotencyKey,omitempty"` + Strict bool `protobuf:"varint,4,opt,name=strict,proto3" json:"strict,omitempty"` } func (x *RejectPromiseRequest) Reset() { @@ -981,6 +1014,13 @@ func (x *RejectPromiseRequest) GetValue() *Value { return nil } +func (x *RejectPromiseRequest) GetIdempotencyKey() string { + if x != nil { + return x.IdempotencyKey + } + return "" +} + func (x *RejectPromiseRequest) GetStrict() bool { if x != nil { return x.Strict @@ -1049,7 +1089,7 @@ 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, 0xa5, 0x01, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x22, 0x9d, 0x02, 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, @@ -1060,152 +1100,169 @@ var file_internal_app_subsystems_api_grpc_api_promise_proto_rawDesc = []byte{ 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, 0x22, 0xa2, 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, 0x69, 0x6b, 0x65, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x18, 0x03, 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, 0x24, 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, - 0x22, 0x6a, 0x0a, 0x13, 0x52, 0x65, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, - 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 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, 0x7f, 0x0a, 0x15, - 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0c, 0x0a, 0x01, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x01, 0x71, 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, - 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, 0x22, 0x87, 0x01, - 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, 0x27, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, - 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 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, 0x12, 0x2c, 0x0a, 0x08, 0x70, 0x72, 0x6f, - 0x6d, 0x69, 0x73, 0x65, 0x73, 0x18, 0x03, 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, 0x7e, 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, - 0x24, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x02, 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, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, - 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x22, 0x6c, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x27, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 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, 0x64, 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, 0x24, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 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, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x22, 0x6c, 0x0a, 0x15, 0x43, - 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 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, 0x65, 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, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 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, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, - 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, - 0x22, 0x6d, 0x0a, 0x16, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6d, 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, 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, 0x03, 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, 0x24, + 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, 0x22, 0x6a, 0x0a, 0x13, 0x52, 0x65, 0x61, 0x64, 0x50, 0x72, 0x6f, 0x6d, + 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x70, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 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, 0x7f, 0x0a, 0x15, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0c, 0x0a, 0x01, 0x71, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x71, 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, 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, 0x22, 0x87, 0x01, 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, 0x27, 0x0a, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x70, + 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 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, 0x12, 0x2c, 0x0a, + 0x08, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x73, 0x18, 0x03, 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, 0xa6, 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, 0x24, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x02, 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, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, + 0x65, 0x6f, 0x75, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, + 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x04, 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, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, + 0x72, 0x69, 0x63, 0x74, 0x22, 0x6c, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, + 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, + 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 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, 0x8c, 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, 0x24, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 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, 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, + 0x4b, 0x65, 0x79, 0x18, 0x03, 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, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, + 0x74, 0x22, 0x6c, 0x0a, 0x15, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 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, - 0x64, 0x0a, 0x14, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x8d, 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, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 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, + 0x26, 0x0a, 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, + 0x79, 0x18, 0x03, 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, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x22, + 0x6d, 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, 0x27, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, + 0x69, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 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, 0x8c, + 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, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 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, 0x16, 0x0a, - 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, - 0x74, 0x72, 0x69, 0x63, 0x74, 0x22, 0x6c, 0x0a, 0x15, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x50, - 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, - 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, - 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 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, 0x4b, 0x0a, 0x0b, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, 0x5f, 0x50, 0x45, 0x4e, - 0x44, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, - 0x5f, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, 0x44, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x53, - 0x45, 0x41, 0x52, 0x43, 0x48, 0x5f, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, - 0x2a, 0x6a, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, - 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x02, 0x4f, 0x4b, 0x10, 0xc8, 0x01, - 0x12, 0x0c, 0x0a, 0x07, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x10, 0xc9, 0x01, 0x12, 0x0e, - 0x0a, 0x09, 0x4e, 0x4f, 0x43, 0x4f, 0x4e, 0x54, 0x45, 0x4e, 0x54, 0x10, 0xcc, 0x01, 0x12, 0x0e, - 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x42, 0x49, 0x44, 0x44, 0x45, 0x4e, 0x10, 0x93, 0x03, 0x12, 0x0d, - 0x0a, 0x08, 0x4e, 0x4f, 0x54, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x94, 0x03, 0x12, 0x0d, 0x0a, - 0x08, 0x43, 0x4f, 0x4e, 0x46, 0x4c, 0x49, 0x43, 0x54, 0x10, 0x99, 0x03, 0x32, 0xfc, 0x03, 0x0a, - 0x0e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 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, + 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x26, 0x0a, + 0x0e, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4b, 0x65, 0x79, 0x18, + 0x03, 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, + 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x22, 0x6c, 0x0a, + 0x15, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 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, 0x4b, 0x0a, 0x0b, 0x53, + 0x65, 0x61, 0x72, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x45, + 0x41, 0x52, 0x43, 0x48, 0x5f, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x13, + 0x0a, 0x0f, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, 0x5f, 0x52, 0x45, 0x53, 0x4f, 0x4c, 0x56, 0x45, + 0x44, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48, 0x5f, 0x52, 0x45, + 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, 0x2a, 0x6a, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, + 0x07, 0x0a, 0x02, 0x4f, 0x4b, 0x10, 0xc8, 0x01, 0x12, 0x0c, 0x0a, 0x07, 0x43, 0x52, 0x45, 0x41, + 0x54, 0x45, 0x44, 0x10, 0xc9, 0x01, 0x12, 0x0e, 0x0a, 0x09, 0x4e, 0x4f, 0x43, 0x4f, 0x4e, 0x54, + 0x45, 0x4e, 0x54, 0x10, 0xcc, 0x01, 0x12, 0x0e, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x42, 0x49, 0x44, + 0x44, 0x45, 0x4e, 0x10, 0x93, 0x03, 0x12, 0x0d, 0x0a, 0x08, 0x4e, 0x4f, 0x54, 0x46, 0x4f, 0x55, + 0x4e, 0x44, 0x10, 0x94, 0x03, 0x12, 0x0d, 0x0a, 0x08, 0x43, 0x4f, 0x4e, 0x46, 0x4c, 0x49, 0x43, + 0x54, 0x10, 0x99, 0x03, 0x32, 0xfc, 0x03, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 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 ( diff --git a/internal/app/subsystems/api/grpc/api/promise.proto b/internal/app/subsystems/api/grpc/api/promise.proto index 15a223cd..5a3eba79 100644 --- a/internal/app/subsystems/api/grpc/api/promise.proto +++ b/internal/app/subsystems/api/grpc/api/promise.proto @@ -10,6 +10,8 @@ message Promise { Value param = 3; Value value = 4; int64 timeout = 5; + string idempotencyKeyForCreate = 6; + string idempotencyKeyForComplete = 7; } enum State { @@ -38,7 +40,6 @@ enum Status { message Value { map headers = 1; - string ikey = 2; bytes data = 3; } @@ -68,7 +69,8 @@ message CreatePromiseRequest { string id = 1; Value param = 2; int64 timeout = 3; - bool strict = 4; + string idempotencyKey = 4; + bool strict = 5; } message CreatePromiseResponse { @@ -79,7 +81,8 @@ message CreatePromiseResponse { message CancelPromiseRequest { string id = 1; Value value = 2; - bool strict = 3; + string idempotencyKey = 3; + bool strict = 4; } message CancelPromiseResponse { @@ -90,7 +93,8 @@ message CancelPromiseResponse { message ResolvePromiseRequest { string id = 1; Value value = 2; - bool strict = 3; + string idempotencyKey = 3; + bool strict = 4; } message ResolvePromiseResponse { @@ -101,7 +105,8 @@ message ResolvePromiseResponse { message RejectPromiseRequest { string id = 1; Value value = 2; - bool strict = 3; + string idempotencyKey = 3; + bool strict = 4; } message RejectPromiseResponse { diff --git a/internal/app/subsystems/api/grpc/grpc.go b/internal/app/subsystems/api/grpc/grpc.go index 7cad4d7e..7ace573f 100644 --- a/internal/app/subsystems/api/grpc/grpc.go +++ b/internal/app/subsystems/api/grpc/grpc.go @@ -205,10 +205,10 @@ func (s *server) CreatePromise(ctx context.Context, req *grpcApi.CreatePromiseRe headers = map[string]string{} } - var ikey *promise.Ikey - if req.Param != nil && req.Param.Ikey != "" { - i := promise.Ikey(req.Param.Ikey) - ikey = &i + var idempotencyKey *promise.IdempotencyKey + if req.IdempotencyKey != "" { + i := promise.IdempotencyKey(req.IdempotencyKey) + idempotencyKey = &i } var data []byte @@ -224,11 +224,11 @@ func (s *server) CreatePromise(ctx context.Context, req *grpcApi.CreatePromiseRe Id: req.Id, Param: promise.Value{ Headers: headers, - Ikey: ikey, Data: data, }, - Timeout: req.Timeout, - Strict: req.Strict, + Timeout: req.Timeout, + IdemptencyKey: idempotencyKey, + Strict: req.Strict, }, }, Callback: s.sendOrPanic(cq), @@ -258,10 +258,10 @@ func (s *server) CancelPromise(ctx context.Context, req *grpcApi.CancelPromiseRe headers = map[string]string{} } - var ikey *promise.Ikey - if req.Value != nil && req.Value.Ikey != "" { - i := promise.Ikey(req.Value.Ikey) - ikey = &i + var idempotencyKey *promise.IdempotencyKey + if req.IdempotencyKey != "" { + i := promise.IdempotencyKey(req.IdempotencyKey) + idempotencyKey = &i } var data []byte @@ -277,10 +277,10 @@ func (s *server) CancelPromise(ctx context.Context, req *grpcApi.CancelPromiseRe Id: req.Id, Value: promise.Value{ Headers: headers, - Ikey: ikey, Data: data, }, - Strict: req.Strict, + IdemptencyKey: idempotencyKey, + Strict: req.Strict, }, }, Callback: s.sendOrPanic(cq), @@ -310,10 +310,10 @@ func (s *server) ResolvePromise(ctx context.Context, req *grpcApi.ResolvePromise headers = map[string]string{} } - var ikey *promise.Ikey - if req.Value != nil && req.Value.Ikey != "" { - i := promise.Ikey(req.Value.Ikey) - ikey = &i + var idempotencyKey *promise.IdempotencyKey + if req.IdempotencyKey != "" { + i := promise.IdempotencyKey(req.IdempotencyKey) + idempotencyKey = &i } var data []byte @@ -329,10 +329,10 @@ func (s *server) ResolvePromise(ctx context.Context, req *grpcApi.ResolvePromise Id: req.Id, Value: promise.Value{ Headers: headers, - Ikey: ikey, Data: data, }, - Strict: req.Strict, + IdemptencyKey: idempotencyKey, + Strict: req.Strict, }, }, Callback: s.sendOrPanic(cq), @@ -362,10 +362,10 @@ func (s *server) RejectPromise(ctx context.Context, req *grpcApi.RejectPromiseRe headers = map[string]string{} } - var ikey *promise.Ikey - if req.Value != nil && req.Value.Ikey != "" { - i := promise.Ikey(req.Value.Ikey) - ikey = &i + var idempotencyKey *promise.IdempotencyKey + if req.IdempotencyKey != "" { + i := promise.IdempotencyKey(req.IdempotencyKey) + idempotencyKey = &i } var data []byte @@ -381,10 +381,10 @@ func (s *server) RejectPromise(ctx context.Context, req *grpcApi.RejectPromiseRe Id: req.Id, Value: promise.Value{ Headers: headers, - Ikey: ikey, Data: data, }, - Strict: req.Strict, + IdemptencyKey: idempotencyKey, + Strict: req.Strict, }, }, Callback: s.sendOrPanic(cq), @@ -425,12 +425,12 @@ func protoPromise(promise *promise.Promise) *grpcApi.Promise { return nil } - var paramIkey, valueIkey string - if promise.Param.Ikey != nil { - paramIkey = string(*promise.Param.Ikey) + var idempotencyKeyForCreate, idempotencyKeyForComplete string + if promise.IdempotencyKeyForCreate != nil { + idempotencyKeyForCreate = string(*promise.IdempotencyKeyForCreate) } - if promise.Value.Ikey != nil { - valueIkey = string(*promise.Value.Ikey) + if promise.IdempotencyKeyForComplete != nil { + idempotencyKeyForComplete = string(*promise.IdempotencyKeyForComplete) } return &grpcApi.Promise{ @@ -438,15 +438,15 @@ func protoPromise(promise *promise.Promise) *grpcApi.Promise { State: protoState(promise.State), Param: &grpcApi.Value{ Headers: promise.Param.Headers, - Ikey: paramIkey, Data: promise.Param.Data, }, Value: &grpcApi.Value{ Headers: promise.Param.Headers, - Ikey: valueIkey, Data: promise.Param.Data, }, - Timeout: promise.Timeout, + Timeout: promise.Timeout, + IdempotencyKeyForCreate: idempotencyKeyForCreate, + IdempotencyKeyForComplete: idempotencyKeyForComplete, } } diff --git a/internal/kernel/types/aio_store.go b/internal/kernel/types/aio_store.go index 26531ee4..19a144c6 100644 --- a/internal/kernel/types/aio_store.go +++ b/internal/kernel/types/aio_store.go @@ -103,19 +103,21 @@ type SearchPromisesCommand struct { } type CreatePromiseCommand struct { - Id string - Timeout int64 - Param promise.Value - Subscriptions []*CreateSubscriptionCommand - Tags map[string]string - CreatedOn int64 + Id string + Param promise.Value + Timeout int64 + IdempotencyKey *promise.IdempotencyKey + Subscriptions []*CreateSubscriptionCommand + Tags map[string]string + CreatedOn int64 } type UpdatePromiseCommand struct { - Id string - State promise.State - Value promise.Value - CompletedOn int64 + Id string + State promise.State + Value promise.Value + IdempotencyKey *promise.IdempotencyKey + CompletedOn int64 } // Promise results diff --git a/internal/kernel/types/api_request.go b/internal/kernel/types/api_request.go index 149883c7..6549b9d5 100644 --- a/internal/kernel/types/api_request.go +++ b/internal/kernel/types/api_request.go @@ -33,29 +33,33 @@ type SearchPromisesRequest struct { } type CreatePromiseRequest struct { - Id string `json:"id"` - Param promise.Value `json:"param,omitempty"` - Timeout int64 `json:"timeout"` - Tags map[string]string `json:"tags,omitempty"` - Strict bool `json:"strict"` + Id string `json:"id"` + Param promise.Value `json:"param,omitempty"` + Timeout int64 `json:"timeout"` + IdemptencyKey *promise.IdempotencyKey `json:"idemptencyKey,omitempty"` + Tags map[string]string `json:"tags,omitempty"` + Strict bool `json:"strict"` } type CancelPromiseRequest struct { - Id string `json:"id"` - Value promise.Value `json:"value,omitempty"` - Strict bool `json:"strict"` + Id string `json:"id"` + Value promise.Value `json:"value,omitempty"` + IdemptencyKey *promise.IdempotencyKey `json:"idemptencyKey,omitempty"` + Strict bool `json:"strict"` } type ResolvePromiseRequest struct { - Id string `json:"id"` - Value promise.Value `json:"value,omitempty"` - Strict bool `json:"strict"` + Id string `json:"id"` + Value promise.Value `json:"value,omitempty"` + IdemptencyKey *promise.IdempotencyKey `json:"idemptencyKey,omitempty"` + Strict bool `json:"strict"` } type RejectPromiseRequest struct { - Id string `json:"id"` - Value promise.Value `json:"value,omitempty"` - Strict bool `json:"strict"` + Id string `json:"id"` + Value promise.Value `json:"value,omitempty"` + IdemptencyKey *promise.IdempotencyKey `json:"idemptencyKey,omitempty"` + Strict bool `json:"strict"` } type ReadSubscriptionsRequest struct { @@ -98,31 +102,31 @@ func (r *Request) String() string { ) case CreatePromise: return fmt.Sprintf( - "CreatePromise(id=%s, ikey=%s, timeout=%d, strict=%t)", + "CreatePromise(id=%s, idempotencyKey=%s, timeout=%d, strict=%t)", r.CreatePromise.Id, - r.CreatePromise.Param.Ikey, + r.CreatePromise.IdemptencyKey, r.CreatePromise.Timeout, r.CreatePromise.Strict, ) case CancelPromise: return fmt.Sprintf( - "CancelPromise(id=%s, ikey=%s, strict=%t)", + "CancelPromise(id=%s, idempotencyKey=%s, strict=%t)", r.CancelPromise.Id, - r.CancelPromise.Value.Ikey, + r.CancelPromise.IdemptencyKey, r.CancelPromise.Strict, ) case ResolvePromise: return fmt.Sprintf( - "ResolvePromise(id=%s, ikey=%s, strict=%t)", + "ResolvePromise(id=%s, idempotencyKey=%s, strict=%t)", r.ResolvePromise.Id, - r.ResolvePromise.Value.Ikey, + r.ResolvePromise.IdemptencyKey, r.ResolvePromise.Strict, ) case RejectPromise: return fmt.Sprintf( - "RejectPromise(id=%s, ikey=%s, strict=%t)", + "RejectPromise(id=%s, idempotencyKey=%s, strict=%t)", r.RejectPromise.Id, - r.RejectPromise.Value.Ikey, + r.RejectPromise.IdemptencyKey, r.RejectPromise.Strict, ) case ReadSubscriptions: diff --git a/pkg/promise/promise.go b/pkg/promise/promise.go index 4b1aa173..13923f78 100644 --- a/pkg/promise/promise.go +++ b/pkg/promise/promise.go @@ -7,25 +7,29 @@ import ( ) type Promise struct { - Id string `json:"id"` - State State `json:"state"` - Param Value `json:"param,omitempty"` - Value Value `json:"value,omitempty"` - Timeout int64 `json:"timeout"` - CreatedOn *int64 `json:"createdOn,omitempty"` - CompletedOn *int64 `json:"completedOn,omitempty"` - Tags map[string]string `json:"tags"` - SortId int64 `json:"-"` // unexported + Id string `json:"id"` + State State `json:"state"` + Param Value `json:"param,omitempty"` + Value Value `json:"value,omitempty"` + Timeout int64 `json:"timeout"` + IdempotencyKeyForCreate *IdempotencyKey `json:"idempotencyKeyForCreate,omitempty"` + IdempotencyKeyForComplete *IdempotencyKey `json:"idempotencyKeyForComplete,omitempty"` + CreatedOn *int64 `json:"createdOn,omitempty"` + CompletedOn *int64 `json:"completedOn,omitempty"` + Tags map[string]string `json:"tags"` + SortId int64 `json:"-"` // unexported } func (p *Promise) String() string { return fmt.Sprintf( - "Promise(id=%s, state=%s, param=%s, value=%s, timeout=%d)", + "Promise(id=%s, state=%s, param=%s, value=%s, timeout=%d, idempotencyKeyForCreate=%s, idempotencyKeyForUpdate=%s)", p.Id, p.State, &p.Param, &p.Value, p.Timeout, + p.IdempotencyKeyForCreate, + p.IdempotencyKeyForComplete, ) } @@ -90,24 +94,23 @@ func (s State) In(mask State) bool { type Value struct { Headers map[string]string `json:"headers,omitempty"` - Ikey *Ikey `json:"ikey,omitempty"` Data []byte `json:"data,omitempty"` } func (v *Value) String() string { return fmt.Sprintf( - "Value(ikey=%s, data=%s)", - v.Ikey, + "Value(headers=%s, data=%s)", + v.Headers, string(v.Data), ) } -type Ikey string +type IdempotencyKey string -func (i1 *Ikey) Match(i2 *Ikey) bool { +func (i1 *IdempotencyKey) Match(i2 *IdempotencyKey) bool { return i1 != nil && i2 != nil && *i1 == *i2 } -func (i *Ikey) String() string { +func (i *IdempotencyKey) String() string { return string(*i) } diff --git a/pkg/promise/record.go b/pkg/promise/record.go index 50923dc7..19849bf9 100644 --- a/pkg/promise/record.go +++ b/pkg/promise/record.go @@ -5,19 +5,19 @@ import ( ) type PromiseRecord struct { - Id string - State State - ParamHeaders []byte - ParamIkey *Ikey - ParamData []byte - ValueHeaders []byte - ValueIkey *Ikey - ValueData []byte - Timeout int64 - CreatedOn *int64 - CompletedOn *int64 - Tags []byte - SortId int64 + Id string + State State + ParamHeaders []byte + ParamData []byte + ValueHeaders []byte + ValueData []byte + Timeout int64 + IdempotencyKeyForCreate *IdempotencyKey + IdempotencyKeyForComplete *IdempotencyKey + CreatedOn *int64 + CompletedOn *int64 + Tags []byte + SortId int64 } func (r *PromiseRecord) Promise() (*Promise, error) { @@ -37,15 +37,17 @@ func (r *PromiseRecord) Promise() (*Promise, error) { } return &Promise{ - Id: r.Id, - State: r.State, - Timeout: r.Timeout, - Param: param, - Value: value, - CreatedOn: r.CreatedOn, - CompletedOn: r.CompletedOn, - Tags: tags, - SortId: r.SortId, + Id: r.Id, + State: r.State, + Param: param, + Value: value, + Timeout: r.Timeout, + IdempotencyKeyForCreate: r.IdempotencyKeyForCreate, + IdempotencyKeyForComplete: r.IdempotencyKeyForComplete, + CreatedOn: r.CreatedOn, + CompletedOn: r.CompletedOn, + Tags: tags, + SortId: r.SortId, }, nil } @@ -60,7 +62,6 @@ func (r *PromiseRecord) param() (Value, error) { return Value{ Headers: headers, - Ikey: r.ParamIkey, Data: r.ParamData, }, nil } @@ -76,7 +77,6 @@ func (r *PromiseRecord) value() (Value, error) { return Value{ Headers: headers, - Ikey: r.ValueIkey, Data: r.ValueData, }, nil } diff --git a/test/dst/generator.go b/test/dst/generator.go index e305c165..c25757cd 100644 --- a/test/dst/generator.go +++ b/test/dst/generator.go @@ -13,7 +13,7 @@ import ( type Generator struct { ticks int64 idSet []string - ikeySet []*promise.Ikey + ikeySet []*promise.IdempotencyKey dataSet [][]byte headersSet []map[string]string tagsSet []map[string]string @@ -30,10 +30,10 @@ func NewGenerator(r *rand.Rand, config *Config) *Generator { idSet[i] = strconv.Itoa(i) } - ikeySet := []*promise.Ikey{} + ikeySet := []*promise.IdempotencyKey{} for i := 0; i < config.Ikeys; i++ { s := strconv.Itoa(i) - ikey := promise.Ikey(s) + ikey := promise.IdempotencyKey(s) ikeySet = append(ikeySet, &ikey, nil) // half of all ikeys are nil } @@ -170,15 +170,15 @@ func (g *Generator) GenerateCreatePromise(r *rand.Rand, t int64) *types.Request return &types.Request{ Kind: types.CreatePromise, CreatePromise: &types.CreatePromiseRequest{ - Id: id, - Timeout: timeout, + Id: id, Param: promise.Value{ Headers: headers, - Ikey: ikey, Data: data, }, - Tags: tags, - Strict: strict, + Timeout: timeout, + IdemptencyKey: ikey, + Tags: tags, + Strict: strict, }, } } @@ -196,10 +196,10 @@ func (g *Generator) GenerateCancelPromise(r *rand.Rand, t int64) *types.Request Id: id, Value: promise.Value{ Headers: headers, - Ikey: ikey, Data: data, }, - Strict: strict, + IdemptencyKey: ikey, + Strict: strict, }, } } @@ -217,10 +217,10 @@ func (g *Generator) GenerateResolvePromise(r *rand.Rand, t int64) *types.Request Id: id, Value: promise.Value{ Headers: headers, - Ikey: ikey, Data: data, }, - Strict: strict, + IdemptencyKey: ikey, + Strict: strict, }, } } @@ -238,10 +238,10 @@ func (g *Generator) GenerateRejectPromise(r *rand.Rand, t int64) *types.Request Id: id, Value: promise.Value{ Headers: headers, - Ikey: ikey, Data: data, }, - Strict: strict, + IdemptencyKey: ikey, + Strict: strict, }, } } diff --git a/test/dst/model.go b/test/dst/model.go index d5c27d1b..e0be2081 100644 --- a/test/dst/model.go +++ b/test/dst/model.go @@ -195,8 +195,8 @@ func (m *PromiseModel) createPromise(req *types.CreatePromiseRequest, res *types switch res.Status { case types.ResponseOK: if m.promise != nil { - if !m.paramIkeyMatch(res.Promise) { - return fmt.Errorf("ikey mismatch (%s, %s)", m.promise.Param.Ikey, res.Promise.Param.Ikey) + if !m.idempotencyKeyForCreateMatch(res.Promise) { + return fmt.Errorf("ikey mismatch (%s, %s)", m.promise.IdempotencyKeyForCreate, res.Promise.IdempotencyKeyForCreate) } else if req.Strict && m.promise.State != promise.Pending { return fmt.Errorf("unexpected state %s when strict true", m.promise.State) } @@ -219,8 +219,8 @@ func (m *PromiseModel) cancelPromise(req *types.CancelPromiseRequest, res *types switch res.Status { case types.ResponseOK: if m.completed() { - if !m.valueIkeyMatch(res.Promise) { - return fmt.Errorf("ikey mismatch (%s, %s)", m.promise.Value.Ikey, res.Promise.Value.Ikey) + if !m.idempotencyKeyForCompleteMatch(res.Promise) { + return fmt.Errorf("ikey mismatch (%s, %s)", m.promise.IdempotencyKeyForComplete, res.Promise.IdempotencyKeyForComplete) } else if req.Strict && m.promise.State != promise.Canceled { return fmt.Errorf("unexpected state %s when strict true", m.promise.State) } @@ -245,8 +245,8 @@ func (m *PromiseModel) resolvePromise(req *types.ResolvePromiseRequest, res *typ switch res.Status { case types.ResponseOK: if m.completed() { - if !m.valueIkeyMatch(res.Promise) { - return fmt.Errorf("ikey mismatch (%s, %s)", m.promise.Value.Ikey, res.Promise.Value.Ikey) + if !m.idempotencyKeyForCompleteMatch(res.Promise) { + return fmt.Errorf("ikey mismatch (%s, %s)", m.promise.IdempotencyKeyForComplete, res.Promise.IdempotencyKeyForComplete) } else if req.Strict && m.promise.State != promise.Resolved { return fmt.Errorf("unexpected state %s when strict true", m.promise.State) } @@ -271,8 +271,8 @@ func (m *PromiseModel) rejectPromise(req *types.RejectPromiseRequest, res *types switch res.Status { case types.ResponseOK: if m.completed() { - if !m.valueIkeyMatch(res.Promise) { - return fmt.Errorf("ikey mismatch (%s, %s)", m.promise.Value.Ikey, res.Promise.Value.Ikey) + if !m.idempotencyKeyForCompleteMatch(res.Promise) { + return fmt.Errorf("ikey mismatch (%s, %s)", m.promise.IdempotencyKeyForComplete, res.Promise.IdempotencyKeyForComplete) } else if req.Strict && m.promise.State != promise.Rejected { return fmt.Errorf("unexpected state %s when strict true", m.promise.State) } @@ -297,9 +297,9 @@ func (m *PromiseModel) verifyPromise(p *promise.Promise) error { if m.promise != nil && p != nil { if m.promise.Id != p.Id || m.promise.Timeout != p.Timeout || - (m.promise.Param.Ikey != nil && !m.paramIkeyMatch(p)) || + (m.promise.IdempotencyKeyForCreate != nil && !m.idempotencyKeyForCreateMatch(p)) || string(m.promise.Param.Data) != string(p.Param.Data) || - (m.completed() && m.promise.Value.Ikey != nil && !m.valueIkeyMatch(p)) || + (m.completed() && m.promise.IdempotencyKeyForComplete != nil && !m.idempotencyKeyForCompleteMatch(p)) || (m.completed() && string(m.promise.Value.Data) != string(p.Value.Data)) { return fmt.Errorf("promises do not match (%s, %s)", m.promise, p) @@ -377,12 +377,12 @@ func (m *PromiseModel) verifySubscription(subscription *subscription.Subscriptio return nil } -func (m *PromiseModel) paramIkeyMatch(promise *promise.Promise) bool { - return m.promise.Param.Ikey != nil && promise.Param.Ikey != nil && *m.promise.Param.Ikey == *promise.Param.Ikey +func (m *PromiseModel) idempotencyKeyForCreateMatch(promise *promise.Promise) bool { + return m.promise.IdempotencyKeyForCreate != nil && promise.IdempotencyKeyForCreate != nil && *m.promise.IdempotencyKeyForCreate == *promise.IdempotencyKeyForCreate } -func (m *PromiseModel) valueIkeyMatch(promise *promise.Promise) bool { - return m.promise.Value.Ikey != nil && promise.Value.Ikey != nil && *m.promise.Value.Ikey == *promise.Value.Ikey +func (m *PromiseModel) idempotencyKeyForCompleteMatch(promise *promise.Promise) bool { + return m.promise.IdempotencyKeyForComplete != nil && promise.IdempotencyKeyForComplete != nil && *m.promise.IdempotencyKeyForComplete == *promise.IdempotencyKeyForComplete } func (m *PromiseModel) completed() bool {