server

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MPL-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEffects = []string{"mutable"}
View Source
var Effects = map[string][]string{
	"ListBuilds": readonly,
}

Information about the effects of endpoints that are authenticated. If an endpoint is not listed, the DefaultEffect value is used.

Functions

func Id

func Id() (string, error)

Id returns a unique Id that can be used for new values. This generates a ulid value but the ID itself should be an internal detail. An error will be returned if the ID could be generated.

func NewStatus

func NewStatus(init pb.Status_State) *pb.Status

NewStatus returns a new Status message with the given initial state.

func Run

func Run(opts ...Option) error

Run initializes and starts the server. This will block until the server exits (by cancelling the associated context set with WithContext or due to an unrecoverable error).

func StatusSetError

func StatusSetError(s *pb.Status, err error)

StatusSetError sets the error state on the status and marks the completion time.

func StatusSetSuccess

func StatusSetSuccess(s *pb.Status)

StatusSetSuccess sets state of the status to success and marks the completion time.

func TestServer

func TestServer(t testing.T, impl pb.WaypointServer, opts ...TestOption) pb.WaypointClient

TestServer starts a server and returns a gRPC client to that server. We use t.Cleanup to ensure resources are automatically cleaned up.

func TestVersionInfoResponse added in v0.7.0

func TestVersionInfoResponse() *pb.GetVersionInfoResponse

TestVersionInfoResponse generates a valid version info response for testing

Types

type AuthChecker

type AuthChecker interface {
	// Called before each RPC to authenticate it. The implementation may
	// return a new context if they want to insert authentication information
	// into it (such as the current user). The implementation may return a nil
	// context and the existing context will be used.
	Authenticate(
		ctx context.Context,
		token, endpoint string,
		effects []string,
	) (context.Context, error)
}

An interface implemented by something that wishes to authenticate the server actions.

type Option

type Option func(*options)

Option configures Run

func WithAuthentication

func WithAuthentication(ac AuthChecker) Option

WithAuthentication configures the server to require authentication.

func WithBrowserUI

func WithBrowserUI(enabled bool) Option

WithBrowserUI configures the server to enable the browser UI.

func WithContext

func WithContext(ctx context.Context) Option

WithContext sets the context for the server. When this context is cancelled, the server will be shut down.

func WithGRPC

func WithGRPC(ln net.Listener) Option

WithGRPC sets the GRPC listener. This listener must be closed manually by the caller. Prior to closing the listener, it is recommended that you cancel the context set with WithContext and wait for Run to return.

func WithHTTP

func WithHTTP(ln net.Listener) Option

WithHTTP sets the HTTP listener. This listener must be closed manually by the caller. Prior to closing the listener, it is recommended that you cancel the context set with WithContext and wait for Run to return.

If this is called multiple times, multiple HTTP listeners are started.

func WithImpl

func WithImpl(impl pb.WaypointServer) Option

WithImpl sets the service implementation to serve.

func WithLogger

func WithLogger(log hclog.Logger) Option

WithLogger sets the logger.

func WithTelemetry added in v0.6.0

func WithTelemetry(enabled bool) Option

WithTelemetry instructs the server to export OpenCensus traces for requests.

type TestOption

type TestOption func(*testConfig)

TestOption is used with TestServer to configure test behavior.

func TestWithContext

func TestWithContext(ctx context.Context) TestOption

TestWithContext specifies a context to use with the test server. When this is done then the server will exit.

func TestWithRestart

func TestWithRestart(ch <-chan struct{}) TestOption

TestWithRestart specifies a channel that will be sent to trigger a restart. The restart happens asynchronously. If you want to ensure the server is shutdown first, use TestWithContext, shut it down, wait for errors on the API, then restart.

Directories

Path Synopsis
Package component has component implementations for the various resulting types.
Package component has component implementations for the various resulting types.
gen
Package grpcmetadata contains functions for reading and writing waypoint specific metadata to contexts, which is transmitted by RPC calls.
Package grpcmetadata contains functions for reading and writing waypoint specific metadata to contexts, which is transmitted by RPC calls.
Package httpapi implements the shared endpoints that are implemented over the HTTP protocol rather than gRPC.
Package httpapi implements the shared endpoints that are implemented over the HTTP protocol rather than gRPC.
Package logbuffer provides a structure and API for efficiently reading and writing logs that may be streamed to a server.
Package logbuffer provides a structure and API for efficiently reading and writing logs that may be streamed to a server.
state
Package state manages the state that the singleprocess server has, providing operations to mutate that state safely as needed.
Package state manages the state that the singleprocess server has, providing operations to mutate that state safely as needed.

Jump to

Keyboard shortcuts

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