Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Heads-up: potential issue with use of "source" in filters? #74

@jmcx

Description

@jmcx

I'm calling this a heads-up because I'd like to finish the proposal for event registry to properly explain.

But the basic idea is I think we need to clarify what an event is from the user's perspective (and document it in our docs etc) and am thinking we could more explicitly align with CloudEvents, and include the event's source and type as attributes the user knows about and can manipulate.

Current behaviour
Currently, the CLI seems to match the value of source with the name of the source component, so if I create a source called foo-webhooksource, then I can create a Trigger with --source foo-webhooksource.

Potential issue
To illustrate, does this fall apart when I'm using a CloudEvents source? With CloudEvents source, I can define the type and source of my event at runtime as an attribute in the context metadata, e.g. type = mycustomtypeand source = mycustomruntimesource. And then I might want to filter on this source value in a Trigger, not the name of the CloudEventsSource component I created. E.g.:

% tmcli create source cloudevents --name foo-cloudeventssource
% tmcli create target cloudevents --name foo-cloudeventstarget --endpoint https://env1minz9xsqi.x.pipedream.net
% tmcli create trigger --target foo-cloudeventstarget --sources mycustomruntimesource
2022/10/14 10:08:28 event types filter: event producer "mycustomruntimesource" is not available

BTW I still get an issue when trying to use the source component name:

% tmcli create trigger --target foo-cloudeventstarget --sources foo-cloudeventssource
2022/10/14 11:17:50 event types filter: "foo-cloudeventssource" event types: event types: unexpected end of JSON input

So essentially, maybe source is not the name of the source component, but something that more generally describes what external system the event came from.

So as a user, if I start working with a Broker locally and I know there are events coming from Salesforce, I can lookup the value of source for events coming from Salesforce in the Registry. This would be independent of the name of the SalesforceSource component being used. That means my definitions of Triggers and Rules aren't coupled to component names, but to Event types and schemas, events being the "contract" between producer and consumer.

In terms of the "default events schemas" that TriggerMesh knows about (e.g. that Fran is adding in the CRDs), we could also hardcode a value for source when it makes sense, alongside the type and description and payload schema as he has started doing. So e.g. for SQS, we could have the following predefined schema:

{
  "type": "com.amazon.sqs.message",
  "source": "com.amazon.sqs",
  "schema": "https://raw.githubusercontent.com/triggermesh/triggermesh/main/schemas/com.amazon.sqs.message.json",
  "description": ""
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions