server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: MPL-2.0 Imports: 30 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 a endpoint is not listed, the DefaultEffect value is used.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

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 MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func NewStatus

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

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

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

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.

Types

type AuthChecker

type AuthChecker interface {
	// Called before each RPC to authenticate it.
	Authenticate(ctx context.Context, token, endpoint string, effects []string) 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.

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.

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 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 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