locate

package
v2.6.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

Package locate defines the locator abstraction used to track the gate and node a user is bound to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	UID     int64     `json:"uid"`     // User ID
	Type    EventType `json:"type"`    // Event type
	InsID   string    `json:"insID"`   // Instance ID
	InsKind string    `json:"insKind"` // Instance kind
	InsName string    `json:"insName"` // Instance name
}

Event describes a change to a user location.

type EventType

type EventType int

EventType is the type of a location event.

const (
	BindGate   EventType = iota + 1 // BindGate: the user is bound to a gate
	BindNode                        // BindNode: the user is bound to a node
	UnbindGate                      // UnbindGate: the user is unbound from a gate
	UnbindNode                      // UnbindNode: the user is unbound from a node
)

The types of a location event.

type Locator

type Locator interface {
	// Name returns the component name of the locator.
	Name() string
	// Watch watches changes to user locations, optionally filtered by kinds.
	Watch(ctx context.Context, kinds ...string) (Watcher, error)
	// BindGate binds the user to the gate identified by gid.
	BindGate(ctx context.Context, uid int64, gid string) error
	// BindNode binds the user to the node identified by name and nid.
	BindNode(ctx context.Context, uid int64, name, nid string) error
	// UnbindGate unbinds the user from the gate identified by gid.
	UnbindGate(ctx context.Context, uid int64, gid string) error
	// UnbindNode unbinds the user from the node identified by name and nid.
	UnbindNode(ctx context.Context, uid int64, name string, nid string) error
	// LocateGate locates the gate the user is bound to.
	LocateGate(ctx context.Context, uid int64) (string, error)
	// LocateNode locates the node the user is bound to under the given name.
	LocateNode(ctx context.Context, uid int64, name string) (string, error)
	// LocateNodes locates every node the user is bound to.
	LocateNodes(ctx context.Context, uid int64) (map[string]string, error)
	// Close closes the locator.
	Close() error
}

Locator locates the gate and the node a user is bound to.

type Watcher

type Watcher interface {
	// Next returns the next batch of user location events.
	Next() ([]*Event, error)
	// Stop stops watching.
	Stop() error
}

Watcher watches changes to user locations.

Jump to

Keyboard shortcuts

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