Documentation
¶
Overview ¶
Package messages provides utilities to log messages
Package messages provides utilities to handle messages
Index ¶
- Constants
- func FormatMessage(msg IMessage) (s string, err error)
- func FormatMessageWithOptions(msg IMessage, option ...FormatterOption) (s string, err error)
- func NewMockNotificationFeedPage(ctx context.Context, hasNext, hasFuture bool) (f *client.NotificationFeed, err error)
- func NewMockNotificationFeedPaginator(ctx context.Context) (pagination.IPaginatorAndPageFetcher, error)
- func NewMockNotificationFeedStreamPaginator(ctx context.Context) (pagination.IStreamPaginatorAndPageFetcher, error)
- type FormatterOption
- type FormatterOptions
- type IMessage
- type IMessageLogger
- func NewBasicAsynchronousMessageLogger(ctx context.Context, rawLogger logging.ILogger) (IMessageLogger, error)
- func NewBasicAsynchronousMessageLoggerWithFormatter(ctx context.Context, rawLogger logging.ILogger, msgFormatter *MessageFormatter) (IMessageLogger, error)
- func NewBasicSynchronousMessageLogger(ctx context.Context, rawLogger logging.ILogger) (IMessageLogger, error)
- func NewBasicSynchronousMessageLoggerWithFormatter(ctx context.Context, rawLogger logging.ILogger, msgFormatter *MessageFormatter) (IMessageLogger, error)
- func NewPeriodicAsynchronousMessageLogger(ctx context.Context, rawLogger logging.ILogger, printPeriod time.Duration) (IMessageLogger, error)
- func NewPeriodicAsynchronousMessageLoggerWithFormatter(ctx context.Context, rawLogger logging.ILogger, printPeriod time.Duration, ...) (IMessageLogger, error)
- func NewPeriodicSynchronousMessageLogger(ctx context.Context, rawLogger logging.ILogger, printPeriod time.Duration) (IMessageLogger, error)
- func NewPeriodicSynchronousMessageLoggerWithFormatter(ctx context.Context, rawLogger logging.ILogger, printPeriod time.Duration, ...) (IMessageLogger, error)
- type MessageFormatter
- type MessageLoggerFactory
- func NewMessageLoggerFactory(logger logging.ILogger, asynchronous bool, printingPeriod time.Duration) *MessageLoggerFactory
- func NewMessageLoggerFactoryWithFormatter(logger logging.ILogger, asynchronous bool, printingPeriod time.Duration, ...) *MessageLoggerFactory
- func NewMessageLoggerFactoryWithFormattingOptions(logger logging.ILogger, asynchronous bool, printingPeriod time.Duration, ...) *MessageLoggerFactory
- type PaginatorFactory
- func (f *PaginatorFactory) Create(ctx context.Context, ...) (paginator pagination.IStreamPaginatorAndPageFetcher, err error)
- func (f *PaginatorFactory) UpdateBackOffPeriod(backoff time.Duration) *PaginatorFactory
- func (f *PaginatorFactory) UpdateRunOutTimeout(runOutTimeOut time.Duration) *PaginatorFactory
Constants ¶
const ( // DefaultMessagesPrintingFrequency describes the default frequency at which messages are printed DefaultMessagesPrintingFrequency = 100 * time.Millisecond // DefaultMessageFetchingBackoff describes the fixed backoff duration before more messages are fetched. DefaultMessageFetchingBackoff = 10 * time.Millisecond // DefaultStreamExhaustionGracePeriod describes the grace period which should happen when expecting message stream exhaustion. DefaultStreamExhaustionGracePeriod = time.Second )
Variables ¶
This section is empty.
Functions ¶
func FormatMessage ¶
FormatMessage formats a job message.
func FormatMessageWithOptions ¶ added in v1.17.0
func FormatMessageWithOptions(msg IMessage, option ...FormatterOption) (s string, err error)
FormatMessageWithOptions formats a job message with formatting options.
func NewMockNotificationFeedPage ¶
func NewMockNotificationFeedPage(ctx context.Context, hasNext, hasFuture bool) (f *client.NotificationFeed, err error)
NewMockNotificationFeedPage generates a mock message page for testing
func NewMockNotificationFeedPaginator ¶
func NewMockNotificationFeedPaginator(ctx context.Context) (pagination.IPaginatorAndPageFetcher, error)
NewMockNotificationFeedPaginator generates a mock message paginator for testing
func NewMockNotificationFeedStreamPaginator ¶
func NewMockNotificationFeedStreamPaginator(ctx context.Context) (pagination.IStreamPaginatorAndPageFetcher, error)
NewMockNotificationFeedStreamPaginator generates a mock message stream paginator for testing
Types ¶
type FormatterOption ¶ added in v1.17.0
type FormatterOption func(*FormatterOptions) *FormatterOptions
var WithSeverity FormatterOption = func(o *FormatterOptions) *FormatterOptions { if o == nil { return o } o.severity = true return o }
WithSeverity includes the severity of the message.
var WithSource FormatterOption = func(o *FormatterOptions) *FormatterOptions { if o == nil { return o } o.source = true return o }
WithSource includes information about the source of the message.
var WithTimeStamp FormatterOption = func(o *FormatterOptions) *FormatterOptions { if o == nil { return o } o.timestamp = true return o }
WithTimeStamp includes the timestamp of the message.
type FormatterOptions ¶ added in v1.17.0
type FormatterOptions struct {
// contains filtered or unexported fields
}
type IMessage ¶
type IMessage interface { // GetCtimeOk returns the creation time GetCtimeOk() (*time.Time, bool) // GetMessageOk returns the message string GetMessageOk() (*string, bool) // GetSeverityOk returns the message severity GetSeverityOk() (*string, bool) // GetSourceOk returns the message source. GetSourceOk() (*string, bool) }
IMessage defines a generic service message.
type IMessageLogger ¶
type IMessageLogger interface { logs.Loggers LogMessage(msg IMessage) LogEmptyMessageError() LogMarshallingError(rawMessage *any) LogMessagesCollection(ctx context.Context, messagePaginator pagination.IGenericPaginator) error }
IMessageLogger defines a logger dedicated to printing service messages.
func NewBasicAsynchronousMessageLogger ¶
func NewBasicAsynchronousMessageLogger(ctx context.Context, rawLogger logging.ILogger) (IMessageLogger, error)
NewBasicAsynchronousMessageLogger creates an asynchronous logger for messages which prints them as they come. It uses the default message formatter.
func NewBasicAsynchronousMessageLoggerWithFormatter ¶ added in v1.17.0
func NewBasicAsynchronousMessageLoggerWithFormatter(ctx context.Context, rawLogger logging.ILogger, msgFormatter *MessageFormatter) (IMessageLogger, error)
NewBasicAsynchronousMessageLoggerWithFormatter creates an asynchronous logger for messages which prints them as they come.
func NewBasicSynchronousMessageLogger ¶
func NewBasicSynchronousMessageLogger(ctx context.Context, rawLogger logging.ILogger) (IMessageLogger, error)
NewBasicSynchronousMessageLogger creates a synchronous logger for messages which prints them as they come. It uses the default message formatter.
func NewBasicSynchronousMessageLoggerWithFormatter ¶ added in v1.17.0
func NewBasicSynchronousMessageLoggerWithFormatter(ctx context.Context, rawLogger logging.ILogger, msgFormatter *MessageFormatter) (IMessageLogger, error)
NewBasicSynchronousMessageLoggerWithFormatter creates a synchronous logger for messages which prints them as they come.
func NewPeriodicAsynchronousMessageLogger ¶
func NewPeriodicAsynchronousMessageLogger(ctx context.Context, rawLogger logging.ILogger, printPeriod time.Duration) (IMessageLogger, error)
NewPeriodicAsynchronousMessageLogger creates an asynchronous logger for messages which prints them at regular intervals. It uses the default message formatter.
func NewPeriodicAsynchronousMessageLoggerWithFormatter ¶ added in v1.17.0
func NewPeriodicAsynchronousMessageLoggerWithFormatter(ctx context.Context, rawLogger logging.ILogger, printPeriod time.Duration, msgFormatter *MessageFormatter) (IMessageLogger, error)
NewPeriodicAsynchronousMessageLoggerWithFormatter creates an asynchronous logger for messages which prints them at regular intervals.
func NewPeriodicSynchronousMessageLogger ¶
func NewPeriodicSynchronousMessageLogger(ctx context.Context, rawLogger logging.ILogger, printPeriod time.Duration) (IMessageLogger, error)
NewPeriodicSynchronousMessageLogger creates a synchronous logger for messages which prints them at regular intervals. It uses the default message formatter.
func NewPeriodicSynchronousMessageLoggerWithFormatter ¶ added in v1.17.0
func NewPeriodicSynchronousMessageLoggerWithFormatter(ctx context.Context, rawLogger logging.ILogger, printPeriod time.Duration, msgFormatter *MessageFormatter) (IMessageLogger, error)
NewPeriodicSynchronousMessageLoggerWithFormatter creates a synchronous logger for messages which prints them at regular intervals.
type MessageFormatter ¶ added in v1.17.0
type MessageFormatter struct {
// contains filtered or unexported fields
}
func DefaultMessageFormatter ¶ added in v1.17.0
func DefaultMessageFormatter() *MessageFormatter
DefaultMessageFormatter returns a default message formatter.
func NewMessageFormatter ¶ added in v1.17.0
func NewMessageFormatter(option ...FormatterOption) *MessageFormatter
NewMessageFormatter creates a formatter for messages
func (*MessageFormatter) FormatMessage ¶ added in v1.17.0
func (f *MessageFormatter) FormatMessage(msg IMessage) (s string, err error)
type MessageLoggerFactory ¶
type MessageLoggerFactory struct {
// contains filtered or unexported fields
}
MessageLoggerFactory defines a message logger factory
func NewMessageLoggerFactory ¶
func NewMessageLoggerFactory(logger logging.ILogger, asynchronous bool, printingPeriod time.Duration) *MessageLoggerFactory
NewMessageLoggerFactory returns a message logger factory.
func NewMessageLoggerFactoryWithFormatter ¶ added in v1.17.0
func NewMessageLoggerFactoryWithFormatter(logger logging.ILogger, asynchronous bool, printingPeriod time.Duration, formatter *MessageFormatter) *MessageLoggerFactory
NewMessageLoggerFactoryWithFormatter returns a message logger factory.
func NewMessageLoggerFactoryWithFormattingOptions ¶ added in v1.17.0
func NewMessageLoggerFactoryWithFormattingOptions(logger logging.ILogger, asynchronous bool, printingPeriod time.Duration, option ...FormatterOption) *MessageLoggerFactory
NewMessageLoggerFactoryWithFormattingOptions returns a message logger factory.
func (*MessageLoggerFactory) Create ¶
func (f *MessageLoggerFactory) Create(ctx context.Context) (IMessageLogger, error)
Create returns a message logger.
type PaginatorFactory ¶
type PaginatorFactory struct {
// contains filtered or unexported fields
}
func NewMockMessagePaginatorFactory ¶
func NewMockMessagePaginatorFactory(pageNumber int) *PaginatorFactory
NewMockMessagePaginatorFactory generates a mock message paginator factory
func NewPaginatorFactory ¶
func NewPaginatorFactory(runOutTimeOut, backoff time.Duration, fetchNextPageFunc func(context.Context, pagination.IStaticPage) (pagination.IStaticPage, error), fetchFutureFunc func(context.Context, pagination.IStaticPageStream) (pagination.IStaticPageStream, error)) *PaginatorFactory
NewPaginatorFactory returns a message paginator factory.
func (*PaginatorFactory) Create ¶
func (f *PaginatorFactory) Create(ctx context.Context, fetchFirstPageFunc func(context.Context) (pagination.IStaticPageStream, error)) (paginator pagination.IStreamPaginatorAndPageFetcher, err error)
func (*PaginatorFactory) UpdateBackOffPeriod ¶ added in v1.5.1
func (f *PaginatorFactory) UpdateBackOffPeriod(backoff time.Duration) *PaginatorFactory
func (*PaginatorFactory) UpdateRunOutTimeout ¶
func (f *PaginatorFactory) UpdateRunOutTimeout(runOutTimeOut time.Duration) *PaginatorFactory