Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: PubSub triggers #98

Closed
orthros opened this issue Sep 27, 2019 · 0 comments
Closed

feature: PubSub triggers #98

orthros opened this issue Sep 27, 2019 · 0 comments
Assignees
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@orthros
Copy link
Contributor

orthros commented Sep 27, 2019

Similarly to Cron Support; there are events from other services (e.g. Kokoro) whose job completion may trigger the invocation of a bot.

Proposed changes:

Bots

  • A bot that wants to subscribe to PubSub triggers needs to include a topic file in their source folder
  • A bot that wishes to subscribe to PubSub triggers needs to subscribe to the topic.repository event in the appFn:
 app.on('topic.repository', async context => {});

Infrastructure

  • The build process will inspect all bots && if a bot has a topic file and no corresponding PubSub topic it will
    • Create a PubSub topic whose name is the bot name
    • Create a Push Subscription for the topic and point it at the Cloud Run serverless-scheduler-proxy instance. NOTE: This will use a custom ServiceAccount that has permissions to invoke the CloudRun instance.

serverless-scheduler-proxy

  • Move the cron processing endpoint to /cron (was /)
  • Add a new endpoint /pubsub which handles incoming PubSub push messages of form:
// PubSubMessage is the payload of a Pub/Sub event.
type PubSubMessage struct {
        Message struct {
                Data []byte `json:"data,omitempty"`
                ID   string `json:"id"`
        } `json:"message"`
        Subscription string `json:"subscription"`
}
  • This handler parses the name of the bot from the Subscription field, and creates a new HTTP request to the bot/Cloud Function whose name is in the subscription. This request will be signed using the signing key of the bot in the x-hub-signature header, and the x-github-event header will be topic.repository
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Sep 28, 2019
@chingor13 chingor13 added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Oct 1, 2019
@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label Oct 1, 2019
@orthros orthros self-assigned this Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants