rpc

package
v0.0.0-...-3f67607 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

This is a `net/rpc`-compatible implementation of a client and server for `flux/remote.Platform`.

The purpose is to be able to access a daemon from an upstream service. The daemon makes an outbound connection (over, say, websockets), then the service can make RPC calls over that connection.

On errors:

Errors from the daemon can come in two varieties: application errors (i.e., a `*(flux/errors).Error`), and internal errors (any other `error`). We need to transmit these faithfully over `net/rpc`, which only accounts for `error` (and flattens them to strings for transmission).

To send application errors, we construct response values that are effectively a union of the actual response type, and the error type.

At the client end, we also need to deal with transmission errors -- e.g., a response timing out, or the connection closing abruptly. These are treated as "Fatal" errors; that is, they should result in a disconnection of the daemon as well as being returned to the caller.

On versions:

The RPC protocol is versioned, because server code (in the daemon) is deployed independently of client code (in the upstream service).

We share the RPC protocol versions with the API, because the endpoint for connecting to an upstream service (`/api/flux/<version>/register`) is part of the API.

Since one client (upstream service) has connections to many servers (daemons), it's the client that has explicit versions in the code. The server code always implements just the most recent version.

For backwards-incompatible changes, we must bump the protocol version (and create a new `RegisterDaemon` endpoint).

On contexts:

Sadly, `net/rpc` does not support context.Context, and never will. So we must ignore the contexts passed in. If we change the RPC mechanism, we may be able to address this.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExportResponse

type ExportResponse struct {
	Result           []byte
	ApplicationError *fluxerr.Error
}

type GitRepoConfigResponse

type GitRepoConfigResponse struct {
	Result           flux.GitConfig
	ApplicationError *fluxerr.Error
}

type JobStatusResponse

type JobStatusResponse struct {
	Result           job.Status
	ApplicationError *fluxerr.Error
}

type ListImagesResponse

type ListImagesResponse struct {
	Result           []flux.ImageStatus
	ApplicationError *fluxerr.Error
}

type ListServicesResponse

type ListServicesResponse struct {
	Result           []flux.ControllerStatus
	ApplicationError *fluxerr.Error
}

type NotifyChangeResponse

type NotifyChangeResponse struct {
	ApplicationError *fluxerr.Error
}

type RPCClientV4

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

RPCClientV4 is the rpc-backed implementation of a platform, for talking to remote daemons.

func NewClientV4

func NewClientV4(conn io.ReadWriteCloser) *RPCClientV4

NewClient creates a new rpc-backed implementation of the platform.

func (*RPCClientV4) Close

func (p *RPCClientV4) Close() error

Close closes the connection to the remote platform, it does *not* cause the remote platform to shut down.

func (RPCClientV4) Export

func (bc RPCClientV4) Export(context.Context) ([]byte, error)

func (RPCClientV4) GitRepoConfig

func (bc RPCClientV4) GitRepoConfig(context.Context, bool) (flux.GitConfig, error)

func (RPCClientV4) JobStatus

func (bc RPCClientV4) JobStatus(context.Context, job.ID) (job.Status, error)

func (RPCClientV4) ListImages

func (bc RPCClientV4) ListImages(context.Context, update.ResourceSpec) ([]flux.ImageStatus, error)

func (RPCClientV4) ListServices

func (bc RPCClientV4) ListServices(context.Context, string) ([]flux.ControllerStatus, error)

func (RPCClientV4) NotifyChange

func (bc RPCClientV4) NotifyChange(context.Context, remote.Change) error

func (*RPCClientV4) Ping

func (p *RPCClientV4) Ping(ctx context.Context) error

Ping is used to check if the remote platform is available.

func (RPCClientV4) SyncStatus

func (bc RPCClientV4) SyncStatus(context.Context, string) ([]string, error)

func (RPCClientV4) UpdateManifests

func (bc RPCClientV4) UpdateManifests(context.Context, update.Spec) (job.ID, error)

func (*RPCClientV4) Version

func (p *RPCClientV4) Version(ctx context.Context) (string, error)

Version is used to check if the remote platform is available

type RPCClientV5

