Skip to content
This repository has been archived by the owner on Jun 14, 2021. It is now read-only.

[RFC] Pub/Sub extensions #93

Open
aimed opened this issue Jul 2, 2019 · 0 comments
Open

[RFC] Pub/Sub extensions #93

aimed opened this issue Jul 2, 2019 · 0 comments
Labels

Comments

@aimed
Copy link
Owner

aimed commented Jul 2, 2019

Extend the OpenApi schema to support PubSub. Defining PubSub inside of events allows us to generate typed clients that know how to subscribe to events. It furthermore allows to generate typed servers that understand what these events look like and how events can be published. For an example of the schema as well as the generated code see the sections below.

In addition to generating types and handling them in a type safe and validated way, defining the PubSub mechanism inside of the schema would enable deployment pipelines to automatically perform the necessary bootstrapping. E.g. A deployment pipeline could inspect the publishers section and then set up a new AWS Queue.

Requirements:

  • Support different PubSub mechanisms (e.g. local, SQS, SNS)

Related work:

Publishing describes how a service publishes events and what shape the events have.
Example publishing:

publishes:
  petShopEvents:
    schema:
        $ref: "#/components/events/PetShopEvent"
    sources:
      SNS:
        arn: {petShopEventsSNSArn}:pet-shop-events
        encoding: application/json
        variables:
          petShopEventsSNSArn:
            type: string

Subscriptions describe how the service connects to publishers. In the case of SNS/SQS a deployment pipeline could create the actual subscription on AWS while Slushy takes care of listening to the events and forwarding them to the appropriate endpoint.
Example subscription:
TODO

subscriptions:
  petShopEvents:
    SQS:
       arn: {petShopEventsSQSArn}:pet-shop-events
       # This references the SNS services this queue is subscribed to. It provides the url and the expected schema.
       SNS:
         # This publisher has write permissions
         permissions: ["SQS:SendMessage"]
         $ref: 'https://my-schemas/petShop/#/publishes/petShopEvents/SNS'

Example code generated:
TODO

@aimed aimed added the RFC label Jul 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant