Documentation ¶
Overview ¶
Package lifecycle provides events that services in the Choria eco system emit during startup, shutdown, provisioning and general running.
These events can be used by other tools to react to events or monitor the running of a Chroia network.
A library to view the events received from the network and one to create a running tally of the count and versions of nodes on your network.
Index ¶
- func EventTypeNames() []string
- func PublishEvent(e Event, conn inter.RawNATSConnector) error
- func ToCloudEventV1(e Event) cloudevents.Event
- func View(ctx context.Context, opt *ViewOptions) error
- func WriteEvents(ctx context.Context, opt *ViewOptions) error
- type AliveEvent
- func (e *AliveEvent) Component() string
- func (e *AliveEvent) Format() Format
- func (e *AliveEvent) ID() string
- func (e *AliveEvent) Identity() string
- func (e *AliveEvent) Protocol() string
- func (e *AliveEvent) SetComponent(c string)
- func (e *AliveEvent) SetFormat(f Format)
- func (e *AliveEvent) SetIdentity(i string)
- func (e *AliveEvent) SetVersion(v string)
- func (e *AliveEvent) String() string
- func (e *AliveEvent) Target() (string, error)
- func (e *AliveEvent) TimeStamp() time.Time
- func (e *AliveEvent) Type() Type
- func (e *AliveEvent) TypeString() string
- type ComponentEvent
- type Event
- type Format
- type Framework
- type GovernedEvent
- type GovernorEvent
- func (e *GovernorEvent) Component() string
- func (e *GovernorEvent) Format() Format
- func (e *GovernorEvent) ID() string
- func (e *GovernorEvent) Identity() string
- func (e *GovernorEvent) Protocol() string
- func (e *GovernorEvent) SetComponent(c string)
- func (g *GovernorEvent) SetEventType(stage GovernorEventType) error
- func (e *GovernorEvent) SetFormat(f Format)
- func (g *GovernorEvent) SetGovernor(name string)
- func (e *GovernorEvent) SetIdentity(i string)
- func (g *GovernorEvent) SetSequence(seq uint64)
- func (g *GovernorEvent) String() string
- func (e *GovernorEvent) Target() (string, error)
- func (e *GovernorEvent) TimeStamp() time.Time
- func (e *GovernorEvent) Type() Type
- func (e *GovernorEvent) TypeString() string
- type GovernorEventType
- type NewVersionEvent
- type Option
- type ProvisionedEvent
- func (e *ProvisionedEvent) Component() string
- func (e *ProvisionedEvent) Format() Format
- func (e *ProvisionedEvent) ID() string
- func (e *ProvisionedEvent) Identity() string
- func (e *ProvisionedEvent) Protocol() string
- func (e *ProvisionedEvent) SetComponent(c string)
- func (e *ProvisionedEvent) SetFormat(f Format)
- func (e *ProvisionedEvent) SetIdentity(i string)
- func (e *ProvisionedEvent) String() string
- func (e *ProvisionedEvent) Target() (string, error)
- func (e *ProvisionedEvent) TimeStamp() time.Time
- func (e *ProvisionedEvent) Type() Type
- func (e *ProvisionedEvent) TypeString() string
- type ShutdownEvent
- func (e *ShutdownEvent) Component() string
- func (e *ShutdownEvent) Format() Format
- func (e *ShutdownEvent) ID() string
- func (e *ShutdownEvent) Identity() string
- func (e *ShutdownEvent) Protocol() string
- func (e *ShutdownEvent) SetComponent(c string)
- func (e *ShutdownEvent) SetFormat(f Format)
- func (e *ShutdownEvent) SetIdentity(i string)
- func (e *ShutdownEvent) String() string
- func (e *ShutdownEvent) Target() (string, error)
- func (e *ShutdownEvent) TimeStamp() time.Time
- func (e *ShutdownEvent) Type() Type
- func (e *ShutdownEvent) TypeString() string
- type StartupEvent
- func (e *StartupEvent) Component() string
- func (e *StartupEvent) Format() Format
- func (e *StartupEvent) ID() string
- func (e *StartupEvent) Identity() string
- func (e *StartupEvent) Protocol() string
- func (e *StartupEvent) SetComponent(c string)
- func (e *StartupEvent) SetFormat(f Format)
- func (e *StartupEvent) SetIdentity(i string)
- func (e *StartupEvent) SetVersion(v string)
- func (e *StartupEvent) String() string
- func (e *StartupEvent) Target() (string, error)
- func (e *StartupEvent) TimeStamp() time.Time
- func (e *StartupEvent) Type() Type
- func (e *StartupEvent) TypeString() string
- type SubscribeConnector
- type Type
- type UpgradedEvent
- func (e *UpgradedEvent) Component() string
- func (e *UpgradedEvent) Format() Format
- func (e *UpgradedEvent) ID() string
- func (e *UpgradedEvent) Identity() string
- func (e *UpgradedEvent) Protocol() string
- func (e *UpgradedEvent) SetComponent(c string)
- func (e *UpgradedEvent) SetFormat(f Format)
- func (e *UpgradedEvent) SetIdentity(i string)
- func (e *UpgradedEvent) SetNewVersion(v string)
- func (e *UpgradedEvent) SetVersion(v string)
- func (e *UpgradedEvent) String() string
- func (e *UpgradedEvent) Target() (string, error)
- func (e *UpgradedEvent) TimeStamp() time.Time
- func (e *UpgradedEvent) Type() Type
- func (e *UpgradedEvent) TypeString() string
- type VersionEvent
- type ViewOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EventTypeNames ¶
func EventTypeNames() []string
EventTypeNames produce a list of valid event type names
func PublishEvent ¶
func PublishEvent(e Event, conn inter.RawNATSConnector) error
PublishEvent publishes an event
func ToCloudEventV1 ¶
func ToCloudEventV1(e Event) cloudevents.Event
ToCloudEventV1 converts an event to a CloudEvent version 1
func View ¶
func View(ctx context.Context, opt *ViewOptions) error
View connects and stream events to Output
func WriteEvents ¶
func WriteEvents(ctx context.Context, opt *ViewOptions) error
WriteEvents views the event stream to the output
Types ¶
type AliveEvent ¶
type AliveEvent struct { Version string `json:"version"` // contains filtered or unexported fields }
AliveEvent is a io.choria.lifecycle.v1.alive event
In addition to the usually required fields it requires a Version() specified when producing this type of event
func (*AliveEvent) Component ¶
func (e *AliveEvent) Component() string
Component is the component that produced the event
func (*AliveEvent) Format ¶
func (e *AliveEvent) Format() Format
Format retrieves the encoding format for the event
func (*AliveEvent) Identity ¶
func (e *AliveEvent) Identity() string
Identity sets the identity for the event
func (*AliveEvent) Protocol ¶
func (e *AliveEvent) Protocol() string
Protocol retrieves the event protocol
func (*AliveEvent) SetComponent ¶
func (e *AliveEvent) SetComponent(c string)
SetComponent sets the component for the event
func (*AliveEvent) SetFormat ¶
func (e *AliveEvent) SetFormat(f Format)
SetFormat sets the encoding format for the event
func (*AliveEvent) SetIdentity ¶
func (e *AliveEvent) SetIdentity(i string)
SetIdentity sets the identity for the event
func (*AliveEvent) SetVersion ¶
func (e *AliveEvent) SetVersion(v string)
SetVersion sets the version for the event
func (*AliveEvent) String ¶
func (e *AliveEvent) String() string
String is text suitable to display on the console etc
func (*AliveEvent) TypeString ¶
func (e *AliveEvent) TypeString() string
TypeString the string representation of the event type
type ComponentEvent ¶
type ComponentEvent interface {
SetComponent(string)
}
ComponentEvent is an event that has a component
type Event ¶
type Event interface { Protocol() string Target() (string, error) String() string Type() Type TypeString() string SetIdentity(string) Component() string Identity() string ID() string Format() Format SetFormat(Format) TimeStamp() time.Time }
Event is event that can be published to the network
func NewFromJSON ¶
NewFromJSON creates an event from the event JSON
type Format ¶
type Format int
Format is the event format used for transporting events
func EventFormatFromJSON ¶
EventFormatFromJSON inspects the JSON data and tries to determine the format from it's content
type Framework ¶
type Framework interface { NewConnector(ctx context.Context, servers func() (srvcache.Servers, error), name string, logger *logrus.Entry) (conn inter.Connector, err error) Certname() string Logger(name string) *logrus.Entry NewRequestID() (string, error) MiddlewareServers() (servers srvcache.Servers, err error) }
type GovernedEvent ¶ added in v0.23.0
type GovernedEvent interface { SetGovernor(name string) SetSequence(seq uint64) SetEventType(stage GovernorEventType) error }
GovernedEvent is an event that relates to Governors
type GovernorEvent ¶ added in v0.23.0
type GovernorEvent struct { Governor string `json:"governor"` Sequence uint64 `json:"sequence"` EventType GovernorEventType `json:"event_type"` // contains filtered or unexported fields }
GovernorEvent is a io.choria.lifecycle.v1.governor event
In addition to the usual required fields it requires a GovernorName(), GovernorSequence() and GovernorType() specified when producing this kind of event
func (*GovernorEvent) Component ¶ added in v0.23.0
func (e *GovernorEvent) Component() string
Component is the component that produced the event
func (*GovernorEvent) Format ¶ added in v0.23.0
func (e *GovernorEvent) Format() Format
Format retrieves the encoding format for the event
func (*GovernorEvent) ID ¶ added in v0.23.0
func (e *GovernorEvent) ID() string
ID is the v4 uuid of this message
func (*GovernorEvent) Identity ¶ added in v0.23.0
func (e *GovernorEvent) Identity() string
Identity sets the identity for the event
func (*GovernorEvent) Protocol ¶ added in v0.23.0
func (e *GovernorEvent) Protocol() string
Protocol retrieves the event protocol
func (*GovernorEvent) SetComponent ¶ added in v0.23.0
func (e *GovernorEvent) SetComponent(c string)
SetComponent sets the component for the event
func (*GovernorEvent) SetEventType ¶ added in v0.23.0
func (g *GovernorEvent) SetEventType(stage GovernorEventType) error
func (*GovernorEvent) SetFormat ¶ added in v0.23.0
func (e *GovernorEvent) SetFormat(f Format)
SetFormat sets the encoding format for the event
func (*GovernorEvent) SetGovernor ¶ added in v0.23.0
func (g *GovernorEvent) SetGovernor(name string)
func (*GovernorEvent) SetIdentity ¶ added in v0.23.0
func (e *GovernorEvent) SetIdentity(i string)
SetIdentity sets the identity for the event
func (*GovernorEvent) SetSequence ¶ added in v0.23.0
func (g *GovernorEvent) SetSequence(seq uint64)
func (*GovernorEvent) String ¶ added in v0.23.0
func (g *GovernorEvent) String() string
func (*GovernorEvent) Type ¶ added in v0.23.0
func (e *GovernorEvent) Type() Type
Type is the type of event
func (*GovernorEvent) TypeString ¶ added in v0.23.0
func (e *GovernorEvent) TypeString() string
TypeString the string representation of the event type
type GovernorEventType ¶ added in v0.23.0
type GovernorEventType string
const ( // GovernorEnterEvent is when a Governor slot is obtained through active campaigning GovernorEnterEvent GovernorEventType = "enter" // GovernorExitEvent is when a slot is left, but not expired or evicted GovernorExitEvent GovernorEventType = "exit" // GovernorTimeoutEvent is when a slot could not be obtained after some time GovernorTimeoutEvent GovernorEventType = "timeouts" // GovernorEvictEvent is when a slot is evicted using a admin API GovernorEvictEvent GovernorEventType = "eviction" )
type NewVersionEvent ¶ added in v0.27.0
type NewVersionEvent interface { VersionEvent SetNewVersion(string) }
NewVersionEvent is an event that has a new and old version
type Option ¶
Option configures events
func GovernorName ¶ added in v0.23.0
GovernorName sets the name of the Governor being interacted with
func GovernorSequence ¶ added in v0.23.0
GovernorSequence sets the sequence of the event when applicable
func GovernorType ¶ added in v0.23.0
func GovernorType(stage GovernorEventType) Option
GovernorType sets the stage this event relates to
func NewVersion ¶ added in v0.27.0
NewVersion set the version for events
type ProvisionedEvent ¶
type ProvisionedEvent struct {
// contains filtered or unexported fields
}
ProvisionedEvent is a io.choria.lifecycle.v1.provisioned event
func (*ProvisionedEvent) Component ¶
func (e *ProvisionedEvent) Component() string
Component is the component that produced the event
func (*ProvisionedEvent) Format ¶
func (e *ProvisionedEvent) Format() Format
Format retrieves the encoding format for the event
func (*ProvisionedEvent) ID ¶
func (e *ProvisionedEvent) ID() string
ID is the v4 uuid of this message
func (*ProvisionedEvent) Identity ¶
func (e *ProvisionedEvent) Identity() string
Identity sets the identity for the event
func (*ProvisionedEvent) Protocol ¶
func (e *ProvisionedEvent) Protocol() string
Protocol retrieves the event protocol
func (*ProvisionedEvent) SetComponent ¶
func (e *ProvisionedEvent) SetComponent(c string)
SetComponent sets the component for the event
func (*ProvisionedEvent) SetFormat ¶
func (e *ProvisionedEvent) SetFormat(f Format)
SetFormat sets the encoding format for the event
func (*ProvisionedEvent) SetIdentity ¶
func (e *ProvisionedEvent) SetIdentity(i string)
SetIdentity sets the identity for the event
func (*ProvisionedEvent) String ¶
func (e *ProvisionedEvent) String() string
String is text suitable to display on the console etc
func (*ProvisionedEvent) TypeString ¶
func (e *ProvisionedEvent) TypeString() string
TypeString the string representation of the event type
type ShutdownEvent ¶
type ShutdownEvent struct {
// contains filtered or unexported fields
}
ShutdownEvent is a io.choria.lifecycle.v1.shutdown event
func (*ShutdownEvent) Component ¶
func (e *ShutdownEvent) Component() string
Component is the component that produced the event
func (*ShutdownEvent) Format ¶
func (e *ShutdownEvent) Format() Format
Format retrieves the encoding format for the event
func (*ShutdownEvent) Identity ¶
func (e *ShutdownEvent) Identity() string
Identity sets the identity for the event
func (*ShutdownEvent) Protocol ¶
func (e *ShutdownEvent) Protocol() string
Protocol retrieves the event protocol
func (*ShutdownEvent) SetComponent ¶
func (e *ShutdownEvent) SetComponent(c string)
SetComponent sets the component for the event
func (*ShutdownEvent) SetFormat ¶
func (e *ShutdownEvent) SetFormat(f Format)
SetFormat sets the encoding format for the event
func (*ShutdownEvent) SetIdentity ¶
func (e *ShutdownEvent) SetIdentity(i string)
SetIdentity sets the identity for the event
func (*ShutdownEvent) String ¶
func (e *ShutdownEvent) String() string
String is text suitable to display on the console etc
func (*ShutdownEvent) TypeString ¶
func (e *ShutdownEvent) TypeString() string
TypeString the string representation of the event type
type StartupEvent ¶
type StartupEvent struct { Version string `json:"version"` // contains filtered or unexported fields }
StartupEvent is a io.choria.lifecycle.v1.startup event
In addition to the usually required fields it requires a Version() specified when producing this type of event
func (*StartupEvent) Component ¶
func (e *StartupEvent) Component() string
Component is the component that produced the event
func (*StartupEvent) Format ¶
func (e *StartupEvent) Format() Format
Format retrieves the encoding format for the event
func (*StartupEvent) Identity ¶
func (e *StartupEvent) Identity() string
Identity sets the identity for the event
func (*StartupEvent) Protocol ¶
func (e *StartupEvent) Protocol() string
Protocol retrieves the event protocol
func (*StartupEvent) SetComponent ¶
func (e *StartupEvent) SetComponent(c string)
SetComponent sets the component for the event
func (*StartupEvent) SetFormat ¶
func (e *StartupEvent) SetFormat(f Format)
SetFormat sets the encoding format for the event
func (*StartupEvent) SetIdentity ¶
func (e *StartupEvent) SetIdentity(i string)
SetIdentity sets the identity for the event
func (*StartupEvent) SetVersion ¶
func (e *StartupEvent) SetVersion(v string)
SetVersion sets the version for the event
func (*StartupEvent) String ¶
func (e *StartupEvent) String() string
String is text suitable to display on the console etc
func (*StartupEvent) TypeString ¶
func (e *StartupEvent) TypeString() string
TypeString the string representation of the event type
type SubscribeConnector ¶
type SubscribeConnector interface { QueueSubscribe(ctx context.Context, name string, subject string, group string, output chan inter.ConnectorMessage) error ConnectedServer() string }
SubscribeConnector is a connection to the middleware
type Type ¶
type Type int
Type is a type of event this system supports
const ( // Unknown is for when a Type string was passed in that doesn't match what was expected Unknown Type = iota - 1 // Startup is an event components can publish when they start Startup // Shutdown is an event components can publish when they shutdown Shutdown // Provisioned is an event components can publish post provisioning Provisioned // Alive is an event components can publish to indicate they are still alive Alive // Governor is an event components can publish while interacting with a Governor Governor // Upgraded is an event that can be fired to indicate a component was upgraded Upgraded )
type UpgradedEvent ¶ added in v0.27.0
type UpgradedEvent struct { Version string `json:"version"` NewVersion string `json:"new_version"` // contains filtered or unexported fields }
func (*UpgradedEvent) Component ¶ added in v0.27.0
func (e *UpgradedEvent) Component() string
Component is the component that produced the event
func (*UpgradedEvent) Format ¶ added in v0.27.0
func (e *UpgradedEvent) Format() Format
Format retrieves the encoding format for the event
func (*UpgradedEvent) ID ¶ added in v0.27.0
func (e *UpgradedEvent) ID() string
ID is the v4 uuid of this message
func (*UpgradedEvent) Identity ¶ added in v0.27.0
func (e *UpgradedEvent) Identity() string
Identity sets the identity for the event
func (*UpgradedEvent) Protocol ¶ added in v0.27.0
func (e *UpgradedEvent) Protocol() string
Protocol retrieves the event protocol
func (*UpgradedEvent) SetComponent ¶ added in v0.27.0
func (e *UpgradedEvent) SetComponent(c string)
SetComponent sets the component for the event
func (*UpgradedEvent) SetFormat ¶ added in v0.27.0
func (e *UpgradedEvent) SetFormat(f Format)
SetFormat sets the encoding format for the event
func (*UpgradedEvent) SetIdentity ¶ added in v0.27.0
func (e *UpgradedEvent) SetIdentity(i string)
SetIdentity sets the identity for the event
func (*UpgradedEvent) SetNewVersion ¶ added in v0.27.0
func (e *UpgradedEvent) SetNewVersion(v string)
SetNewVersion sets the version for the event
func (*UpgradedEvent) SetVersion ¶ added in v0.27.0
func (e *UpgradedEvent) SetVersion(v string)
SetVersion sets the version for the event
func (*UpgradedEvent) String ¶ added in v0.27.0
func (e *UpgradedEvent) String() string
String is text suitable to display on the console etc
func (*UpgradedEvent) Type ¶ added in v0.27.0
func (e *UpgradedEvent) Type() Type
Type is the type of event
func (*UpgradedEvent) TypeString ¶ added in v0.27.0
func (e *UpgradedEvent) TypeString() string
TypeString the string representation of the event type
type VersionEvent ¶
type VersionEvent interface {
SetVersion(string)
}
VersionEvent is an event that has a version
type ViewOptions ¶
type ViewOptions struct { TypeFilter string ComponentFilter string Debug bool Output io.Writer Choria Framework Connector SubscribeConnector }
ViewOptions configure the view command