bannednodes

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 3 Imported by: 2

Documentation

Overview

Package bannednodes defines a concurrent safe node list which may be bound to a context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(ctx context.Context, nodes ...*registry.Node)

Add adds a new node to ctx. Nothing would happen if there's no k-v.

func NewCtx

func NewCtx(ctx context.Context, mandatory bool) context.Context

NewCtx creates a new context and sets its k-v.

Types

type Nodes

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

Nodes is a linked list of registry.Node.

func FromCtx

func FromCtx(ctx context.Context) (nodes *Nodes, mandatory bool, ok bool)

FromCtx returns the node list and a boolean which indicate whether it is abandoned. FromCtx does not return a bannedNodes, but a read only linked list. The internal lock is not exported to external user.

func (*Nodes) Range

func (nodes *Nodes) Range(f func(n *registry.Node) bool) bool

Range likes the Range method of sync.Map. It calls f serially for each node in Nodes. Range stops on f failed. Range returns true after traversing all nodes, false otherwise. Users should not change n in f.

Jump to

Keyboard shortcuts

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