eventbus

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package eventbus provides an in-process pub/sub system for domain events. Events are emitted by the service layer after successful mutations and consumed by SSE streams, webhook dispatch, and MCP notifications.

Index

Constants

View Source
const (
	EventTaskCreated       = "task.created"
	EventTaskUpdated       = "task.updated"
	EventTaskTransitioned  = "task.transitioned"
	EventTaskDeleted       = "task.deleted"
	EventTaskAssigned      = "task.assigned"
	EventTaskCommented     = "task.commented"
	EventCommentEdited     = "comment.edited"
	EventDependencyAdded   = "dependency.added"
	EventDependencyRemoved = "dependency.removed"
	EventAttachmentAdded   = "attachment.added"
	EventAttachmentRemoved = "attachment.removed"
)

Event type constants matching the PRD §7.1 webhook event types.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActorRef

type ActorRef struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

ActorRef identifies the actor who caused the event.

type BoardRef

type BoardRef struct {
	Slug string `json:"slug"`
	Name string `json:"name"`
}

BoardRef identifies the board the event belongs to.

type Event

type Event struct {
	Type      string        `json:"event"`
	Timestamp time.Time     `json:"timestamp"`
	Actor     ActorRef      `json:"actor"`
	Board     BoardRef      `json:"board"`
	Before    *TaskSnapshot `json:"before,omitempty"`
	After     *TaskSnapshot `json:"after,omitempty"`
	Detail    any           `json:"detail,omitempty"`
}

Event represents a domain event emitted after a successful mutation.

For task events, Before and After carry snapshots of the task state before and after the mutation:

  • Create: Before=nil, After=snapshot
  • Update: Before=snap, After=snapshot
  • Transition: Before=snap, After=snapshot
  • Delete: Before=snap, After=nil
  • Comment/Dep/Attachment: Before=nil, After=snapshot (current state)

type EventBus

type EventBus struct {
	// contains filtered or unexported fields
}

EventBus is an in-process pub/sub system. Mutations publish events; subscribers (SSE, webhooks, MCP) receive them on buffered channels. Publishing never blocks — if a subscriber's buffer is full, the oldest event is dropped.

func New

func New() *EventBus

New creates an EventBus with no subscribers.

func (*EventBus) Publish

func (b *EventBus) Publish(event Event)

Publish sends an event to all subscribers. Non-blocking — if a subscriber's buffer is full, the oldest event is dropped to make room.

func (*EventBus) Subscribe

func (b *EventBus) Subscribe() *Subscription

Subscribe creates a new subscription with a buffered channel.

type Subscription

type Subscription struct {
	C <-chan Event
	// contains filtered or unexported fields
}

Subscription receives events on a buffered channel.

func (*Subscription) Cancel

func (s *Subscription) Cancel()

Cancel removes the subscription from the bus and drains its channel.

type TaskSnapshot

type TaskSnapshot struct {
	Ref      string  `json:"ref"`
	Num      int     `json:"num"`
	Title    string  `json:"title"`
	State    string  `json:"state"`
	Priority string  `json:"priority,omitempty"`
	Assignee *string `json:"assignee,omitempty"`
}

TaskSnapshot is a point-in-time snapshot of a task's display-relevant fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL