msgbus: Index | Files | Directories

package msgbus

import ""


Package Files

metrics.go msgbus.go queue.go version.go


const (
    // DefaultMaxQueueSize is the default maximum size of queues
    DefaultMaxQueueSize = 1000 // ~4MB per queue (1000 * 4KB)

    // DefaultMaxPayloadSize is the default maximum payload size
    DefaultMaxPayloadSize = 8192 // 8KB

    // DefaultBufferLength is the default buffer length for subscriber chans
    DefaultBufferLength = 100


var (
    // Version release version
    Version = "0.1.1"

    // Build will be overwritten automatically by the build system
    Build = "dev"

    // GitCommit will be overwritten automatically by the build system
    GitCommit = "HEAD"
var DefObjectives = map[float64]float64{
    0.50: 0.05,
    0.90: 0.01,
    0.95: 0.005,
    0.99: 0.001,

DefObjectives ...

func FullVersion Uses

func FullVersion() string

FullVersion returns the full version, build and commit hash

type Client Uses

type Client struct {
    // contains filtered or unexported fields

Client ...

func NewClient Uses

func NewClient(conn *websocket.Conn, topic *Topic, bus *MessageBus) *Client

NewClient ...

func (*Client) Start Uses

func (c *Client) Start()

Start ...

type HandlerFunc Uses

type HandlerFunc func(msg *Message) error

HandlerFunc ...

type ListenerOptions Uses

type ListenerOptions struct {
    BufferLength int

ListenerOptions ...

type Listeners Uses

type Listeners struct {
    // contains filtered or unexported fields

Listeners ...

func NewListeners Uses

func NewListeners(options *ListenerOptions) *Listeners

NewListeners ...

func (*Listeners) Add Uses

func (ls *Listeners) Add(id string) chan Message

Add ...

func (*Listeners) Exists Uses

func (ls *Listeners) Exists(id string) bool

Exists ...

func (*Listeners) Get Uses

func (ls *Listeners) Get(id string) (chan Message, bool)

Get ...

func (*Listeners) Length Uses

func (ls *Listeners) Length() int

Length ...

func (*Listeners) NotifyAll Uses

func (ls *Listeners) NotifyAll(message Message) int

NotifyAll ...

func (*Listeners) Remove Uses

func (ls *Listeners) Remove(id string)

Remove ...

type Message Uses

type Message struct {
    ID      uint64    `json:"id"`
    Topic   *Topic    `json:"topic"`
    Payload []byte    `json:"payload"`
    Created time.Time `json:"created"`

Message ...

type MessageBus Uses

type MessageBus struct {
    // contains filtered or unexported fields

MessageBus ...

func New Uses

func New(options *Options) *MessageBus

New ...

func (*MessageBus) Get Uses

func (mb *MessageBus) Get(t *Topic) (Message, bool)

Get ...

func (*MessageBus) Len Uses

func (mb *MessageBus) Len() int

Len ...

func (*MessageBus) Metrics Uses

func (mb *MessageBus) Metrics() *Metrics

Metrics ...

func (*MessageBus) NewMessage Uses

func (mb *MessageBus) NewMessage(topic *Topic, payload []byte) Message

NewMessage ...

func (*MessageBus) NewTopic Uses

func (mb *MessageBus) NewTopic(topic string) *Topic

NewTopic ...

func (*MessageBus) Put Uses

func (mb *MessageBus) Put(message Message)

Put ...

func (*MessageBus) ServeHTTP Uses

func (mb *MessageBus) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*MessageBus) Subscribe Uses

func (mb *MessageBus) Subscribe(id, topic string) chan Message

Subscribe ...

func (*MessageBus) Unsubscribe Uses

func (mb *MessageBus) Unsubscribe(id, topic string)

Unsubscribe ...

type Metrics Uses

type Metrics struct {
    // contains filtered or unexported fields

Metrics ...

func NewMetrics Uses

func NewMetrics(namespace string) *Metrics

NewMetrics ...

func (*Metrics) Counter Uses

func (m *Metrics) Counter(subsystem, name string) prometheus.Counter

Counter ...

func (*Metrics) CounterVec Uses

func (m *Metrics) CounterVec(subsystem, name string) *prometheus.CounterVec

CounterVec ...

func (*Metrics) Gauge Uses

func (m *Metrics) Gauge(subsystem, name string) prometheus.Gauge

Gauge ...

func (*Metrics) GaugeVec Uses

func (m *Metrics) GaugeVec(subsystem, name string) *prometheus.GaugeVec

GaugeVec ...

func (*Metrics) Handler Uses

func (m *Metrics) Handler() http.Handler

Handler ...

func (*Metrics) NewCounter Uses

func (m *Metrics) NewCounter(subsystem, name, help string) prometheus.Counter

NewCounter ...

func (*Metrics) NewCounterFunc Uses

func (m *Metrics) NewCounterFunc(subsystem, name, help string, f func() float64) prometheus.CounterFunc

NewCounterFunc ...

func (*Metrics) NewCounterVec Uses

func (m *Metrics) NewCounterVec(subsystem, name, help string, labels []string) *prometheus.CounterVec

NewCounterVec ...

func (*Metrics) NewGauge Uses

func (m *Metrics) NewGauge(subsystem, name, help string) prometheus.Gauge

NewGauge ...

func (*Metrics) NewGaugeFunc Uses

func (m *Metrics) NewGaugeFunc(subsystem, name, help string, f func() float64) prometheus.GaugeFunc

NewGaugeFunc ...

func (*Metrics) NewGaugeVec Uses

func (m *Metrics) NewGaugeVec(subsystem, name, help string, labels []string) *prometheus.GaugeVec

NewGaugeVec ...

func (*Metrics) NewSummary Uses

func (m *Metrics) NewSummary(subsystem, name, help string) prometheus.Summary

NewSummary ...

func (*Metrics) NewSummaryVec Uses

func (m *Metrics) NewSummaryVec(subsystem, name, help string, labels []string) *prometheus.SummaryVec

NewSummaryVec ...

func (*Metrics) Run Uses

func (m *Metrics) Run(addr string)

Run ...

func (*Metrics) Summary Uses

func (m *Metrics) Summary(subsystem, name string) prometheus.Summary

Summary ...

func (*Metrics) SummaryVec Uses

func (m *Metrics) SummaryVec(subsystem, name string) *prometheus.SummaryVec

SummaryVec ...

type Options Uses

type Options struct {
    BufferLength   int
    MaxQueueSize   int
    MaxPayloadSize int
    WithMetrics    bool

Options ...

type Queue Uses

type Queue struct {
    // contains filtered or unexported fields

Queue represents a single instance of a bounded queue data structure with access to both side. If maxlen is non-zero the queue is bounded otherwise unbounded.

func NewQueue Uses

func NewQueue(maxlen *Queue

NewQueue creates a new instance of Queue with the provided maxlen

func (*Queue) Empty Uses

func (q *Queue) Empty() bool

Empty returns true if the queue is empty false otherwise

func (*Queue) Full Uses

func (q *Queue) Full() bool

Full returns true if the queue is full false otherwise

func (*Queue) Len Uses

func (q *Queue) Len() int

Len returns the number of elements currently stored in the queue.

func (*Queue) MaxLen Uses

func (q *Queue) MaxLen() int

MaxLen returns the maxlen of the queue

func (*Queue) Peek Uses

func (q *Queue) Peek() interface{}

Peek returns the element at the front of the queue.

func (*Queue) Pop Uses

func (q *Queue) Pop() interface{}

Pop removes and returns the element from the front of the queue.

func (*Queue) Push Uses

func (q *Queue) Push(elem interface{})

Push appends an element to the back of the queue.

func (*Queue) Size Uses

func (q *Queue) Size() int

Size returns the current size of the queue

type Topic Uses

type Topic struct {
    Name     string    `json:"name"`
    Sequence uint64    `json:"seq"`
    Created  time.Time `json:"created"`

Topic ...

func (*Topic) String Uses

func (t *Topic) String() string



Package msgbus imports 12 packages (graph) and is imported by 5 packages. Updated 2019-09-09. Refresh now. Tools for package owners.