rendezvous

package
v0.0.0-...-be868c5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderID is the HTTP header used for passing the gomote ID.
	HeaderID = "X-Go-Gomote-ID"
	// HeaderToken is the HTTP header used for passing in the authentication token.
	HeaderToken = "X-Go-Swarming-Auth-Token"
	// HeaderHostname is the HTTP header used for passing in the hostname.
	HeaderHostname = "X-Go-Hostname"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeRendezvous

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

FakeRendezvous is a fake rendezvous implementation intended for use in testing.

func NewFake

func NewFake(ctx context.Context, validator TokenValidator) *FakeRendezvous

NewFake creates a Fake Rendezvous instance.

func (*FakeRendezvous) DeregisterInstance

func (rdv *FakeRendezvous) DeregisterInstance(ctx context.Context, id string)

DeregisterInstance is a fake implementation.

func (*FakeRendezvous) HandleReverse

func (rdv *FakeRendezvous) HandleReverse(w http.ResponseWriter, r *http.Request)

HandleReverse is a fake implementation of the handler.

func (*FakeRendezvous) RegisterInstance

func (rdv *FakeRendezvous) RegisterInstance(ctx context.Context, id string, wait time.Duration)

RegisterInstance is a fake implementation.

func (*FakeRendezvous) WaitForInstance

func (rdv *FakeRendezvous) WaitForInstance(ctx context.Context, id string) (buildlet.Client, error)

WaitForInstance is a fake implementation.

type Option

type Option func(*Rendezvous)

Option is an optional configuration setting.

func OptionValidator

func OptionValidator(v TokenValidator) Option

OptionValidator changes the verifier used by Rendezvous.

type Rendezvous

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

Rendezvous waits for buildlets to connect, verifies they are valid instances and passes the connection to the waiting caller.

func New

func New(ctx context.Context, opts ...Option) *Rendezvous

New creates a Rendezvous element. The context that is passed in should be non-canceled during the lifetime of the running service.

func (*Rendezvous) DeregisterInstance

func (rdv *Rendezvous) DeregisterInstance(ctx context.Context, id string)

DeregisterInstance removes the registration for an instance which has been previously registered.

func (*Rendezvous) HandleReverse

func (rdv *Rendezvous) HandleReverse(w http.ResponseWriter, r *http.Request)

HandleReverse handles HTTP requests from the buildlet and passes the connection to the waiter.

func (*Rendezvous) RegisterInstance

func (rdv *Rendezvous) RegisterInstance(ctx context.Context, id string, wait time.Duration)

RegisterInstance notes an instance and waits for that instance to connect to the handler. An instance must be registered before the instance can attempt to connect. If an instance does not connect before the end of the wait period, the instance will not be able to connect.

func (*Rendezvous) WaitForInstance

func (rdv *Rendezvous) WaitForInstance(ctx context.Context, id string) (buildlet.Client, error)

WaitForInstance waits for the registered instance to successfully connect. It waits for the lifetime of the context. If the instance is not registered or has exceeded the timeout period, it will immediately return an error.

type TokenValidator

type TokenValidator func(ctx context.Context, jwt string) bool

TokenValidator verifies if a token is valid.

Jump to

Keyboard shortcuts

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