Documentation ¶
Overview ¶
Package broadcaster provided minimalist and opinionated methods for "broadcasting" messages with zero or more images.
Index ¶
- func RegisterBroadcaster(ctx context.Context, scheme string, init_func BroadcasterInitializationFunc) error
- func Schemes() []string
- type Broadcaster
- func NewBroadcaster(ctx context.Context, uri string) (Broadcaster, error)
- func NewLogBroadcaster(ctx context.Context, uri string) (Broadcaster, error)
- func NewMultiBroadcaster(ctx context.Context, broadcasters ...Broadcaster) (Broadcaster, error)
- func NewMultiBroadcasterFromURIs(ctx context.Context, broadcaster_uris ...string) (Broadcaster, error)
- func NewNullBroadcaster(ctx context.Context, uri string) (Broadcaster, error)
- type BroadcasterInitializationFunc
- type LogBroadcaster
- type Message
- type MultiBroadcaster
- type NullBroadcaster
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterBroadcaster ¶
func RegisterBroadcaster(ctx context.Context, scheme string, init_func BroadcasterInitializationFunc) error
RegisterBroadcaster registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Broadcaster` instances by the `NewBroadcaster` method.
Types ¶
type Broadcaster ¶
type Broadcaster interface { // BroadcastMessage "broadcasts" a `Message` struct. BroadcastMessage(context.Context, *Message) (uid.UID, error) }
Broadcaster provides a minimalist interface for "broadcasting" messages to an arbitrary service or target.
func NewBroadcaster ¶
func NewBroadcaster(ctx context.Context, uri string) (Broadcaster, error)
NewBroadcaster returns a new `Broadcaster` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `BroadcasterInitializationFunc` function used to instantiate the new `Broadcaster`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterBroadcaster` method.
func NewLogBroadcaster ¶
func NewLogBroadcaster(ctx context.Context, uri string) (Broadcaster, error)
NewLogBroadcaster returns a new `LogBroadcaster` configured by 'uri' which is expected to take the form of:
log://?{PARAMETERS}
Where `{PARAMETERS}` may be one or more of the following: * ?ascii={BOOLEAN} – If true then ASCII-representations of each image in a message will be logged. Default is "false". By default `LogBroadcaster` instances are configured to broadcast messages to a `log/slog.Default` instance with an `INFO` level.
func NewMultiBroadcaster ¶
func NewMultiBroadcaster(ctx context.Context, broadcasters ...Broadcaster) (Broadcaster, error)
func NewMultiBroadcasterFromURIs ¶
func NewMultiBroadcasterFromURIs(ctx context.Context, broadcaster_uris ...string) (Broadcaster, error)
func NewNullBroadcaster ¶
func NewNullBroadcaster(ctx context.Context, uri string) (Broadcaster, error)
type BroadcasterInitializationFunc ¶
type BroadcasterInitializationFunc func(ctx context.Context, uri string) (Broadcaster, error)
BroadcasterInitializationFunc is a function defined by individual broadcaster package and used to create an instance of that broadcaster
type LogBroadcaster ¶
type LogBroadcaster struct { Broadcaster // contains filtered or unexported fields }
LogBroadcaster implements the `Broadcaster` interface to broadcast messages to a `log.Logger` instance.
func (*LogBroadcaster) BroadcastMessage ¶
func (b *LogBroadcaster) BroadcastMessage(ctx context.Context, msg *Message) (uid.UID, error)
BroadcastMessage broadcast the title and body properties of 'msg' to the `log.Logger` instance associated with 'b'. If the `?ascii=` parameter in the constructor URI (see `NewLogBroadcaster`) is true then each image will be converted in to an ASCII representation and logged. It returns the value of the Unix timestamp that the log message was broadcast.
type Message ¶
type Message struct { // Title is a string to use as the title of a "broadcast" message. Title string // Body is a string to use as the body of a "broadcast" message. Body string // Images is zero or more `image.Image` instances to be included with a "broadcast" messages. // Images are encoded according to rules implemented by service or target -specific implementation // of the `Broadcaster` interface. Images []image.Image }
Message defines a struct containing properties to "broadcast". The semantics of these properties are determined by the server or target -specific implementation of the `Broadcaster` interface.
type MultiBroadcaster ¶
type MultiBroadcaster struct { Broadcaster // contains filtered or unexported fields }
func (*MultiBroadcaster) BroadcastMessage ¶
func (b *MultiBroadcaster) BroadcastMessage(ctx context.Context, msg *Message) (uid.UID, error)
type NullBroadcaster ¶
type NullBroadcaster struct {
Broadcaster
}
func (*NullBroadcaster) BroadcastMessage ¶
func (b *NullBroadcaster) BroadcastMessage(ctx context.Context, msg *Message) (uid.UID, error)
Directories ¶
Path | Synopsis |
---|---|
Package app provides methods for implementing broadcast-related applications
|
Package app provides methods for implementing broadcast-related applications |
broadcast
Package broadcast provides methods for implementing a command line tool for "broadcasting" messages.
|
Package broadcast provides methods for implementing a command line tool for "broadcasting" messages. |
cmd
|
|