routetable

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 7 Imported by: 4

Documentation

Overview

Package routetable provides functionality for distributed routing tables used for tracking and managing service instances and their connection states.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key added in v0.0.25

func Key(name, color string, oid int64) string

func NewMasterRouteTable added in v0.0.15

func NewMasterRouteTable(rtd Data, name string, opts ...Option) *masterRouteTable

NewMasterRouteTable creates a new BaseRouteTable with the given data store, name, key generation function, and optional configuration options.

func NewReadOnlyRouteTable added in v0.0.15

func NewReadOnlyRouteTable(rtd Data, name string) *readOnlyRouteTable

NewReadOnlyRouteTable creates a new readOnlyRouteTable with the given data store, name, key generation function.

func NewRenewalRouteTable added in v0.0.15

func NewRenewalRouteTable(rtd Data, name string, opts ...Option) *renewalRouteTable

NewRenewalRouteTable creates a new renewalRouteTable with the given data store, name, key generation function, and optional configuration options.

func SplitKey added in v0.0.25

func SplitKey(key string) (name, color string, oid int64, err error)

Types

type Data added in v0.0.7

type Data interface {
	Get(ctx context.Context, key string) (addr string, err error)
	GetEx(ctx context.Context, key string, ttl time.Duration) (addr string, err error)
	BatchGet(ctx context.Context, keys []string) (addrs []string, err error)
	Set(ctx context.Context, key, addr string, ttl time.Duration) error
	SetNxOrGet(ctx context.Context, key, addr string, ttl time.Duration) (set bool, ret string, err error)
	GetSet(ctx context.Context, key, addr string, ttl time.Duration) (old string, err error)
	Expire(ctx context.Context, key string, expiration time.Duration) error
	ExpireIfSame(ctx context.Context, key, value string, expiration time.Duration) error
	Del(ctx context.Context, key string) error
	DelIfSame(ctx context.Context, key, value string) error
}

Data is an interface for the underlying data storage of route tables.

type MasterRouteTable added in v0.0.15

type MasterRouteTable interface {
	ReNewalRouteTable

	GetEx(ctx context.Context, color string, oid int64) (addr string, err error)
	Set(ctx context.Context, color string, key int64, addr string) error
	GetSet(ctx context.Context, color string, key int64, addr string) (old string, err error)
	SetNxOrGet(ctx context.Context, color string, key int64, addr string) (ok bool, result string, err error)
}

MasterRouteTable is an interface for managing routing table entries. It provides methods for storing, retrieving, and manipulating route information.

type Option

type Option func(*renewalRouteTable)

Option is a function type that configures a BaseRouteTable instance.

func WithTTL

func WithTTL(dur time.Duration) Option

WithTTL returns an Option that sets the time-to-live for route table entries. dur must be greater than 0, otherwise the default TTL will be used.

type ReNewalRouteTable added in v0.0.12

type ReNewalRouteTable interface {
	ReadOnlyRouteTable

	RenewSelf(ctx context.Context, color string, key int64, value string) error
	TTL() time.Duration
}

ReNewalRouteTable is an interface for read-only access to the routing table.

type ReadOnlyRouteTable

type ReadOnlyRouteTable interface {
	BuildKey(color string, oid int64) string
	Get(ctx context.Context, color string, key int64) (addr string, err error)
	BatchGet(ctx context.Context, color string, keys []int64) (addrs []string, err error)
}

type RouteTable

type RouteTable interface {
	MasterRouteTable
}

Directories

Path Synopsis
Package redis provides a Redis-based implementation of the route table.
Package redis provides a Redis-based implementation of the route table.

Jump to

Keyboard shortcuts

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