Skip to content

Commit

Permalink
Fix global attribute protocol (#16)
Browse files Browse the repository at this point in the history
* Fix global attribute protocol

* fix policy
  • Loading branch information
longquanzheng authored Oct 31, 2023
1 parent 2db5a31 commit 31b9161
Show file tree
Hide file tree
Showing 32 changed files with 1,992 additions and 1,600 deletions.
102 changes: 54 additions & 48 deletions api-schema/xdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ components:
type: array
items:
$ref: '#/components/schemas/LocalQueueMessage'
upsertGlobalAttributes:
writeToGlobalAttributes:
type: array
items:
$ref: '#/components/schemas/GlobalAttributeValue'
$ref: '#/components/schemas/GlobalAttributeTableRowUpdate'
StateDecision:
type: object
description: the decision at the end of state execution, either nextStates or threadCloseDecision is needed
Expand Down Expand Up @@ -498,25 +498,46 @@ components:
GlobalAttributeConfig:
type: object
properties:
defaultDbTable:
tableConfigs:
type: array
items:
$ref: '#/components/schemas/GlobalAttributeTableConfig'
GlobalAttributeTableConfig:
type: object
required:
- tableName
- primaryKey
properties:
tableName:
type: string
primaryGlobalAttribute:
$ref: '#/components/schemas/GlobalAttributeValue'
initialGlobalAttributes: # initial upsert global attribute -- create the new row if not exists
primaryKey:
$ref: '#/components/schemas/TableColumnValue'
initialWrite: # optional initial write -- create the new row if not exists
type: array
items:
$ref: '#/components/schemas/GlobalAttributeValue'
initialGlobalAttributeWriteMode:
$ref: '#/components/schemas/TableColumnValue'
initialWriteMode:
$ref: '#/components/schemas/AttributeWriteConflictMode'
GlobalAttributeTableRowUpdate:
type: object
required:
- tableName
properties:
tableName:
type: string
updateColumns:
type: array
items:
$ref: '#/components/schemas/TableColumnValue'
AttributeWriteConflictMode:
type: string
enum:
- ReturnErrorOnConflict # default behavior for initial global attributes
- IgnoreConflict
- OverrideOnConflict
GlobalAttributeValue:
TableColumnValue:
type: object
description: the value of a global attribute (from SDK to server or from server to SDK)
description: the value of a global attribute table (from SDK to server or from server to SDK)
required:
- dbColumn
- dbQueryValue
Expand All @@ -527,67 +548,52 @@ components:
dbQueryValue:
type: string
description: the plain string value that can be used in the database query(e.g. for SQL SELECT ... WHERE $Column=$dbQueryValue or UPDATE/INSERT)
alternativeTable:
type: string
description: if not empty, the global attribute is mapped to a different table name than the default table. Must be used with alternativeTableForeignKeyColumn
alternativeTableForeignKeyColumn:
type: string
description: Must present when alternativeTable is not empty. It means the foreign key column to join with the primary key of the default table
# dbHint:
# type: string
# description: some additional info for how to use the dbColumn and dbQueryValue
GlobalAttributeKey:
TableColumnDef:
type: object
description: the definition(key) for getting value of a global attribute
description: the definition(key) for getting value of a global attribute table
required:
- dbColumn
properties:
dbColumn:
type: string
description: the column name that can be used in the database query, see below for example
alternativeTable:
type: string
description: if not empty, the global attribute is mapped to a different table name than the default table. Must be used with alternativeTableForeignKeyColumn
alternativeTableForeignKeyColumn:
type: string
description: Must present when alternativeTable is not empty. It means the foreign key column to join with the primary key of the default table
# dbHint:
# type: string
# description: some additional info for how to use the dbColumn and dbQueryValue
description: the column name that can be used in the database query, see below for example
LoadGlobalAttributesRequest:
type: object
description: the request to load global attributes
properties:
attributes:
tableRequests:
type: array
items:
$ref: '#/components/schemas/GlobalAttributeKey'
defaultReadLockingType:
$ref: '#/components/schemas/AttributeReadLockingType'
tableReadLockingPolicyOverrides:
$ref: '#/components/schemas/TableReadRequest'
TableReadRequest:
type: object
properties:
tableName:
type: string
lockingPolicy:
$ref: '#/components/schemas/TableReadLockingPolicy'
columns:
type: array
description: set a different read policy per table to override the default locking type
items:
$ref: '#/components/schemas/TableReadLockingPolicy'
items:
$ref: '#/components/schemas/TableColumnDef'
LoadGlobalAttributeResponse:
type: object
description: the response for loading global attributes
properties:
attributes:
tableResponses:
type: array
items:
$ref: '#/components/schemas/GlobalAttributeValue'
TableReadLockingPolicy:
$ref: '#/components/schemas/TableReadResponse'
TableReadResponse:
type: object
required:
- readLockingType
- tableName
properties:
readLockingType:
$ref: '#/components/schemas/AttributeReadLockingType'
tableName:
type: string
AttributeReadLockingType:
columns:
type: array
items:
$ref: '#/components/schemas/TableColumnValue'
TableReadLockingPolicy:
type: string
enum:
- NO_LOCKING
Expand Down
18 changes: 12 additions & 6 deletions goapi/xdbapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ docs/AsyncStateExecuteRequest.md
docs/AsyncStateExecuteResponse.md
docs/AsyncStateWaitUntilRequest.md
docs/AsyncStateWaitUntilResponse.md
docs/AttributeReadLockingType.md
docs/AttributeWriteConflictMode.md
docs/CommandRequest.md
docs/CommandResults.md
Expand All @@ -21,8 +20,8 @@ docs/Context.md
docs/DefaultAPI.md
docs/EncodedObject.md
docs/GlobalAttributeConfig.md
docs/GlobalAttributeKey.md
docs/GlobalAttributeValue.md
docs/GlobalAttributeTableConfig.md
docs/GlobalAttributeTableRowUpdate.md
docs/LoadGlobalAttributeResponse.md
docs/LoadGlobalAttributesRequest.md
docs/LocalQueueCommand.md
Expand All @@ -45,7 +44,11 @@ docs/StateDecision.md
docs/StateFailureRecoveryOptions.md
docs/StateFailureRecoveryPolicy.md
docs/StateMovement.md
docs/TableColumnDef.md
docs/TableColumnValue.md
docs/TableReadLockingPolicy.md
docs/TableReadRequest.md
docs/TableReadResponse.md
docs/ThreadCloseDecision.md
docs/ThreadCloseType.md
docs/TimerCommand.md
Expand All @@ -61,16 +64,15 @@ model_async_state_execute_request.go
model_async_state_execute_response.go
model_async_state_wait_until_request.go
model_async_state_wait_until_response.go
model_attribute_read_locking_type.go
model_attribute_write_conflict_mode.go
model_command_request.go
model_command_results.go
model_command_waiting_type.go
model_context.go
model_encoded_object.go
model_global_attribute_config.go
model_global_attribute_key.go
model_global_attribute_value.go
model_global_attribute_table_config.go
model_global_attribute_table_row_update.go
model_load_global_attribute_response.go
model_load_global_attributes_request.go
model_local_queue_command.go
Expand All @@ -93,7 +95,11 @@ model_state_decision.go
model_state_failure_recovery_options.go
model_state_failure_recovery_policy.go
model_state_movement.go
model_table_column_def.go
model_table_column_value.go
model_table_read_locking_policy.go
model_table_read_request.go
model_table_read_response.go
model_thread_close_decision.go
model_thread_close_type.go
model_timer_command.go
Expand Down
9 changes: 6 additions & 3 deletions goapi/xdbapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,15 @@ Class | Method | HTTP request | Description
- [AsyncStateExecuteResponse](docs/AsyncStateExecuteResponse.md)
- [AsyncStateWaitUntilRequest](docs/AsyncStateWaitUntilRequest.md)
- [AsyncStateWaitUntilResponse](docs/AsyncStateWaitUntilResponse.md)
- [AttributeReadLockingType](docs/AttributeReadLockingType.md)
- [AttributeWriteConflictMode](docs/AttributeWriteConflictMode.md)
- [CommandRequest](docs/CommandRequest.md)
- [CommandResults](docs/CommandResults.md)
- [CommandWaitingType](docs/CommandWaitingType.md)
- [Context](docs/Context.md)
- [EncodedObject](docs/EncodedObject.md)
- [GlobalAttributeConfig](docs/GlobalAttributeConfig.md)
- [GlobalAttributeKey](docs/GlobalAttributeKey.md)
- [GlobalAttributeValue](docs/GlobalAttributeValue.md)
- [GlobalAttributeTableConfig](docs/GlobalAttributeTableConfig.md)
- [GlobalAttributeTableRowUpdate](docs/GlobalAttributeTableRowUpdate.md)
- [LoadGlobalAttributeResponse](docs/LoadGlobalAttributeResponse.md)
- [LoadGlobalAttributesRequest](docs/LoadGlobalAttributesRequest.md)
- [LocalQueueCommand](docs/LocalQueueCommand.md)
Expand All @@ -127,7 +126,11 @@ Class | Method | HTTP request | Description
- [StateFailureRecoveryOptions](docs/StateFailureRecoveryOptions.md)
- [StateFailureRecoveryPolicy](docs/StateFailureRecoveryPolicy.md)
- [StateMovement](docs/StateMovement.md)
- [TableColumnDef](docs/TableColumnDef.md)
- [TableColumnValue](docs/TableColumnValue.md)
- [TableReadLockingPolicy](docs/TableReadLockingPolicy.md)
- [TableReadRequest](docs/TableReadRequest.md)
- [TableReadResponse](docs/TableReadResponse.md)
- [ThreadCloseDecision](docs/ThreadCloseDecision.md)
- [ThreadCloseType](docs/ThreadCloseType.md)
- [TimerCommand](docs/TimerCommand.md)
Expand Down
Loading

0 comments on commit 31b9161

Please sign in to comment.