rpc

package
v0.0.0-...-73a212e Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

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

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           v6.GitConfig
	ApplicationError *fluxerr.Error
}

type JobStatusResponse

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

type ListImagesResponse

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

type ListServicesResponse

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

type NotifyChangeResponse

type NotifyChangeResponse struct {
	ApplicationError *fluxerr.Error
}

type RPCClientV10

type RPCClientV10 struct {
	*RPCClientV9
}

RPCClientV10 is the rpc-backed implementation of a server, for talking to remote daemons. This version introduces methods which accept an options struct as the first argument. e.g. ListImagesWithOptions

func NewClientV10

func NewClientV10(conn io.ReadWriteCloser) *RPCClientV10

NewClientV10 creates a new rpc-backed implementation of the server.

func (*RPCClientV10) ListImagesWithOptions

func (p *RPCClientV10) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error)

type RPCClientV6

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

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

func NewClientV6

func NewClientV6(conn io.ReadWriteCloser) *RPCClientV6

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

func (*RPCClientV6) Export

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

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

func (*RPCClientV6) GitRepoConfig

func (p *RPCClientV6) GitRepoConfig(ctx context.Context, regenerate bool) (v6.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) ([]v6.ImageStatus, error)

func (*RPCClientV6) ListImagesWithOptions

func (p *RPCClientV6) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error)

func (*RPCClientV6) ListServices

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

func (RPCClientV6) NotifyChange

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

func (*RPCClientV6) Ping

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

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

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)

func (*RPCClientV6) Version

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

Version is used to check the version of the remote server.

type RPCClientV7

type RPCClientV7 struct {
	*RPCClientV6
}

RPCClient is the rpc-backed implementation of a server, 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 server.

func (*RPCClientV7) Export

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

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

func (*RPCClientV7) GitRepoConfig

func (p *RPCClientV7) GitRepoConfig(ctx context.Context, regenerate bool) (v6.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) ([]v6.ImageStatus, error)

func (*RPCClientV7) ListImagesWithOptions

func (p *RPCClientV7) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error)

func (*RPCClientV7) ListServices

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

func (RPCClientV7) NotifyChange

func (bc RPCClientV7) NotifyChange(context.Context, v9.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 server, 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 server.

func (*RPCClientV8) ListImages

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

func (*RPCClientV8) ListImagesWithOptions

func (p *RPCClientV8) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error)

func (RPCClientV8) NotifyChange

func (bc RPCClientV8) NotifyChange(context.Context, v9.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 v9.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) ListImagesWithOptions

func (p *RPCServer) ListImagesWithOptions(opts v10.ListImagesOptions, resp *ListImagesResponse) error

func (*RPCServer) ListServices

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

func (*RPCServer) NotifyChange

func (p *RPCServer) NotifyChange(c v9.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 an api.Server and makes it available over RPC.

func NewServer

func NewServer(s api.UpstreamServer) (*Server, error)

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

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