sources

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Heartbeat

type Heartbeat struct {
	// Unix (seconds) timestamp when heartbeat has been published.
	Timestamp int64 `json:"timestamp"`
}

Data of a heartbeat

type HeartbeatEventSource

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

Event source which emits heartbeat events

func NewHeartbeatEventSource

func NewHeartbeatEventSource(tracerProvider trace.TracerProvider, logger *log.Logger) *HeartbeatEventSource

Description

Build and return a non-started heartbeat event source

Inputs

  • tracerProvider: Provider to use to get a tracer. If nil, global tracer provider is used.
  • logger: Logger to use to publish debug logs. If nil, debug logs will be discarded.

Return

A new, non-started heartbeat event source.

func (*HeartbeatEventSource) GetChannel

func (source *HeartbeatEventSource) GetChannel() chan event.Event

Description

Provide the channel used by the event source to publish its events.

Implementation requirements & hints

Return

The channel used by this source to publish its events.

func (*HeartbeatEventSource) Start

func (source *HeartbeatEventSource) Start(ctx context.Context) error

Description

Start the event source that will start publishing events on its publication channel.

Implementation requirements & hints

  • The method must return an error if the source has already been started.
  • The method must return an error if the provided context has been canceled or has expired.
  • The method must return an error if the source has been stopped (no restart).
  • The method must close the publication channel.

Inputs

  • ctx: Context used for tracing purpose.

Return

An error if the event source could not be started.

func (*HeartbeatEventSource) Stop

func (source *HeartbeatEventSource) Stop(ctx context.Context) error

Description

Stop the event source and close the publication channel.

Implementation requirements & hints

  • The method must return an error if the source has not been started.
  • The method must return an error if the source has already been stopped.
  • The method must close the publication channel even if the underlying event source could not properly closed.
  • The closed publication channel must be kept: source must not be restarted (stale source).

Inputs

  • ctx: Context used for tracing purpose.

Return

An error if the event source could not be closed.

Jump to

Keyboard shortcuts

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