pool

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: GPL-2.0, MIT Imports: 15 Imported by: 0

Documentation

Overview

Package pool is

Index

Constants

View Source
const MAX_LOCKS = MaxLocks

Deprecated: uses snake case - use MaxLocks instead

View Source
const MaxLocks = 50

Variables

This section is empty.

Functions

func PointerHasher

func PointerHasher(_ maphash.Seed, k string) uint64

Types

type IncomingEvent

type IncomingEvent struct {
	Event *event.T
	Relay *client.T
}

type Option

type Option interface {
	IsPoolOption()
	Apply(*Simple)
}

type Simple

type Simple struct {
	Relays *xsync.MapOf[string, *client.T]

	Context context.T
	// contains filtered or unexported fields
}

func NewSimplePool

func NewSimplePool(c context.T, opts ...Option) (p *Simple)

func (*Simple) EnsureRelay

func (p *Simple) EnsureRelay(url string) (rl *client.T, err error)

func (*Simple) QuerySingle

func (p *Simple) QuerySingle(c context.T, urls []string, f *filter.T, unique bool) *IncomingEvent

QuerySingle returns the first event returned by the first relay, cancels everything else.

func (*Simple) SubMany

func (p *Simple) SubMany(c context.T, urls []string, f filters.T,
	unique bool) chan IncomingEvent

SubMany opens a subscription with the given filters to multiple relays the subscriptions only end when the context is canceled

func (*Simple) SubManyEose

func (p *Simple) SubManyEose(c context.T, urls []string, f filters.T, unique bool) chan IncomingEvent

SubManyEose is like SubMany, but it stops subscriptions and closes the channel when gets a EOSE

func (*Simple) SubManyEoseNonUnique

func (p *Simple) SubManyEoseNonUnique(c context.T, urls []string, f filters.T, unique bool) chan IncomingEvent

SubManyEoseNonUnique is like SubManyEose, but returns duplicate events if they come from different relays

func (*Simple) SubManyNonUnique

func (p *Simple) SubManyNonUnique(c context.T, urls []string, filters filters.T, unique bool) chan IncomingEvent

SubManyNonUnique is like SubMany, but returns duplicate events if they come from different relays

type WithAuthHandler

type WithAuthHandler func(authEvent *event.T) error

WithAuthHandler must be a function that signs the auth event when called. it will be called whenever any relay in the pool returns a `CLOSED` message with the "auth-required:" prefix, only once for each relay

func (WithAuthHandler) Apply

func (h WithAuthHandler) Apply(pool *Simple)

func (WithAuthHandler) IsPoolOption

func (_ WithAuthHandler) IsPoolOption()

Jump to

Keyboard shortcuts

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