connector
The Connector is the most fundamental construct of the framework, providing key capabilities to Microbus microservices:
- Startup and shutdown with corresponding callbacks
- Service hostname and a random instance ID, both used to address the microservice
- Connectivity to NATS
- HTTP-like communication over NATS, unicast (request/response) and multicast (pub/sub)
- Structured logging
- Configuration
- Tickers to execute jobs on a recurring basis
- Distributed cache
- Embedded resource files and strings
- Distributed tracing
- Authorization
The connector package includes a separate source file for each functional area of the microservice. All these source files implement the same Connector class.
config.gois responsible for fetching config values from the configurator core microserviceconnector.godefines theConnectorstruct and provides a few getters and setterscontrol.godeals with subscribing and handling the control messages on the reserved port:888fragment.goorchestrates the fragmentation and defragmentation of large requests and responseslifecycle.goimplements theStartupandShutdownlogic, as well asGoandParallelfor running code in goroutineslogger.goprovides a JSON logger for the microservicemetrics.gocollects metrics with OpenTelemetrymuffler.gois an OpenTelemetry span sampler that excludes noisy spanspublish.godeals with outbound messagingres.gomanages the loading of files and localized strings from a resourceFSselectiveprocessor.gois an OpenTelemetry processor of tracing spans that exports only spans that are explicitly selectedsubjects.gocrafts the NATS subjects (topics) that a microservice subscribes to or publishes tosubscribe.godeals with inbound message handlingtime.gointroduces tickers to the microservicetracer.gosupports distributed tracing with OpenTelemetry