Documentation
¶
Index ¶
- func EngineStateInfoToProto(rsi *EngineStateInfo) (*sharedpb.RASEvent_EngineStateInfo, error)
- func PoolSvcInfoToProto(psi *PoolSvcInfo) (*sharedpb.RASEvent_PoolSvcInfo, error)
- func StrInfoToProto(si *StrInfo) (*sharedpb.RASEvent_StrInfo, error)
- type DebounceKeyFn
- type EngineStateInfo
- type Handler
- type HandlerFunc
- type PoolSvcInfo
- type PubSub
- func (ps *PubSub) Close()
- func (ps *PubSub) Debounce(id RASID, cooldown time.Duration, keyFn DebounceKeyFn)
- func (ps *PubSub) DisableEventIDs(ids ...RASID)
- func (ps *PubSub) EnableEventIDs(ids ...RASID)
- func (ps *PubSub) HandleClusterEvent(req *sharedpb.ClusterEventReq, forwarded bool) (*sharedpb.ClusterEventResp, error)
- func (ps *PubSub) Publish(event *RASEvent)
- func (ps *PubSub) Reset()
- func (ps *PubSub) Subscribe(topic RASTypeID, handler Handler)
- type Publisher
- type RASEvent
- func NewEngineDiedEvent(hostname string, instanceIdx uint32, rank uint32, exitErr common.ExitStatus, ...) *RASEvent
- func NewEngineFormatRequiredEvent(hostname string, instanceIdx uint32, formatType string) *RASEvent
- func NewEngineJoinFailedEvent(hostname string, instanceIdx uint32, rank uint32, reason string) *RASEvent
- func NewFromProto(pbEvt *sharedpb.RASEvent) (*RASEvent, error)
- func NewGenericEvent(id RASID, sev RASSeverityID, msg, info string) *RASEvent
- func NewPoolSvcReplicasUpdateEvent(hostname string, rank uint32, poolUUID string, svcReps []uint32, ...) *RASEvent
- func (evt *RASEvent) FromProto(pbEvt *sharedpb.RASEvent) (err error)
- func (evt *RASEvent) GetEngineStateInfo() *EngineStateInfo
- func (evt *RASEvent) GetPoolSvcInfo() *PoolSvcInfo
- func (evt *RASEvent) GetStrInfo() *StrInfo
- func (evt *RASEvent) GetTimestamp() (time.Time, error)
- func (evt *RASEvent) IsForwarded() bool
- func (evt *RASEvent) MarshalJSON() ([]byte, error)
- func (evt *RASEvent) PrintRAS() string
- func (evt *RASEvent) ShouldForward() bool
- func (ev *RASEvent) String() string
- func (evt *RASEvent) ToProto() (*sharedpb.RASEvent, error)
- func (evt *RASEvent) UnmarshalJSON(data []byte) error
- func (evt *RASEvent) WithForwardable(forwardable bool) *RASEvent
- func (evt *RASEvent) WithForwarded(forwarded bool) *RASEvent
- func (evt *RASEvent) WithRank(rid uint32) *RASEvent
- type RASExtendedInfo
- type RASID
- type RASSeverityID
- type RASTypeID
- type StrInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EngineStateInfoToProto ¶
func EngineStateInfoToProto(rsi *EngineStateInfo) (*sharedpb.RASEvent_EngineStateInfo, error)
EngineStateInfoToProto converts event info from native to proto format.
func PoolSvcInfoToProto ¶
func PoolSvcInfoToProto(psi *PoolSvcInfo) (*sharedpb.RASEvent_PoolSvcInfo, error)
PoolSvcInfoToProto converts event info from native to proto format.
func StrInfoToProto ¶
func StrInfoToProto(si *StrInfo) (*sharedpb.RASEvent_StrInfo, error)
StrInfoToProto converts event info from native to proto format.
Types ¶
type DebounceKeyFn ¶
DebounceKeyFn defines a function that returns a key to be used for determining if the event matches a previously-seen event.
type EngineStateInfo ¶
EngineStateInfo describes details of a engine's state.
func EngineStateInfoFromProto ¶
func EngineStateInfoFromProto(pbInfo *sharedpb.RASEvent_EngineStateInfo) (*EngineStateInfo, error)
EngineStateInfoFromProto converts event info from proto to native format.
type Handler ¶
type Handler interface { // OnEvent takes an event to be processed and a context, // implementation must return on context.Done() and be thread safe. OnEvent(context.Context, *RASEvent) }
Handler defines an interface to be implemented by event receivers.
type HandlerFunc ¶
HandlerFunc is an adapter to allow an ordinary function to be used as a Handler.
type PoolSvcInfo ¶
type PoolSvcInfo struct { SvcReplicas []uint32 `json:"svc_reps"` RaftLeaderTerm uint64 `json:"version"` }
PoolSvcInfo describes details of a pool service.
func PoolSvcInfoFromProto ¶
func PoolSvcInfoFromProto(pbInfo *sharedpb.RASEvent_PoolSvcInfo) (*PoolSvcInfo, error)
PoolSvcInfoFromProto converts event info from proto to native format.
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
PubSub stores subscriptions to event topics and handlers to be called on receipt of events pertaining to a particular topic.
func (*PubSub) Close ¶
func (ps *PubSub) Close()
Close terminates event loop by calling shutdown to cancel context.
func (*PubSub) Debounce ¶
func (ps *PubSub) Debounce(id RASID, cooldown time.Duration, keyFn DebounceKeyFn)
Debounce accepts an event ID and a key function to be used to determine if an event matches a previously-seen event with that ID. This mechanism provides control over publication of duplicate events. The cooldown parameter determines the minimum amount of time required between publication of duplicate events. If cooldown is zero, then a given event may only be published at most once.
func (*PubSub) DisableEventIDs ¶
DisableEventIDs adds event IDs to the filter preventing those event IDs from being published.
func (*PubSub) EnableEventIDs ¶
EnableEventIDs removes event IDs from the filter enabling those event IDs to be published.
func (*PubSub) HandleClusterEvent ¶
func (ps *PubSub) HandleClusterEvent(req *sharedpb.ClusterEventReq, forwarded bool) (*sharedpb.ClusterEventResp, error)
HandleClusterEvent extracts event field from protobuf request message and converts to native event type. The Event is then published to make available to locally subscribed consumers to act upon.
type Publisher ¶
type Publisher interface { // Publish takes an event to be published. Publish(event *RASEvent) }
Publisher defines an interface to be implemented by event publishers.
type RASEvent ¶
type RASEvent struct { ID RASID `json:"id"` Timestamp string `json:"timestamp"` Type RASTypeID `json:"type"` Severity RASSeverityID `json:"severity"` Msg string `json:"msg"` Hostname string `json:"hostname"` Rank uint32 `json:"rank"` Incarnation uint64 `json:"incarnation"` HWID string `json:"hw_id"` ProcID int `json:"proc_id"` ThreadID uint64 `json:"thread_id"` JobID string `json:"job_id"` PoolUUID string `json:"pool_uuid"` ContUUID string `json:"cont_uuid"` ObjID string `json:"obj_id"` CtlOp string `json:"ctl_op"` ExtendedInfo RASExtendedInfo `json:"extended_info"` // contains filtered or unexported fields }
RASEvent describes details of a specific RAS event.
func NewEngineDiedEvent ¶
func NewEngineDiedEvent(hostname string, instanceIdx uint32, rank uint32, exitErr common.ExitStatus, exPid int) *RASEvent
NewEngineDiedEvent creates a specific EngineDied event from given inputs.
func NewEngineFormatRequiredEvent ¶
NewEngineFormatRequiredEvent creates a EngineFormatRequired event from given inputs.
func NewEngineJoinFailedEvent ¶
func NewEngineJoinFailedEvent(hostname string, instanceIdx uint32, rank uint32, reason string) *RASEvent
NewEngineJoinFailedEvent creates an EngineJoinFailed event from the given inputs.
func NewFromProto ¶
NewFromProto creates an Event from given protobuf RASEvent message.
func NewGenericEvent ¶
func NewGenericEvent(id RASID, sev RASSeverityID, msg, info string) *RASEvent
NewGenericEvent returns a generic RAS event with supplied ID.
func NewPoolSvcReplicasUpdateEvent ¶
func NewPoolSvcReplicasUpdateEvent(hostname string, rank uint32, poolUUID string, svcReps []uint32, leaderTerm uint64) *RASEvent
NewPoolSvcReplicasUpdateEvent creates a specific PoolSvcRanksUpdate event from given inputs.
func (*RASEvent) GetEngineStateInfo ¶
func (evt *RASEvent) GetEngineStateInfo() *EngineStateInfo
GetEngineStateInfo returns extended info if of type EngineStateInfo.
func (*RASEvent) GetPoolSvcInfo ¶
func (evt *RASEvent) GetPoolSvcInfo() *PoolSvcInfo
GetPoolSvcInfo returns extended info if of type PoolSvcInfo.
func (*RASEvent) GetStrInfo ¶
GetStrInfo returns extended info if of type StrInfo.
func (*RASEvent) GetTimestamp ¶
GetTimestamp returns a time.Time parsed from the event timestamp.
func (*RASEvent) IsForwarded ¶
IsForwarded returns true if event has been forwarded between hosts.
func (*RASEvent) MarshalJSON ¶
MarshalJSON marshals RASEvent to JSON.
func (*RASEvent) PrintRAS ¶
PrintRAS generates a string representation of the event consistent with what is logged in the data plane.
func (*RASEvent) ShouldForward ¶
ShouldForward returns true if event is forwardable and has not already been forwarded.
func (*RASEvent) UnmarshalJSON ¶
UnmarshalJSON unmarshals RASEvent from JSON.
func (*RASEvent) WithForwardable ¶
WithForwardable sets the forwardable state of this event.
func (*RASEvent) WithForwarded ¶
WithForwarded sets the forwarded state of this event.
type RASExtendedInfo ¶
type RASExtendedInfo interface {
// contains filtered or unexported methods
}
RASExtendedInfo provides extended information for an event.
type RASID ¶
type RASID uint32
RASID identifies a given RAS event.
const ( RASUnknownEvent RASID = C.RAS_UNKNOWN_EVENT RASEngineFormatRequired RASID = C.RAS_ENGINE_FORMAT_REQUIRED // notice RASEngineDied RASID = C.RAS_ENGINE_DIED // error RASPoolRepsUpdate RASID = C.RAS_POOL_REPS_UPDATE // info RASSwimRankAlive RASID = C.RAS_SWIM_RANK_ALIVE // info RASSwimRankDead RASID = C.RAS_SWIM_RANK_DEAD // info RASSystemStartFailed RASID = C.RAS_SYSTEM_START_FAILED // error RASSystemStopFailed RASID = C.RAS_SYSTEM_STOP_FAILED // error RASEngineJoinFailed RASID = C.RAS_ENGINE_JOIN_FAILED // error RASSystemFabricProvChanged RASID = C.RAS_SYSTEM_FABRIC_PROV_CHANGED // info RASNVMeLinkSpeedChanged RASID = C.RAS_DEVICE_LINK_SPEED_CHANGED // warning|notice RASNVMeLinkWidthChanged RASID = C.RAS_DEVICE_LINK_WIDTH_CHANGED // warning|notice )
RASID constant definitions matching those used when creating events either in the control or data (engine) planes.
type RASSeverityID ¶
type RASSeverityID uint32
RASSeverityID identifies the severity of a given RAS event.
const ( RASSeverityUnknown RASSeverityID = C.RAS_SEV_UNKNOWN RASSeverityError RASSeverityID = C.RAS_SEV_ERROR RASSeverityWarning RASSeverityID = C.RAS_SEV_WARNING RASSeverityNotice RASSeverityID = C.RAS_SEV_NOTICE )
RASSeverityID constant definitions.
func (RASSeverityID) String ¶
func (sev RASSeverityID) String() string
func (RASSeverityID) SyslogPriority ¶
func (sev RASSeverityID) SyslogPriority() syslog.Priority
SyslogPriority maps RAS severity to syslog package priority.
func (RASSeverityID) Uint32 ¶
func (sev RASSeverityID) Uint32() uint32
Uint32 returns uint32 representation of event severity.
type RASTypeID ¶
type RASTypeID uint32
RASTypeID identifies the type of a given RAS event.
const ( RASTypeAny RASTypeID = C.RAS_TYPE_ANY RASTypeStateChange RASTypeID = C.RAS_TYPE_STATE_CHANGE RASTypeInfoOnly RASTypeID = C.RAS_TYPE_INFO )
RASTypeID constant definitions.
type StrInfo ¶
type StrInfo string
StrInfo contains opaque blob of type string to hold custom details for a generic RAS event to be forwarded through the control-plane from the data-plane to an external consumer e.g. syslog.
func NewStrInfo ¶
NewStrInfo returns an initialized StrInfo reference.
func StrInfoFromProto ¶
func StrInfoFromProto(pbInfo *sharedpb.RASEvent_StrInfo) (*StrInfo, error)
StrInfoFromProto converts event info from proto to native format.