Documentation ¶
Overview ¶
Package message implements types for manipulating streams of broker messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataLimiter ¶
type DataLimiter struct { // Budget is how many bytes can be transmitted per period. // If HasBudget is false, any number of bytes can be transmitted. Budget int `json:"budget"` HasBudget bool `json:"hasBudget"` // Count is how many bytes have been transmitted during the current // period. Count int `json:"count"` // PeriodEnd marks the end of the current period. PeriodEnd time.Time `json:"periodEnd"` // contains filtered or unexported fields }
DataLimiter is a passthrough that limits the number of application-layer bytes transmitted per period.
func NewDataLimiter ¶
func NewDataLimiter( store Persistor, conf <-chan api.CellularConfig, src ...broker.MessageSource, ) *DataLimiter
NewDataLimiter returns a DataLimiter for input whose state persists on the filesystem.
func (*DataLimiter) Decode ¶
func (l *DataLimiter) Decode(r io.Reader) (err error)
Decode updates l's state by reading bytes from r.
func (*DataLimiter) Encode ¶
func (l *DataLimiter) Encode(w io.Writer) (err error)
Encode writes the l's state to w.
func (*DataLimiter) Output ¶
func (l *DataLimiter) Output() <-chan broker.Message
Output returns a channel on which messages can be received. The channel closes when l's input closes.
type FilePersistor ¶
type FilePersistor struct {
Path string
}
FilePersistor permits saving and loading data from a file.
func (FilePersistor) Load ¶
func (fp FilePersistor) Load(object Decodable) error
Load decodes object from the underlying file.
func (FilePersistor) Save ¶
func (fp FilePersistor) Save(object Encodable) error
Save encodes object to the underlying file.
type MemPersistor ¶
MemPersistor permits saving and loading data from an internal memory buffer.
func (*MemPersistor) Load ¶
func (mp *MemPersistor) Load(object Decodable) error
Load decodes object from mp's internal buffer.
func (*MemPersistor) Save ¶
func (mp *MemPersistor) Save(object Encodable) error
Save encodes object to mp's internal buffer.
type Merger ¶
type Merger struct {
// contains filtered or unexported fields
}
Merger is a broker.MessageSource that merges multiple other MessageSources into one stream.
func Merge ¶
func Merge(src ...broker.MessageSource) Merger
Merge returns a Merger that merges the streams of each element in src.