How enercity/protoflow works
Protoflow is a Watermill-based event-processing library. The principal workflow is to configure and construct a Service, select a transport, register typed JSON/Protobuf or raw handlers, then start the router to consume messages and publish handler outputs. The README also documents middleware for validation, outbox, tracing, metrics, retries, poison queues, and recovery. Evidence is strongest for service wiring, handler conversion, publishing, and AWS/channel transports; several middleware capabilities are documented but their implementations were not excerpted.
Main entry points: service.go Service and router · libapi.go Public API · json.go JSON handlers · handlers_proto.go Protobuf registration
Components 21
Service setup
- Public API
libapi.go - Configuration
internal/runtime/config/config.go - Service and router
internal/runtime/service.go
Message handling
- Protobuf handlers
internal/runtime/handlers/proto.go - JSON handlers
internal/runtime/handlers/json.go - Protobuf registration
internal/runtime/handlers_proto.go - JSON registration
internal/runtime/handlers_json.go - Raw registration
internal/runtime/handlers_raw.go - Message metadata
internal/runtime/metadata/metadata.go - JSON codec
internal/runtime/jsoncodec/jsoncodec.go
Transport and publishing
- Event publishing
internal/runtime/publisher.go - Transport factory
internal/runtime/transport/factory.go - AWS SNS/SQS
internal/runtime/transport/aws.go - Go channel
internal/runtime/transport/channel.go
Cross-cutting runtime
- Middleware stack
internal/runtime/middleware.go - Logging adapters
internal/runtime/logging/logging.go - Runtime web UI
internal/runtime/webui.go
Other components
- Application developer
- Message broker
- Outbox store
- Payload validator
Connections 28
- Application developer → Public API: configures and registers
README.md - Public API → Service and router: constructs service
libapi.go - Service and router → Configuration: uses config
internal/runtime/service.go - Service and router → Transport factory: builds transport
internal/runtime/service.go - Transport factory → AWS SNS/SQS: dispatches AWS
internal/runtime/transport/factory.go - Transport factory → Go channel: dispatches channel
internal/runtime/transport/factory.go - AWS SNS/SQS → Message broker: publishes and consumes
internal/runtime/transport/aws.go - Go channel → Message broker: publishes and consumes
internal/runtime/transport/channel.go - Public API → Protobuf registration: registers protobuf
libapi.go - Public API → JSON registration: registers JSON
libapi.go - Public API → Raw registration: registers raw handler
libapi.go - Protobuf registration → Protobuf handlers: builds handler
internal/runtime/handlers_proto.go - JSON registration → JSON handlers: builds handler
internal/runtime/handlers_json.go - Protobuf handlers → Message metadata: converts metadata
internal/runtime/handlers/proto.go - JSON handlers → Message metadata: converts metadata
internal/runtime/handlers/json.go - JSON handlers → JSON codec: encodes payloads
internal/runtime/handlers/json.go - Protobuf registration → Service and router: registers handler
internal/runtime/handlers_proto.go - JSON registration → Service and router: registers handler
internal/runtime/handlers_json.go - Raw registration → Service and router: adds router handler
internal/runtime/handlers_raw.go - Service and router → Middleware stack: registers middleware
internal/runtime/service.go - Service and router → Logging adapters: adapts logger
internal/runtime/service.go - Service and router → Runtime web UI: starts web UI
- Public API → Event publishing: exposes publishing
libapi.go - Event publishing → Message metadata: sets message metadata
internal/runtime/publisher.go - Event publishing → Message broker: publishes event
internal/runtime/publisher.go - Service and router → Outbox store: accepts optional store
internal/runtime/service.go - Service and router → Payload validator: accepts optional validator
internal/runtime/service.go - Application developer → Service and router: starts service
README.md