Files
zeekayandGitHub 5b5cf9e9db feat: merge AgentField control plane + SDKs as Hanzo Agents (#1)
Transforms hanzoai/agents from a marketplace config repo into a full
agent orchestration platform by merging the AgentField infrastructure:

- Go control plane (K8s-like agent orchestration, service mesh, DAG workflows)
- Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC)
- TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows)
- Go SDK (idiomatic agent builder + client)
- React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI)
- Docker/K8s/Helm deployment configs
- Examples: hello world, deep research, RAG, simulation, benchmarks
- Functional test suite across Python/Go/TypeScript

All references rebranded: AgentField → Hanzo Agents
- Module: github.com/hanzoai/agents/control-plane
- Python: hanzo_agents
- TypeScript: @hanzo/agents
- Go: github.com/hanzoai/agents/sdk/go
- Env vars: HANZO_AGENTS_*
- Config: hanzo-agents.yaml

Previous marketplace configs moved to config/ directory.
2026-02-09 18:53:09 -08:00

62 lines
1.4 KiB
Go

package events
import "sync"
// EventBus provides a generic pub/sub channel for real-time updates.
type EventBus[T any] struct {
subscribers map[string]chan T
mutex sync.RWMutex
bufferSize int
}
// NewEventBus constructs an EventBus with a default buffer for subscriber channels.
func NewEventBus[T any]() *EventBus[T] {
return &EventBus[T]{
subscribers: make(map[string]chan T),
bufferSize: 100,
}
}
// Subscribe registers a subscriber and returns a channel to receive events.
func (bus *EventBus[T]) Subscribe(subscriberID string) chan T {
bus.mutex.Lock()
defer bus.mutex.Unlock()
ch := make(chan T, bus.bufferSize)
bus.subscribers[subscriberID] = ch
return ch
}
// Unsubscribe removes the subscriber and closes the channel.
func (bus *EventBus[T]) Unsubscribe(subscriberID string) {
bus.mutex.Lock()
defer bus.mutex.Unlock()
if ch, ok := bus.subscribers[subscriberID]; ok {
close(ch)
delete(bus.subscribers, subscriberID)
}
}
// Publish delivers an event to all subscribers without blocking.
func (bus *EventBus[T]) Publish(event T) {
bus.mutex.RLock()
defer bus.mutex.RUnlock()
for id, ch := range bus.subscribers {
select {
case ch <- event:
default:
// drop event for slow subscriber to avoid blocking
_ = id
}
}
}
// SubscriberCount returns number of active subscribers.
func (bus *EventBus[T]) SubscriberCount() int {
bus.mutex.RLock()
defer bus.mutex.RUnlock()
return len(bus.subscribers)
}