match

package
v0.0.0-...-33825f2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package match builds a tree of active subscriptions that is matched against all incoming updates.

Index

Constants

View Source
const Glob = "*"

Glob is a special string used to indicate a match of any path node.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Update(interface{})
}

Client is a interface for a callback invoked for all matching updates.

type Match

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

Match is a structure that will invoke registered query callbacks for each matching update.

func New

func New() *Match

New creates a new Match structure.

func (*Match) AddQuery

func (m *Match) AddQuery(query []string, client Client) (remove func())

AddQuery registers a client callback for all matching nodes. It returns a callback to remove the query. The remove function is idempotent.

func (*Match) Update

func (m *Match) Update(n interface{}, p []string)

Update invokes all client callbacks for queries that match the supplied node.

func (*Match) UpdateOnce

func (m *Match) UpdateOnce(n interface{}, p []string, updated map[Client]struct{})

UpdateOnce invokes the callback of each client whose query matches the supplied node and if the client hasn't been updated (in which case it is not in the updated). If the callback of a client has been invoked in this call, the client will be added to updated if updated is not nil. Therefore, in order to track updated clients, updated must not be nil.

Jump to

Keyboard shortcuts

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