events

package
v3.1.0-M6+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLogOptionalFields

func AddLogOptionalFields(ctx context.Context, logOptFields LogOptionalFields) context.Context

AddLogOptionalFields adds given log optional fields to existing one in the given context if any

Existing fields are overwritten in case of collision

func CustomCommandStatusChange deprecated

func CustomCommandStatusChange(kv *api.KV, deploymentID, taskID, status string) (string, error)

CustomCommandStatusChange publishes a status change for a custom command

CustomCommandStatusChange returns the published event id

Deprecated: use PublishAndLogCustomCommandStatusChange instead

func DeploymentStatusChange deprecated

func DeploymentStatusChange(kv *api.KV, deploymentID, status string) (string, error)

DeploymentStatusChange publishes a status change for a given deployment

DeploymentStatusChange returns the published event id

Deprecated: use PublishAndLogDeploymentStatusChange instead

func FormatLog

func FormatLog(flat map[string]interface{}) string

FormatLog allows to format the flat map log representation in the following format :[Timestamp][Level][DeploymentID][WorkflowID]ExecutionIDNodeIDInstanceIDInterfaceNameOperationName[TypeID]Content

func GetLogsEventsIndex

func GetLogsEventsIndex(kv *api.KV, deploymentID string) (uint64, error)

GetLogsEventsIndex returns the latest index of LogEntry events for a given deployment

func GetStatusEventsIndex

func GetStatusEventsIndex(kv *api.KV, deploymentID string) (uint64, error)

GetStatusEventsIndex returns the latest index of InstanceStatus events for a given deployment

func InstanceStatusChange deprecated

func InstanceStatusChange(kv *api.KV, deploymentID, nodeName, instance, status string) (string, error)

InstanceStatusChange publishes a status change for a given instance of a given node

InstanceStatusChange returns the published event id

Deprecated: Use PublishAndLogInstanceStatusChange instead

func LogsEvents

func LogsEvents(kv *api.KV, deploymentID string, waitIndex uint64, timeout time.Duration) ([]json.RawMessage, uint64, error)

LogsEvents allows to return logs from Consul KV storage for all, or a given deployment

func NewContext

func NewContext(ctx context.Context, logOptFields LogOptionalFields) context.Context

NewContext returns a new Context that carries value logOptFields.

func PublishAndLogCustomCommandStatusChange

func PublishAndLogCustomCommandStatusChange(ctx context.Context, kv *api.KV, deploymentID, taskID, status string) (string, error)

PublishAndLogCustomCommandStatusChange publishes a status change for a custom command and log this change into the log API

PublishAndLogCustomCommandStatusChange returns the published event id

func PublishAndLogDeploymentStatusChange

func PublishAndLogDeploymentStatusChange(ctx context.Context, kv *api.KV, deploymentID, status string) (string, error)

PublishAndLogDeploymentStatusChange publishes a status change for a given deployment and log this change into the log API

PublishAndLogDeploymentStatusChange returns the published event id

func PublishAndLogInstanceStatusChange

func PublishAndLogInstanceStatusChange(ctx context.Context, kv *api.KV, deploymentID, nodeName, instance, status string) (string, error)

PublishAndLogInstanceStatusChange publishes a status change for a given instance of a given node and log this change into the log API

PublishAndLogInstanceStatusChange returns the published event id

func PublishAndLogScalingStatusChange

func PublishAndLogScalingStatusChange(ctx context.Context, kv *api.KV, deploymentID, taskID, status string) (string, error)

PublishAndLogScalingStatusChange publishes a status change for a scaling task and log this change into the log API

PublishAndLogScalingStatusChange returns the published event id

func PublishAndLogWorkflowStatusChange

func PublishAndLogWorkflowStatusChange(ctx context.Context, kv *api.KV, deploymentID, taskID, status string) (string, error)

PublishAndLogWorkflowStatusChange publishes a status change for a workflow task and log this change into the log API

PublishAndLogWorkflowStatusChange returns the published event id

func ScalingStatusChange deprecated

func ScalingStatusChange(kv *api.KV, deploymentID, taskID, status string) (string, error)

ScalingStatusChange publishes a status change for a scaling task

ScalingStatusChange returns the published event id

Deprecated: use PublishAndLogScalingStatusChange instead

func WorkflowStatusChange deprecated

func WorkflowStatusChange(kv *api.KV, deploymentID, taskID, status string) (string, error)

WorkflowStatusChange publishes a status change for a workflow task

WorkflowStatusChange returns the published event id

Deprecated: use PublishAndLogWorkflowStatusChange instead

Types

type BufferedLogEntryWriter

type BufferedLogEntryWriter interface {
	io.Writer
	// contains filtered or unexported methods
}

A BufferedLogEntryWriter is a Writer that buffers writes and flushes its buffer as an event log on a regular basis (every 5s)

func NewBufferedLogEntryWriter

func NewBufferedLogEntryWriter() BufferedLogEntryWriter

NewBufferedLogEntryWriter returns a BufferedLogEntryWriter used to register log entry

type FieldType

type FieldType int

FieldType is allowed/expected additional info types

