receiver

package
v0.7.188 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package receiver forwards buffered telemetry events to Segment. It runs inside the detached "chunk receive-telemetry" subprocess spawned by internal/telemetry's delegateDestination, out of the parent CLI's exit path.

Index

Constants

View Source
const (
	KindTrack    = "track"
	KindIdentify = "identify"
)

Message kinds carried on the wire between the CLI and the detached receive-telemetry subprocess.

View Source
const (
	// EnvWriteKey configures the Segment write key for the delegate subprocess.
	EnvWriteKey = "__CHUNK_TELEMETRY_WRITE_KEY"
	// EnvTelemetryEndpoint configures the Segment endpoint for the delegate subprocess.
	EnvTelemetryEndpoint = "__CHUNK_TELEMETRY_ENDPOINT"
)

Variables

This section is empty.

Functions

func Receive

func Receive(in io.Reader) (err error)

Receive decodes a JSON array of buffered messages from in and forwards them to Segment using the write key and endpoint from the environment.

Types

type Message added in v0.7.188

type Message struct {
	Kind     string              `json:"kind"`
	Track    *analytics.Track    `json:"track,omitempty"`
	Identify *analytics.Identify `json:"identify,omitempty"`
}

Message is the wire envelope for one buffered Segment message. Events reach the subprocess as a JSON array of these, so a payload can mix command invocation tracks with the identify calls that join an anonymous ID to a user ID — a bare analytics.Track array could only carry the former.

func Wrap added in v0.7.188

func Wrap(msg analytics.Message) (Message, error)

Wrap puts msg in an envelope. It returns an error for message types the wire format does not know about, so adding one to Sender without teaching the receiver to forward it fails loudly rather than silently dropping events.

func (Message) Unwrap added in v0.7.188

func (m Message) Unwrap() analytics.Message

Unwrap returns the analytics message m carries, or nil when the envelope is empty or of an unknown kind (an older CLI's payload, say) — the receiver skips those rather than failing the whole batch.

Jump to

Keyboard shortcuts

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