type RPCClientV5 struct {
	*RPCClientV4
}

RPCClient is the rpc-backed implementation of a platform, for talking to remote daemons.

func NewClientV5

func NewClientV5(conn io.ReadWriteCloser) *RPCClientV5

NewClient creates a new rpc-backed implementation of the platform.

func (*RPCClientV5) Export

func (p *RPCClientV5) Export(ctx context.Context) ([]byte, error)

Export is used to get service configuration in platform-specific format

func (RPCClientV5) GitRepoConfig

func (bc RPCClientV5) GitRepoConfig(context.Context, bool) (flux.GitConfig, error)

func (RPCClientV5) JobStatus

func (bc RPCClientV5) JobStatus(context.Context, job.ID) (job.Status, error)

func (RPCClientV5) ListImages

func (bc RPCClientV5) ListImages(context.Context, update.ResourceSpec) ([]flux.ImageStatus, error)

func (RPCClientV5) ListServices

func (bc RPCClientV5) ListServices(context.Context, string) ([]flux.ControllerStatus, error)

func (RPCClientV5) NotifyChange

func (bc RPCClientV5) NotifyChange(context.Context, remote.Change) error

func (RPCClientV5) SyncStatus

func (bc RPCClientV5) SyncStatus(context.Context, string) ([]string, error)

func (RPCClientV5) UpdateManifests

func (bc RPCClientV5) UpdateManifests(context.Context, update.Spec) (job.ID, error)

type RPCClientV6

type RPCClientV6 struct {
	*RPCClientV5
}

RPCClient is the rpc-backed implementation of a platform, for talking to remote daemons.

func NewClientV6

func NewClientV6(conn io.ReadWriteCloser) *RPCClientV6

NewClient creates a new rpc-backed implementation of the platform.

func (*RPCClientV6) Export

func (p *RPCClientV6) Export(ctx context.Context) ([]byte, error)

Export is used to get service configuration in platform-specific format

func (*RPCClientV6) GitRepoConfig

func (p *RPCClientV6) GitRepoConfig(ctx context.Context, regenerate bool) (flux.GitConfig, error)

func (*RPCClientV6) JobStatus

func (p *RPCClientV6) JobStatus(ctx context.Context, jobID job.ID) (job.Status, error)

func (*RPCClientV6) ListImages

func (p *RPCClientV6) ListImages(ctx context.Context, spec update.ResourceSpec) ([]flux.ImageStatus, error)

func (*RPCClientV6) ListServices

func (p *RPCClientV6) ListServices(ctx context.Context, namespace string) ([]flux.ControllerStatus, error)

Export is used to get service configuration in platform-specific format

func (RPCClientV6) NotifyChange

func (bc RPCClientV6) NotifyChange(context.Context, remote.Change) error

func (*RPCClientV6) SyncNotify

func (p *RPCClientV6) SyncNotify(ctx context.Context) error

func (*RPCClientV6) SyncStatus

func (p *RPCClientV6) SyncStatus(ctx context.Context, ref string) ([]string, error)

func (*RPCClientV6) UpdateManifests

func (p *RPCClientV6) UpdateManifests(ctx context.Context, u update.Spec) (job.ID, error)

type RPCClientV7

type RPCClientV7 struct {
	*RPCClientV6
}

RPCClient is the rpc-backed implementation of a platform, for talking to remote daemons. Version 7 has the same methods, but transmits error data properly. The reason it needs a new version is that the responses must be decoded differently.

func NewClientV7

func NewClientV7(conn io.ReadWriteCloser) *RPCClientV7

NewClient creates a new rpc-backed implementation of the platform.

func (*RPCClientV7) Export

func (p *RPCClientV7) Export(ctx context.Context) ([]byte, error)

Export is used to get service configuration in platform-specific format

func (*RPCClientV7) GitRepoConfig

func (p *RPCClientV7) GitRepoConfig(ctx context.Context, regenerate bool) (flux.GitConfig, error)

func (*RPCClientV7) JobStatus

func (p *RPCClientV7) JobStatus(ctx context.Context, jobID job.ID) (job.Status, error)

func (*RPCClientV7) ListImages

