counter

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package counter ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client to the counter service.

Note starting with simply routing all streams to the first node.

func NewClient

func NewClient(partitioner Partitioner) *Client

NewClient connects to the counter service and streams the count for subscribed IDs.

func (*Client) Close

func (c *Client) Close()

func (*Client) Register

func (c *Client) Register(id string, onUpdate func(c uint64), onError func(e error)) (func() error, error)

Register registers the user for the given ID, which will call onUpdate whenever the count changes. Returns a function to unregister.

type Murmur3Partitioner

type Murmur3Partitioner struct {
	// contains filtered or unexported fields
}

func NewMurmur3Partitioner

func NewMurmur3Partitioner() *Murmur3Partitioner

func (*Murmur3Partitioner) Locate

func (p *Murmur3Partitioner) Locate(id string, onRelocate func(addr NodeAddr, ok bool)) (NodeAddr, func(), bool)

func (*Murmur3Partitioner) SetNodes

func (p *Murmur3Partitioner) SetNodes(nodes map[string]string)

type NodeAddr

type NodeAddr struct {
	ID   string
	Addr string
}

type Partitioner

type Partitioner interface {
	Locate(id string, onRelocate func(addr NodeAddr, ok bool)) (NodeAddr, func(), bool)
	SetNodes(nodes map[string]string)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL