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) // SetLogger assigns a specific `log.Logger` instance to be used for logging messages. SetLogger(context.Context, *log.Logger) 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://
By default `LogBroadcaster` instances are configured to broadcast messages to a `log.Default` instance. If you want to change that call the `SetLogger` method.
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'. It does not publish images yet. Maybe someday it will try to convert images to their ascii interpretations but today it does not. 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
|
|