Add dynamic handler management #13

Merged
xdrm-brackets merged 12 commits from feature/dynamic-handler-signature into 0.3.0 2020-03-29 15:10:06 +00:00

handlers are now managed by the dynamic package :

  • handler's signature is func(inputStruct) (outputStruct, api.Error)
    • inputStruct contains input fields using the name from the field name, optional fields are pointers
    • outputStruct contains output fields following the same rules as inputStruct except optional types are disallowed
    • if no in input, inputStruct can be omitted, resulting in func() (outputStruct, api.Error)
    • if no output, outputStruct can be omitted, resulting in func(inputStruct) api.Error
    • as a result, if both input and output are empty; handler signature is func() api.Error

datatypes interface contains a Type() reflect.Type method to tell what type the result will be cast into :

  • handler inputStruct fields are checked against datatypes to check if datatype.Type() is convertible to inputStruct.field
  • same for output even if no cast is made; it serves as a guard to make sure the contract (config) is satisfied by the implementation.

config parses the out field to check for conflicts and find datatypes.

handlers are now managed by the `dynamic` package : - handler's signature is `func(inputStruct) (outputStruct, api.Error)` - `inputStruct` contains input fields using the name from the field `name`, optional fields are pointers - `outputStruct` contains output fields following the same rules as `inputStruct` except optional types are disallowed - if no in input, `inputStruct` can be omitted, resulting in `func() (outputStruct, api.Error)` - if no output, `outputStruct` can be omitted, resulting in `func(inputStruct) api.Error` - as a result, if both input and output are empty; handler signature is `func() api.Error` datatypes interface contains a `Type() reflect.Type` method to tell what type the result will be cast into : - handler `inputStruct` fields are checked against datatypes to check if `datatype.Type()` is convertible to `inputStruct.field` - same for output even if no cast is made; it serves as a guard to make sure the contract (config) is satisfied by the implementation. config parses the `out` field to check for conflicts and find datatypes.
xdrm-brackets closed this pull request 2020-03-29 15:10:05 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: go/aicra#13
No description provided.