flux: github.com/weaveworks/flux/pkg/remote/rpc Index | Files

package rpc

import "github.com/weaveworks/flux/pkg/remote/rpc"

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

Package Files

baseclient.go clientV10.go clientV11.go clientV6.go clientV7.go clientV8.go clientV9.go compat.go doc.go server.go

type ExportResponse Uses

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

type GitRepoConfigResponse Uses

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

type JobStatusResponse Uses

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

type ListImagesResponse Uses

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

type ListServicesResponse Uses

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

type NotifyChangeResponse Uses

type NotifyChangeResponse struct {
    ApplicationError *fluxerr.Error
}

type RPCClientV10 Uses

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 Uses

func NewClientV10(conn io.ReadWriteCloser) *RPCClientV10

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

func (*RPCClientV10) ListImagesWithOptions Uses

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

type RPCClientV11 Uses

type RPCClientV11 struct {
    *RPCClientV10
}

RPCClientV11 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. ListServicesWithOptions

func NewClientV11 Uses

func NewClientV11(conn io.ReadWriteCloser) *RPCClientV11

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

func (*RPCClientV11) ListServicesWithOptions Uses

func (p *RPCClientV11) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error)

type RPCClientV6 Uses

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

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

func NewClientV6 Uses

func NewClientV6(conn io.ReadWriteCloser) *RPCClientV6

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

func (*RPCClientV6) Export Uses

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

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

func (*RPCClientV6) GitRepoConfig Uses

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

func (*RPCClientV6) JobStatus Uses

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

func (*RPCClientV6) ListImages Uses

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

func (*RPCClientV6) ListImagesWithOptions Uses

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

func (*RPCClientV6) ListServices Uses

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

func (*RPCClientV6) ListServicesWithOptions Uses

func (p *RPCClientV6) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error)

func (RPCClientV6) NotifyChange Uses

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

func (*RPCClientV6) Ping Uses

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

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

func (*RPCClientV6) SyncNotify Uses

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

func (*RPCClientV6) SyncStatus Uses

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

func (*RPCClientV6) UpdateManifests Uses

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

func (*RPCClientV6) Version Uses

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

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

type RPCClientV7 Uses

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 Uses

func NewClientV7(conn io.ReadWriteCloser) *RPCClientV7

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

func (*RPCClientV7) Export Uses

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

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

func (*RPCClientV7) GitRepoConfig Uses

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

func (*RPCClientV7) JobStatus Uses

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

func (*RPCClientV7) ListImages Uses

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

func (*RPCClientV7) ListImagesWithOptions Uses

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

func (*RPCClientV7) ListServices Uses

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

func (*RPCClientV7) ListServicesWithOptions Uses

func (p *RPCClientV7) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error)

func (RPCClientV7) NotifyChange Uses

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

func (*RPCClientV7) SyncNotify Uses

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

func (*RPCClientV7) SyncStatus Uses

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

func (*RPCClientV7) UpdateManifests Uses

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

type RPCClientV8 Uses

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 Uses

func NewClientV8(conn io.ReadWriteCloser) *RPCClientV8

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

func (*RPCClientV8) ListImages Uses

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

func (*RPCClientV8) ListImagesWithOptions Uses

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

func (*RPCClientV8) ListServicesWithOptions Uses

func (p *RPCClientV8) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error)

func (RPCClientV8) NotifyChange Uses

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

func (*RPCClientV8) UpdateManifests Uses

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

type RPCClientV9 Uses

type RPCClientV9 struct {
    *RPCClientV8
}

func NewClientV9 Uses

func NewClientV9(conn io.ReadWriteCloser) *RPCClientV9

func (*RPCClientV9) NotifyChange Uses

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

type RPCServer Uses

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

func (*RPCServer) Export Uses

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

func (*RPCServer) GitRepoConfig Uses

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

func (*RPCServer) JobStatus Uses

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

func (*RPCServer) ListImages Uses

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

func (*RPCServer) ListImagesWithOptions Uses

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

func (*RPCServer) ListServices Uses

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

func (*RPCServer) NotifyChange Uses

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

func (*RPCServer) Ping Uses

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

func (*RPCServer) SyncStatus Uses

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

func (*RPCServer) UpdateManifests Uses

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

func (*RPCServer) Version Uses

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

type Server Uses

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

Server takes an api.Server and makes it available over RPC.

func NewServer Uses

func NewServer(s api.Server, t time.Duration) (*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 Uses

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

type SyncNotifyResponse Uses

type SyncNotifyResponse struct {
    ApplicationError *fluxerr.Error
}

type SyncStatusResponse Uses

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

type UpdateManifestsResponse Uses

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

Package rpc imports 21 packages (graph). Updated 2020-05-01. Refresh now. Tools for package owners.