# robby031/gochannel architecture

> Architecture diagram of the GitHub repository robby031/gochannel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/robby031/gochannel
- Repository: https://github.com/robby031/gochannel

## Overview

gochannel is a small, generic, thread-safe Go publish/subscribe library. Producers publish by topic or broadcast; the bus dispatches non-blockingly to buffered subscriber channels, dropping messages for full buffers and exposing drop counts and a callback. Subscribers can be removed explicitly or through context cancellation, and Close shuts down subscriptions. The runtime is implemented in gochannel.go; the graph focuses on its API and core behavior rather than delivery tooling.

Main entry points: [`gochannel.go`](https://github.com/robby031/gochannel/blob/main/gochannel.go) (Typed Bus API)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_producer(("Producer"))
node_bus["Typed Bus API<br/>[gochannel.go]"]
node_registry["Topic Registry<br/>[gochannel.go]"]
node_dispatch["Message Dispatch<br/>[gochannel.go]"]
node_subscriber(("Subscriber"))
node_context(("Context Cancellation"))
node_lifecycle["Subscription Lifecycle<br/>[gochannel.go]"]
node_drop["Drop Monitoring<br/>[gochannel.go]"]

node_producer -->|"publishes"| node_bus
node_bus -->|"registers subscriptions"| node_registry
node_bus -->|"dispatches messages"| node_dispatch
node_dispatch -->|"sends messages"| node_subscriber
node_subscriber -->|"unsubscribes"| node_bus
node_context -->|"triggers cleanup"| node_lifecycle
node_lifecycle -->|"removes subscriber"| node_registry
node_bus -->|"closes subscriptions"| node_lifecycle
node_dispatch -->|"records drops"| node_drop

click node_bus "https://github.com/robby031/gochannel/blob/main/gochannel.go"
click node_registry "https://github.com/robby031/gochannel/blob/main/gochannel.go"
click node_dispatch "https://github.com/robby031/gochannel/blob/main/gochannel.go"
click node_lifecycle "https://github.com/robby031/gochannel/blob/main/gochannel.go"
click node_drop "https://github.com/robby031/gochannel/blob/main/gochannel.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_producer,node_subscriber,node_context toneIndigo
class node_bus toneMint
class node_registry,node_dispatch,node_lifecycle,node_drop toneTeal
```

## Components

### Other components

- **Producer**
- [Typed Bus API](https://github.com/robby031/gochannel/blob/main/gochannel.go): `gochannel.go`
- [Topic Registry](https://github.com/robby031/gochannel/blob/main/gochannel.go): `gochannel.go`
- [Message Dispatch](https://github.com/robby031/gochannel/blob/main/gochannel.go): `gochannel.go`
- **Subscriber**
- **Context Cancellation**
- [Subscription Lifecycle](https://github.com/robby031/gochannel/blob/main/gochannel.go): `gochannel.go`
- [Drop Monitoring](https://github.com/robby031/gochannel/blob/main/gochannel.go): `gochannel.go`

## Connections

- Producer → Typed Bus API: publishes (evidence: `README.md`)
- Typed Bus API → Topic Registry: registers subscriptions (evidence: `gochannel.go`)
- Typed Bus API → Message Dispatch: dispatches messages (evidence: `gochannel.go`)
- Message Dispatch → Subscriber: sends messages (evidence: `gochannel.go`)
- Subscriber → Typed Bus API: unsubscribes (evidence: `README.md`)
- Context Cancellation → Subscription Lifecycle: triggers cleanup (evidence: `gochannel.go`)
- Subscription Lifecycle → Topic Registry: removes subscriber (evidence: `gochannel.go`)
- Typed Bus API → Subscription Lifecycle: closes subscriptions (evidence: `gochannel.go`)
- Message Dispatch → Drop Monitoring: records drops (evidence: `gochannel.go`)
