meeting

package
v1.12.3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: AGPL-3.0 Imports: 12 Imported by: 6

Documentation

Overview

Package meeting provides a way for one thread of control to wait for information provided by another thread.

Index

Constants

This section is empty.

Variables

View Source
var (

	// Clock holds the clock implementation used by the meeting package.
	// This is exported so it can be changed for testing purposes.
	Clock clock.Clock = clock.WallClock
)

Functions

This section is empty.

Types

type Metrics

type Metrics interface {
	// RequestCompleted is called every time an HTTP
	// request has completed with the time the request started.
	RequestCompleted(startTime time.Time)

	// RequestsExpired is called when some requests
	// have been garbage collected with the number
	// of GC'd requests.
	RequestsExpired(count int)
}

Metrics represents a way to report metrics information about the meeting service. It must be callable concurrently.

type Params

type Params struct {
	// Store is used for storage of persistent data.
	Store Store

	// Metrics holds an object that's used to report server metrics.
	// If it's nil, no metrics will be reported.
	Metrics Metrics

	// ListenAddr holds the host name to listen on. This
	// should not have a port number.
	// Note that ListenAddr must also be sufficient for other
	// servers to use to contact this one.
	ListenAddr string

	// DisableGC holds whether the garbage collector is disabled.
	DisableGC bool

	// WaitTimeout holds the maximum time to that
	// wait requests will wait. If it is zero, a default
	// duration will be used.
	WaitTimeout time.Duration

	// ExpiryDuration holds the maximum amount of time
	// a rendezvous will be kept around for. If it is zero, a default
	// duration will be used.
	ExpiryDuration time.Duration
}

Params holds parameters for the NewServer function.

type Place

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

Place represents a rendezvous place.

func NewPlace

func NewPlace(params Params) (*Place, error)

NewServer returns a new rendezvous place using the given parameters.

func (*Place) Close

func (p *Place) Close()

Close shuts down the rendezvous place.

func (*Place) Done

func (p *Place) Done(ctx context.Context, id string, data []byte) error

Done marks the rendezvous with the given id as complete, and provides it with the given data which will be returned from Wait.

func (*Place) NewRendezvous

func (p *Place) NewRendezvous(ctx context.Context, id string, data []byte) error

NewRendezvous creates a new rendezvous holding the given data. The rendezvous id is returned.

func (*Place) Wait

func (p *Place) Wait(ctx context.Context, id string) (data0, data1 []byte, err error)

Wait waits for the rendezvous with the given id and returns the data provided to NewRendezvous and the data provided to Done.

type Store

type Store interface {
	// Context returns a context that is suitable for passing to the
	// other store methods. Store methods called with such a context
	// will be sequentially consistent; for example, a value that is
	// Put will immediately be available from a Get method.
	//
	// The returned close function must be called when the returned
	// context will no longer be used, to allow for any required
	// cleanup.
	Context(ctx context.Context) (_ context.Context, close func())

	// Put associates an address with the given id.
	Put(ctx context.Context, id, address string) error

	// Get returns the address associated with the given id
	// and removes the association.
	Get(ctx context.Context, id string) (address string, err error)

	// Remove removes the entry with the given id.
	// It should not return an error if the entry has already
	// been removed.
	Remove(ctx context.Context, id string) (time.Time, error)

	// RemoveOld removes entries with the given address that were created
	// earlier than the given time. It returns any ids removed.
	// If it encountered an error while deleting the ids, it
	// may return a non-empty ids slice and a non-nil error.
	RemoveOld(ctx context.Context, address string, olderThan time.Time) (ids []string, err error)
}

Store defines the backing store required by the participants in the rendezvous. Entries created in the store should be visible to all participants.

Jump to

Keyboard shortcuts

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