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 ¶
- The method must return the same channel instance to all callers.
- The source must provide its publication channel even if it has not been started yet.
- The source must continue providing the same channel even if the source has been stopped.
- To achieve end to end event traceability, events are expected to embed tracing data as described in the following documentation: https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/extensions/distributed-tracing.md
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.
Click to show internal directories.
Click to hide internal directories.