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 PublishConnector) 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 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 PublishConnector
- 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 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 PublishConnector) 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 choria.Connector, err error) Certname() string Logger(name string) *logrus.Entry NewRequestID() (string, error) MiddlewareServers() (servers srvcache.Servers, err error) }
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 PublishConnector ¶
PublishConnector is a connection to the middleware
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 *choria.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 ( // Startup is an event components can publish when they start Startup Type = iota // 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 )
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