ba919305c2
Features: - Unified Go binary running Task Service, Agent Manager, and Orchestrator - SQLite persistence for boards, columns, and tasks - Docker-based agent execution with ACP message streaming - Augment Agent integration with session resumption support - RESTful API for all operations (port 8080) - In-memory event bus for service communication Architecture: - cmd/kandev: Single entry point for all services - internal/task: Task, board, and column management - internal/agent: Docker container lifecycle and ACP streaming - internal/orchestrator: Agent coordination and monitoring - internal/events: In-memory pub/sub event bus Documentation: - README.md: Project overview and quick start - docs/ARCHITECTURE.md: System architecture (current + planned) - docs/GETTING_STARTED.md: Development setup guide - docs/IMPLEMENTATION_PLAN.md: Original microservices plan - backend/NEXT_STEPS.md: Development roadmap
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
// Package bus provides event bus abstractions for Kandev.
|
|
package bus
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Event represents a message on the event bus
|
|
type Event struct {
|
|
ID string `json:"id"`
|
|
Type string `json:"type"`
|
|
Source string `json:"source"` // Service that produced the event
|
|
Timestamp time.Time `json:"timestamp"`
|
|
Data map[string]interface{} `json:"data"`
|
|
}
|
|
|
|
// NewEvent creates a new event with a UUID and current timestamp
|
|
func NewEvent(eventType, source string, data map[string]interface{}) *Event {
|
|
return &Event{
|
|
ID: uuid.New().String(),
|
|
Type: eventType,
|
|
Source: source,
|
|
Timestamp: time.Now().UTC(),
|
|
Data: data,
|
|
}
|
|
}
|
|
|
|
// EventHandler is a function that handles an event
|
|
type EventHandler func(ctx context.Context, event *Event) error
|
|
|
|
// Subscription represents an active subscription
|
|
type Subscription interface {
|
|
Unsubscribe() error
|
|
IsValid() bool
|
|
}
|
|
|
|
// EventBus interface for event bus operations
|
|
type EventBus interface {
|
|
// Publish sends an event to a subject
|
|
Publish(ctx context.Context, subject string, event *Event) error
|
|
|
|
// Subscribe creates a subscription to a subject pattern
|
|
Subscribe(subject string, handler EventHandler) (Subscription, error)
|
|
|
|
// QueueSubscribe creates a queue subscription for load balancing
|
|
QueueSubscribe(subject, queue string, handler EventHandler) (Subscription, error)
|
|
|
|
// Request sends a request and waits for a response (with timeout)
|
|
Request(ctx context.Context, subject string, event *Event, timeout time.Duration) (*Event, error)
|
|
|
|
// Close closes the connection
|
|
Close()
|
|
|
|
// IsConnected returns connection status
|
|
IsConnected() bool
|
|
}
|
|
|