const (
	// WorkFlowID is the field type representing the workflow ID in log entry
	WorkFlowID FieldType = iota

	// ExecutionID is the field type representing the execution ID in log entry
	ExecutionID

	// NodeID is the field type representing the node ID in log entry
	NodeID

	// InstanceID is the field type representing the instance ID in log entry
	InstanceID

	// InterfaceName is the field type representing the interface ID in log entry
	InterfaceName

	// OperationName is the field type representing the operation ID in log entry
	OperationName

	// TypeID is the field type representing the type ID in log entry
	TypeID
)

func (FieldType) String

func (ft FieldType) String() string

String allows to stringify the field type enumeration in JSON standard

type LogEntry

type LogEntry struct {
	// contains filtered or unexported fields
}

LogEntry is the log entry representation

func SimpleLogEntry

func SimpleLogEntry(level LogLevel, deploymentID string) *LogEntry

SimpleLogEntry allows to return a LogEntry instance with log level and deploymentID

func (LogEntry) Register

func (e LogEntry) Register(content []byte)

Register allows to register a log entry with byte array content

func (LogEntry) RegisterAsString

func (e LogEntry) RegisterAsString(content string)

RegisterAsString allows to register a log entry with string content

func (LogEntry) Registerf

func (e LogEntry) Registerf(format string, a ...interface{})

Registerf allows to register a log entry with formats according to a format specifier.

This is basically a convenient function around RegisterAsString(fmt.Sprintf()).

func (LogEntry) RunBufferedRegistration

func (e LogEntry) RunBufferedRegistration(buf BufferedLogEntryWriter, quit chan bool)

RunBufferedRegistration allows to run a registration with a buffered writer

type LogEntryDraft

type LogEntryDraft struct {
	// contains filtered or unexported fields
}

LogEntryDraft is a partial LogEntry with only optional fields. It has to be completed with level and deploymentID

func WithContextOptionalFields

func WithContextOptionalFields(ctx context.Context) *LogEntryDraft

WithContextOptionalFields allows to return a LogEntry instance with additional fields comming from the context

func WithOptionalFields deprecated

func WithOptionalFields(fields LogOptionalFields) *LogEntryDraft

WithOptionalFields allows to return a LogEntry instance with additional fields

Deprecated: Use events.WithContextOptionalFields() instead

func (LogEntryDraft) NewLogEntry

func (e LogEntryDraft) NewLogEntry(level LogLevel, deploymentID string) *LogEntry

NewLogEntry allows to build a log entry from a draft

type LogLevel

type LogLevel int

LogLevel x ENUM( INFO, DEBUG, WARN, ERROR )

const (
	// LogLevelINFO is a LogLevel of type INFO
	LogLevelINFO LogLevel = iota
	// LogLevelDEBUG is a LogLevel of type DEBUG
	LogLevelDEBUG
	// LogLevelWARN is a LogLevel of type WARN
	LogLevelWARN
	// LogLevelERROR is a LogLevel of type ERROR
	LogLevelERROR
)

func ParseLogLevel

func ParseLogLevel(name string) (LogLevel, error)

ParseLogLevel attempts to convert a string to a LogLevel

func (LogLevel) String

func (x LogLevel) String() string

String implements the Stringer interface.

type LogOptionalFields

type LogOptionalFields map[FieldType]interface{}

LogOptionalFields are log's additional info

func FromContext

func FromContext(ctx context.Context) (LogOptionalFields, bool)

FromContext returns a copy of the LogOptionalFields value stored in ctx, if any.

type StatusUpdate

type StatusUpdate struct {
	Timestamp    string `json:"timestamp"`
	Type         string `json:"type"`
	Node         string `json:"node,omitempty"`
	Instance     string `json:"instance,omitempty"`
	TaskID       string `json:"task_id,omitempty"`
	DeploymentID string `json:"deployment_id"`
	Status       string `json:"status"`
}

StatusUpdate represents status change event

func StatusEvents

func StatusEvents(kv *api.KV, deploymentID string, waitIndex uint64, timeout time.Duration) ([]StatusUpdate, uint64, error)

StatusEvents return a list of events (StatusUpdate instances) for all, or a given deployment

type StatusUpdateType

type StatusUpdateType uint64

StatusUpdateType is the status update type

const (
	// InstanceStatusChangeType is the StatusUpdate type for an instance state change event
	InstanceStatusChangeType StatusUpdateType = iota
	// DeploymentStatusChangeType is the StatusUpdate type for an deployment status change event
	DeploymentStatusChangeType
	// CustomCommandStatusChangeType is the StatusUpdate type for an custom command status change event
	CustomCommandStatusChangeType
	// ScalingStatusChangeType is the StatusUpdate type for an scaling status change event
	ScalingStatusChangeType
	// WorkflowStatusChangeType is the StatusUpdate type for an workflow status change event
	WorkflowStatusChangeType
)

func StatusUpdateTypeString

func StatusUpdateTypeString(s string) (StatusUpdateType, error)

StatusUpdateTypeString returns a StatusUpdateType given its string representation

func (StatusUpdateType) String

func (i StatusUpdateType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL