{"modulePath":"github.com/QuantProcessing/exchanges","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package kernel\n\n## Variables\n\n```go\nvar (\n\tErrBackpressure     = errors.New(\"msgbus backpressure\")\n\tErrEndpointNotFound = errors.New(\"endpoint not found\")\n)\n```\n\n```go\nvar ErrComponentFaulted = errors.New(\"component faulted\")\n```\n\n## Types\n\n```go\ntype Clock interface {\n\tNow() time.Time\n\tAfter(time.Duration) \u003c-chan time.Time\n}\n```\n\n```go\ntype Component struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewComponent(id string, hooks ComponentHooks) *Component\n```\n\n```go\nfunc (c *Component) Degrade(err error)\n```\n\n```go\nfunc (c *Component) Fault(err error)\n```\n\n```go\nfunc (c *Component) Health() Health\n```\n\n```go\nfunc (c *Component) Kill(ctx context.Context) error\n```\n\n```go\nfunc (c *Component) Start(ctx context.Context) error\n```\n\n```go\nfunc (c *Component) State() ComponentState\n```\n\n```go\nfunc (c *Component) Stop(ctx context.Context) error\n```\n\n```go\ntype ComponentHooks struct {\n\tStart func(context.Context) error\n\tStop  func(context.Context) error\n\tKill  func(context.Context) error\n}\n```\n\n```go\ntype ComponentState string\n```\n\n```go\nconst (\n\tComponentStateInitialized ComponentState = \"initialized\"\n\tComponentStateStarting    ComponentState = \"starting\"\n\tComponentStateRunning     ComponentState = \"running\"\n\tComponentStateStopping    ComponentState = \"stopping\"\n\tComponentStateStopped     ComponentState = \"stopped\"\n\tComponentStateDegraded    ComponentState = \"degraded\"\n\tComponentStateFaulted     ComponentState = \"faulted\"\n)\n```\n\n```go\ntype EndpointHandler func(context.Context, Request) (Response, error)\n```\n\n```go\ntype Envelope struct {\n\tTopic         string\n\tMessage       any\n\tTimestamp     time.Time\n\tCorrelationID string\n}\n```\n\n```go\ntype Health struct {\n\tID        string\n\tState     ComponentState\n\tLastError string\n}\n```\n\n```go\ntype LiveClock struct{}\n```\n\n```go\nfunc (LiveClock) After(d time.Duration) \u003c-chan time.Time\n```\n\n```go\nfunc (LiveClock) Now() time.Time\n```\n\n```go\ntype MsgBus struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewMsgBus(cfg MsgBusConfig) *MsgBus\n```\n\n```go\nfunc (b *MsgBus) Publish(ctx context.Context, topic string, message any) error\n```\n\n```go\nfunc (b *MsgBus) RegisterEndpoint(endpoint string, handler EndpointHandler)\n```\n\n```go\nfunc (b *MsgBus) Request(ctx context.Context, endpoint string, payload any) (Response, error)\n```\n\n```go\nfunc (b *MsgBus) Stats() MsgBusStats\n```\n\n```go\nfunc (b *MsgBus) Subscribe(topic string, buffer int) Subscription\n```\n\n```go\ntype MsgBusConfig struct {\n\tClock         Clock\n\tDefaultBuffer int\n}\n```\n\n```go\ntype MsgBusStats struct {\n\tPublished int64\n\tDropped   int64\n}\n```\n\n```go\ntype Request struct {\n\tEndpoint      string\n\tPayload       any\n\tCorrelationID string\n\tTimestamp     time.Time\n}\n```\n\n```go\ntype Response struct {\n\tCorrelationID string\n\tPayload       any\n}\n```\n\n```go\ntype Subscription interface {\n\tC() \u003c-chan Envelope\n\tClose() error\n}\n```\n\n```go\ntype TestClock struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTestClock(start time.Time) *TestClock\n```\n\n```go\nfunc (c *TestClock) Advance(d time.Duration)\n```\n\n```go\nfunc (c *TestClock) After(d time.Duration) \u003c-chan time.Time\n```\n\n```go\nfunc (c *TestClock) Now() time.Time\n```\n\n","path":"github.com/QuantProcessing/exchanges/kernel","name":"kernel","synopsis":"","isRedistributable":true}
