Skip to content

Conversation

@astelmashenko
Copy link
Member

@astelmashenko astelmashenko commented Jan 13, 2026

A custom broker implementation consists of few components:

  1. Feature/natsjs broker step1 #715 broker controller, to be able to specify NatsJetstreamBroker class for a broker CRD
  2. added trigger controller and reconciler #716 trigger controller, to receive events for eventing triggers which are subscribed to the NatsJetstreamBroker class and reconcile subscriptions to JetStream
  3. ingress, which accepts http requests to broker and stores it into JetStream stream storage
  4. filter, which creates consumers to JetStream, get messages, filter them out and sends to targets according to triggers configuration
  5. configuration is a set of yaml files describe CRD, service accounts, roles and permissions of above components
  6. e2e tests/docs/examples

Custom broker implemnetation step2: trigger controller

Brokers work with eventing triggers, since there custom broker class for NatsJetsream we need to reac when triggers are created/updated/deleted for brokers with the new custom broker class. An example of broker trigger.

Broker:

apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
  name: example-broker
  annotations:
    eventing.knative.dev/broker.class: NatsJetStreamBroker

Trigger:

apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: exact-filter-trigger
  namespace: default
spec:
  broker: example-broker
  filters:
    - exact:
        type: com.example.order.created
  subscriber:
    ref:
      apiVersion: v1
      kind: Service
      name: order-processor

There are two main files: pkg/broker/trigger/controller.go and pkg/broker/trigger/reconciler.go
Trigger controller loads nats conn options, subscribes to events from trigger and broker CRD filtering by broker class to react on CRD changes; and create a reconciler.

Trigger reconciler cheks trigger related things: broker status, subscriber, dlq, etc and updates trigger conditions and overall status. JetStream specific is it checks if a stream exists, and creates/updates a consumer for the Nats stream. Consumer configuration is based on Trigger spec.Delivery, to utilize retries based on JetStream consumer features, instead of in-memory retries, it will be visible in future PR related to filter.

@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 13, 2026
@knative-prow
Copy link

knative-prow bot commented Jan 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: astelmashenko

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 13, 2026
@knative-prow knative-prow bot requested review from dan-j and matzew January 13, 2026 20:43
@astelmashenko astelmashenko removed the request for review from dan-j January 13, 2026 20:44
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 42.30769% with 120 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.53%. Comparing base (1f2f843) to head (4864918).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/broker/trigger/reconciler.go 54.01% 61 Missing and 2 partials ⚠️
pkg/broker/trigger/controller.go 20.00% 56 Missing ⚠️
cmd/broker/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #716      +/-   ##
==========================================
+ Coverage   30.81%   31.53%   +0.72%     
==========================================
  Files          53       55       +2     
  Lines        3096     3304     +208     
==========================================
+ Hits          954     1042      +88     
- Misses       2074     2192     +118     
- Partials       68       70       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@knative-prow knative-prow bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 14, 2026
@astelmashenko astelmashenko marked this pull request as ready for review January 14, 2026 09:39
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 14, 2026
@knative-prow knative-prow bot requested review from Leo6Leo and aliok January 14, 2026 09:39
@astelmashenko
Copy link
Member Author

/assign @Cali0707

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants