{"modulePath":"github.com/get-eventually/go-eventually","version":"v0.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package message\n\nPackage message exposes the generic Message type, used to represent a message in a system (e.g. Event, Command, etc.).\n\n## Variables\n\n```go\nvar ErrAlreadyIterated = errors.New(\"message.Stream: already iterated\")\n```\nErrAlreadyIterated is returned by Stream.Err when Iter is called more than once.\n\nThe second and subsequent iterations yield nothing; Err transitions to this sentinel value.\n\n## Types\n\n```go\ntype Envelope[T Message] struct {\n\tMessage  T\n\tMetadata Metadata\n}\n```\nEnvelope bundles a Message to be exchanged with optional Metadata support.\n\n```go\nfunc (e Envelope[T]) ToGenericEnvelope() GenericEnvelope\n```\nToGenericEnvelope maps the Envelope instance into a GenericEnvelope one.\n\n```go\ntype GenericEnvelope Envelope[Message]\n```\nGenericEnvelope is an Envelope type that can be used when the concrete Message type in the Envelope is not of interest.\n\n```go\ntype Message interface {\n\tName() string\n}\n```\nMessage is a Message payload.\n\nEach payload should have a unique name identifier, that can be used to uniquely route a message to its type.\n\n```go\ntype Metadata map[string]string\n```\nMetadata contains some data related to a Message that are not functional for the Message itself, but instead functioning as supporting information to provide additional context.\n\n```go\nfunc (m Metadata) Merge(other Metadata) Metadata\n```\nMerge merges the other Metadata provided in input with the current map. Returns a pointer to the extended metadata map.\n\n```go\nfunc (m Metadata) With(key, value string) Metadata\n```\nWith returns a new Metadata reference holding the value addressed using the specified key.\n\n```go\ntype Stream[T any] struct {\n\t// contains filtered or unexported fields\n}\n```\nStream is a single-use, iterator-backed sequence of values of type T.\n\nProducers are written as callbacks that push values via yield and return a terminal error if the sequence cannot be completed. Consumers iterate via [Stream.Iter](#Stream.Iter) and check [Stream.Err](#Stream.Err) at the end:\n\n\tfor v := range stream.Iter() {\n\t\t// handle v\n\t}\n\tif err := stream.Err(); err != nil {\n\t\t// handle failure\n\t}\n\nConsumer abandonment (break in the range loop) is NOT a failure; Err returns nil in that case.\n\nStream is single-use. Calling [Stream.Iter](#Stream.Iter) more than once yields an empty sequence and sets [Stream.Err](#Stream.Err) to [ErrAlreadyIterated](#ErrAlreadyIterated).\n\nCtx cancellation is the producer's responsibility: producers should check ctx.Err() at loop boundaries and return it to signal cancellation.\n\n```go\nfunc NewStream[T any](produce func(yield func(T) bool) error) *Stream[T]\n```\nNewStream returns a Stream backed by the given producer.\n\nThe producer is invoked lazily when [Stream.Iter](#Stream.Iter) is called. It must push each value via yield and respect yield's bool return: if yield returns false, the producer should stop and return nil.\n\nA non-nil error returned by the producer is captured and surfaced via [Stream.Err](#Stream.Err).\n\n```go\nfunc (s *Stream[T]) Err() error\n```\nErr returns the terminal error of the stream, or nil if the stream completed without error (including the case of consumer abandonment).\n\nErr is valid at any time; before [Stream.Iter](#Stream.Iter) is called, Err returns nil.\n\n```go\nfunc (s *Stream[T]) Iter() iter.Seq[T]\n```\nIter returns an [iter.Seq](/iter#Seq) over the stream's values.\n\nIter is single-use: calling it more than once returns an empty sequence and sets [Stream.Err](#Stream.Err) to [ErrAlreadyIterated](#ErrAlreadyIterated).\n\n","path":"github.com/get-eventually/go-eventually/message","name":"message","synopsis":"Package message exposes the generic Message type, used to represent a message in a system (e.g.","isRedistributable":true}
