Documentation ¶
Overview ¶
Copyright 2017 Jeff Nickoloff "jeff@allingeek.com"
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2017 Jeff Nickoloff "jeff@allingeek.com"
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func NewContext(ctx context.Context, config EventsConfig) context.Context
- func PublishInflux(url, db string, maxIdle time.Duration) chan EventBlock
- func PublishLog() chan EventBlock
- func Write(ctx context.Context, es ...Event) error
- type Counter
- type Event
- type EventBlock
- type EventsConfig
- type Pair
- type Registry
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
func NewContext(ctx context.Context, config EventsConfig) context.Context
func PublishInflux ¶
func PublishInflux(url, db string, maxIdle time.Duration) chan EventBlock
PublishInflux returns a channel of EventBlocks and starts a goroutine that reads from that channel and writes retireved EventBlocks using the InfluxDB client library. Closing the returned channel will stop the associated goroutine.
func PublishLog ¶
func PublishLog() chan EventBlock
PublishLog returns a channel of EventBlocks after it starts a goroutine that reads from that channel writing the EventBlocks to STDOUT via the log package. Closing the channel will stop the goroutine.
Types ¶
type EventBlock ¶
type EventBlock struct {
// contains filtered or unexported fields
}
type EventsConfig ¶
func FromContext ¶
func FromContext(ctx context.Context) (EventsConfig, bool)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Publish ¶
func (r *Registry) Publish(eb EventBlock)
Publish is called by the goroutine that has gathered events - typically via the Write function. Publish is synchronous on a per-Registry basis however, the actual publication operation for each subscriber happens asynchronously in separate goroutines.
In the event that a subscriber's channel is closed it will be automatically unsubscribed from the Registry.
Publication to each subscriber will timeout after the duration specified during Registry configuration. In such an event the EventBlock will not be written to the subscriber and an error message will be written to the log. Automatically unsubscribing the subscriber in this case would cause more significant data loss in the event of a transient backpressure issue.
func (*Registry) Subscribe ¶
func (r *Registry) Subscribe(name string, c chan EventBlock)
Subscribe is idempotent for a given subscription name