Skip to content

Commit

Permalink
Merge pull request #95 from bancolombia/feature/fanout-and-batch
Browse files Browse the repository at this point in the history
feat: added fanout and batch message delivery
  • Loading branch information
juancgalvis authored Feb 4, 2025
2 parents 6e2e2db + 5ba16e7 commit 1ab15f0
Show file tree
Hide file tree
Showing 19 changed files with 1,229 additions and 190 deletions.
4 changes: 2 additions & 2 deletions channel-sender/config/config-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ channel_sender_ex:

# max time in seconds to wait the client to send the auth token
# before closing the channel
socket_idle_timeout: 30000
socket_idle_timeout: 90000

# Specifies the maximum time (in milliseconds) that the Elixir supervisor waits
# for child channel processes to terminate after sending it an exit signal
Expand Down Expand Up @@ -78,7 +78,7 @@ channel_sender_ex:
# for more information about the kubernetes configuration with libcluser

logger:
level: info
level: debug



167 changes: 153 additions & 14 deletions channel-sender/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ paths:
/create:
post:
tags:
- /ext/channel/
- /ext/channel
summary: Create Channel and session
description: |
By passing in the appropriate options, you can regisster a new channel in the system
By passing in the appropriate options, you can register a new channel in the system
operationId: createChannel
requestBody:
description: Channel to create
Expand All @@ -38,40 +38,107 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/InvalidRequest'
$ref: '#/components/schemas/InvalidBodyResponse'

/deliver_message:
post:
tags:
- /ext/channel/
summary: Deliver an event from a message
description: Deliver an event message to a previusly registered channel_ref
- /ext/channel
summary: Deliver an event message to a channel or group of channels
description: Deliver an event message to a previusly registered channel_ref, or deliver a message to all channels related to an specific app_ref or user_ref
operationId: deliverMessage
requestBody:
description: "Triggers internal workflow to deliver message. The message may not be delivered immediately, or not at all. Depends if the channel_ref was previusly registered. The message_data schema is not enforced, but its recommeded to use CloudEvents."
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
oneOf:
- $ref: '#/components/schemas/Message'
- $ref: '#/components/schemas/AppMessage'
- $ref: '#/components/schemas/UserMessage'
responses:
"202":
description: Ok
content:
application/json:
schema:
type: object
properties:
result:
type: string
example: Ok
$ref: '#/components/schemas/SuccessResponse'
"400":
description: Bad request due to invalid body or missing required fields
content:
application/json:
schema:
$ref: '#/components/schemas/InvalidRequest'
$ref: '#/components/schemas/InvalidBodyResponse'

/deliver_batch:
post:
tags:
- /ext/channel
summary: Batch deliver up to 10 event messages
description: Deliver event messages to a group of channel_refs
operationId: deliverBatchMessages
requestBody:
description: ""
content:
application/json:
schema:
$ref: '#/components/schemas/Messages'
responses:
"202":
description: If all messages were accepted SuccessResponse is returned. If some messages were rejected PartialSuccessResponse is returned.
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/SuccessResponse'
- $ref: '#/components/schemas/PartialSuccessResponse'
"400":
description: Bad request due to invalid body
content:
application/json:
schema:
$ref: '#/components/schemas/InvalidBodyResponse'
/:
delete:
tags:
- /ext/channel
summary: Perform a graceful shutdown of a channel processes
description: Perform a graceful shutdown of a channel process and related socket process, if any.
operationId: stopChannel
parameters:
- name: channel_ref
in: query
description: The channel_ref to be stopped
required: true
schema:
type: string
example: beec634503c238f5b84f737275bfd4ba.855b8193bb6f419381eac6cc087aea3f
responses:
"200":
description: If the operation is performed succesfully.
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/SuccessResponse'
"400":
description: Bad request due to missing required parameter
content:
application/json:
schema:
$ref: '#/components/schemas/InvalidBodyResponse'

components:
schemas:
Messages:
type: object
required:
- messages
properties:
messages:
type: array
items:
$ref: '#/components/schemas/Message'
Message:
required:
- channel_ref
Expand All @@ -97,6 +164,56 @@ components:
event_name:
type: string
example: event.productCreated
AppMessage:
required:
- app_ref
- event_name
- message_data
- message_id
type: object
properties:
app_ref:
type: string
example: app01
message_id:
type: string
format: uuid
example: d290f1ee-6c54-4b01-90e6-d701748f0851
correlation_id:
type: string
format: uuid
example: d290f1ee-6c54-4b01-90e6-d701748f0851
message_data:
type: object
example: {"product_id": "1234", "product_name": "product name"}
event_name:
type: string
example: event.productCreated
UserMessage:
required:
- user_ref
- event_name
- message_data
- message_id
type: object
properties:
user_ref:
type: string
example: user.1
message_id:
type: string
format: uuid
example: d290f1ee-6c54-4b01-90e6-d701748f0851
correlation_id:
type: string
format: uuid
example: d290f1ee-6c54-4b01-90e6-d701748f0851
message_data:
type: object
example: {"product_id": "1234", "product_name": "product name"}
event_name:
type: string
example: event.productCreated
ChannelRequest:
required:
- application_ref
Expand All @@ -121,7 +238,29 @@ components:
channel_secret:
type: string
example: SFMyNTY.g2gDaANtAAAAQWJlZWM2MzQ1MDNjMjM4ZjViODRmNzM3Mjc1YmZkNGJhLjg1NWI4MTkzYmI2ZjQxOTM4MWVhYzZjYzA4N2FlYTNmbQAAAAZ4eHh4eHhtAAAAB3h4eHh4eHhuBgDbcXMIlAFiAAFRgA.......
InvalidRequest:
SuccessResponse:
type: object
properties:
result:
type: string
example: Ok
PartialSuccessResponse:
type: object
properties:
result:
type: string
example: partial-success
accepted_messages:
type: integer
example: 5
rejected_messages:
type: integer
example: 2
discarded:
type: array
items:
$ref: '#/components/schemas/Message'
InvalidBodyResponse:
required:
- error
- request
Expand Down
Loading

0 comments on commit 1ab15f0

Please sign in to comment.