Skip to content

Commit

Permalink
Updated openapi spec
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Zhang <jim.zhang@kaleido.io>
  • Loading branch information
jimthematrix committed Jan 13, 2022
1 parent fd8372a commit e96ad59
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/events/api/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
EventPayloadType_Bytes = "bytes" // default data type of the event payload, no special processing is done before returning to the subscribing client
EventPayloadType_String = "string" // event payload will be an UTF-8 encoded string
EventPayloadType_StringifiedJSON = "stringifiedJSON" // event payload will be a structured map with UTF-8 encoded string values
EventPayloadType_JSON = "json" // equivalent to "stringifiedJSON"
)

// persistedFilter is the part of the filter we record to storage
Expand Down Expand Up @@ -52,7 +53,7 @@ type SubscriptionInfo struct {
Signer string `json:"signer"`
FromBlock string `json:"fromBlock,omitempty"`
Filter persistedFilter `json:"filter"`
PayloadType string `json:"payloadType,omitempty"` // optional. data type of the payload bytes; "bytes", "string" or "stringifiedJSON". Default to "bytes"
PayloadType string `json:"payloadType,omitempty"` // optional. data type of the payload bytes; "bytes", "string" or "stringifiedJSON/json". Default to "bytes"
}

// GetID returns the ID (for sorting)
Expand Down
2 changes: 1 addition & 1 deletion internal/events/evtprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (ep *evtProcessor) processEventEntry(subInfo *api.SubscriptionInfo, entry *
switch payloadType {
case api.EventPayloadType_String:
entry.Payload = string(entry.Payload.([]byte))
case api.EventPayloadType_StringifiedJSON:
case api.EventPayloadType_StringifiedJSON, api.EventPayloadType_JSON:
structuredMap := make(map[string]interface{})
err := json.Unmarshal(entry.Payload.([]byte), &structuredMap)
if err != nil {
Expand Down
36 changes: 35 additions & 1 deletion openapi/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,44 @@ components:
enum:
- websocket
- webhook
default: websocket
websocket:
oneOf:
- $ref: "#/components/schemas/websocket_info"
- $ref: "#/components/schemas/webhook_info"
suspended:
type: boolean
default: false
description: if set to 'true', the stream will be suspended
batchSize:
type: integer
default: 1
description: how many events should be packed in each event batch to deliver to the client. Range is 1-1000
batchTimeoutMS:
type: integer
default: 5000
description: if there are pending events to deliver, but the batch size has not been reached, this is the maximum amount of milliseconds to wait before delivering the current batch
errorHandling:
type: string
description: when the delivery should be blocked when the event listener client failed to take delivery, or skip and continue
enum:
- block
- skip
default: skip
retryTimeoutSec:
type: integer
description: total amount of time (in seconds) to retry a failed event delivery
blockedReryDelaySec:
type: integer
description: amount of time (in seconds) to wait before retrying a failed delivery
timestamps:
type: boolean
default: false
description: Chaincode events from Fabric do not contain timestamps. If set to 'true', FabConnect to make a call to Fabric to download the block to obtain the timestamp, and set on the event. Note doing this incurs time overhead in events processing
timestampCacheSize:
type: integer
default: 1000
description: The size of the internal cache for the blocknumber <-> timestamp map
subscription_input:
type: "object"
properties:
Expand All @@ -416,7 +450,7 @@ components:
type: string
default: string
enum:
- stringifiedJSON
- json
- string
filter:
type: object
Expand Down

0 comments on commit e96ad59

Please sign in to comment.