func (p *RPCClientV7) ListImages(ctx context.Context, spec update.ResourceSpec) ([]flux.ImageStatus, error)

func (*RPCClientV7) ListServices

func (p *RPCClientV7) ListServices(ctx context.Context, namespace string) ([]flux.ControllerStatus, error)

func (RPCClientV7) NotifyChange

func (bc RPCClientV7) NotifyChange(context.Context, remote.Change) error

func (*RPCClientV7) SyncNotify

func (p *RPCClientV7) SyncNotify(ctx context.Context) error

func (*RPCClientV7) SyncStatus

func (p *RPCClientV7) SyncStatus(ctx context.Context, ref string) ([]string, error)

func (*RPCClientV7) UpdateManifests

func (p *RPCClientV7) UpdateManifests(ctx context.Context, u update.Spec) (job.ID, error)

type RPCClientV8

type RPCClientV8 struct {
	*RPCClientV7
}

RPCClient is the rpc-backed implementation of a platform, for talking to remote daemons. Version 8 has the same methods, but supports a different set of resource kinds to earlier versions.

func NewClientV8

func NewClientV8(conn io.ReadWriteCloser) *RPCClientV8

NewClient creates a new rpc-backed implementation of the platform.

func (*RPCClientV8) ListImages

func (p *RPCClientV8) ListImages(ctx context.Context, spec update.ResourceSpec) ([]flux.ImageStatus, error)

func (RPCClientV8) NotifyChange

func (bc RPCClientV8) NotifyChange(context.Context, remote.Change) error

func (*RPCClientV8) UpdateManifests

func (p *RPCClientV8) UpdateManifests(ctx context.Context, u update.Spec) (job.ID, error)

type RPCClientV9

type RPCClientV9 struct {
	*RPCClientV8
}

func NewClientV9

func NewClientV9(conn io.ReadWriteCloser) *RPCClientV9

func (*RPCClientV9) NotifyChange

func (p *RPCClientV9) NotifyChange(ctx context.Context, c remote.Change) error

type RPCServer

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

func (*RPCServer) Export

func (p *RPCServer) Export(_ struct{}, resp *ExportResponse) error

func (*RPCServer) GitRepoConfig

func (p *RPCServer) GitRepoConfig(regenerate bool, resp *GitRepoConfigResponse) error

func (*RPCServer) JobStatus

func (p *RPCServer) JobStatus(jobID job.ID, resp *JobStatusResponse) error

func (*RPCServer) ListImages

func (p *RPCServer) ListImages(spec update.ResourceSpec, resp *ListImagesResponse) error

func (*RPCServer) ListServices

func (p *RPCServer) ListServices(namespace string, resp *ListServicesResponse) error

func (*RPCServer) NotifyChange

func (p *RPCServer) NotifyChange(c remote.Change, resp *NotifyChangeResponse) error

func (*RPCServer) Ping

func (p *RPCServer) Ping(_ struct{}, _ *struct{}) error

func (*RPCServer) SyncStatus

func (p *RPCServer) SyncStatus(ref string, resp *SyncStatusResponse) error

func (*RPCServer) UpdateManifests

func (p *RPCServer) UpdateManifests(spec update.Spec, resp *UpdateManifestsResponse) error

func (*RPCServer) Version

func (p *RPCServer) Version(_ struct{}, resp *string) error

type Server

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

Server takes a platform and makes it available over RPC.

func NewServer

func NewServer(p remote.Platform) (*Server, error)

NewServer instantiates a new RPC server, handling requests on the conn by invoking methods on the underlying (assumed local) platform.

func (*Server) ServeConn

func (c *Server) ServeConn(conn io.ReadWriteCloser)

type SyncNotifyResponse

type SyncNotifyResponse struct {
	ApplicationError *fluxerr.Error
}

type SyncStatusResponse

type SyncStatusResponse struct {
	Result           []string
	ApplicationError *fluxerr.Error
}

type UpdateManifestsResponse

type UpdateManifestsResponse struct {
	Result           job.ID
	ApplicationError *fluxerr.Error
}

Jump to

Keyboard shortcuts

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