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 ¶
- type ExportResponse
- type GitRepoConfigResponse
- type JobStatusResponse
- type ListImagesResponse
- type ListServicesResponse
- type NotifyChangeResponse
- type RPCClientV4
- func (p *RPCClientV4) Close() error
- func (bc RPCClientV4) Export(context.Context) ([]byte, error)
- func (bc RPCClientV4) GitRepoConfig(context.Context, bool) (flux.GitConfig, error)
- func (bc RPCClientV4) JobStatus(context.Context, job.ID) (job.Status, error)
- func (bc RPCClientV4) ListImages(context.Context, update.ResourceSpec) ([]flux.ImageStatus, error)
- func (bc RPCClientV4) ListServices(context.Context, string) ([]flux.ControllerStatus, error)
- func (bc RPCClientV4) NotifyChange(context.Context, remote.Change) error
- func (p *RPCClientV4) Ping(ctx context.Context) error
- func (bc RPCClientV4) SyncStatus(context.Context, string) ([]string, error)
- func (bc RPCClientV4) UpdateManifests(context.Context, update.Spec) (job.ID, error)
- func (p *RPCClientV4) Version(ctx context.Context) (string, error)
- type RPCClientV5
- func (p *RPCClientV5) Export(ctx context.Context) ([]byte, error)
- func (bc RPCClientV5) GitRepoConfig(context.Context, bool) (flux.GitConfig, error)
- func (bc RPCClientV5) JobStatus(context.Context, job.ID) (job.Status, error)
- func (bc RPCClientV5) ListImages(context.Context, update.ResourceSpec) ([]flux.ImageStatus, error)
- func (bc RPCClientV5) ListServices(context.Context, string) ([]flux.ControllerStatus, error)
- func (bc RPCClientV5) NotifyChange(context.Context, remote.Change) error
- func (bc RPCClientV5) SyncStatus(context.Context, string) ([]string, error)
- func (bc RPCClientV5) UpdateManifests(context.Context, update.Spec) (job.ID, error)
- type RPCClientV6
- func (p *RPCClientV6) Export(ctx context.Context) ([]byte, error)
- func (p *RPCClientV6) GitRepoConfig(ctx context.Context, regenerate bool) (flux.GitConfig, error)
- func (p *RPCClientV6) JobStatus(ctx context.Context, jobID job.ID) (job.Status, error)
- func (p *RPCClientV6) ListImages(ctx context.Context, spec update.ResourceSpec) ([]flux.ImageStatus, error)
- func (p *RPCClientV6) ListServices(ctx context.Context, namespace string) ([]flux.ControllerStatus, error)
- func (bc RPCClientV6) NotifyChange(context.Context, remote.Change) error
- func (p *RPCClientV6) SyncNotify(ctx context.Context) error
- func (p *RPCClientV6) SyncStatus(ctx context.Context, ref string) ([]string, error)
- func (p *RPCClientV6) UpdateManifests(ctx context.Context, u update.Spec) (job.ID, error)
- type RPCClientV7
- func (p *RPCClientV7) Export(ctx context.Context) ([]byte, error)
- func (p *RPCClientV7) GitRepoConfig(ctx context.Context, regenerate bool) (flux.GitConfig, error)
- func (p *RPCClientV7) JobStatus(ctx context.Context, jobID job.ID) (job.Status, error)
- func (p *RPCClientV7) ListImages(ctx context.Context, spec update.ResourceSpec) ([]flux.ImageStatus, error)
- func (p *RPCClientV7) ListServices(ctx context.Context, namespace string) ([]flux.ControllerStatus, error)
- func (bc RPCClientV7) NotifyChange(context.Context, remote.Change) error
- func (p *RPCClientV7) SyncNotify(ctx context.Context) error
- func (p *RPCClientV7) SyncStatus(ctx context.Context, ref string) ([]string, error)
- func (p *RPCClientV7) UpdateManifests(ctx context.Context, u update.Spec) (job.ID, error)
- type RPCClientV8
- type RPCClientV9
- type RPCServer
- func (p *RPCServer) Export(_ struct{}, resp *ExportResponse) error
- func (p *RPCServer) GitRepoConfig(regenerate bool, resp *GitRepoConfigResponse) error
- func (p *RPCServer) JobStatus(jobID job.ID, resp *JobStatusResponse) error
- func (p *RPCServer) ListImages(spec update.ResourceSpec, resp *ListImagesResponse) error
- func (p *RPCServer) ListServices(namespace string, resp *ListServicesResponse) error
- func (p *RPCServer) NotifyChange(c remote.Change, resp *NotifyChangeResponse) error
- func (p *RPCServer) Ping(_ struct{}, _ *struct{}) error
- func (p *RPCServer) SyncStatus(ref string, resp *SyncStatusResponse) error
- func (p *RPCServer) UpdateManifests(spec update.Spec, resp *UpdateManifestsResponse) error
- func (p *RPCServer) Version(_ struct{}, resp *string) error
- type Server
- type SyncNotifyResponse
- type SyncStatusResponse
- type UpdateManifestsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExportResponse ¶
type GitRepoConfigResponse ¶
type JobStatusResponse ¶
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 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) GitRepoConfig ¶
func (RPCClientV4) ListImages ¶
func (bc RPCClientV4) ListImages(context.Context, update.ResourceSpec) ([]flux.ImageStatus, error)
func (RPCClientV4) ListServices ¶
func (RPCClientV4) NotifyChange ¶
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 (RPCClientV4) UpdateManifests ¶
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 (RPCClientV5) ListImages ¶
func (bc RPCClientV5) ListImages(context.Context, update.ResourceSpec) ([]flux.ImageStatus, error)
func (RPCClientV5) ListServices ¶
func (RPCClientV5) NotifyChange ¶
func (RPCClientV5) SyncStatus ¶
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 (*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 (*RPCClientV6) SyncNotify ¶
func (p *RPCClientV6) SyncNotify(ctx context.Context) error
func (*RPCClientV6) SyncStatus ¶
func (*RPCClientV6) UpdateManifests ¶
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 (*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 (*RPCClientV7) SyncNotify ¶
func (p *RPCClientV7) SyncNotify(ctx context.Context) error
func (*RPCClientV7) SyncStatus ¶
func (*RPCClientV7) UpdateManifests ¶
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 (*RPCClientV8) UpdateManifests ¶
type RPCClientV9 ¶
type RPCClientV9 struct {
*RPCClientV8
}
func NewClientV9 ¶
func NewClientV9(conn io.ReadWriteCloser) *RPCClientV9
func (*RPCClientV9) NotifyChange ¶
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) SyncStatus ¶
func (p *RPCServer) SyncStatus(ref string, resp *SyncStatusResponse) error
func (*RPCServer) UpdateManifests ¶
func (p *RPCServer) UpdateManifests(spec update.Spec, resp *UpdateManifestsResponse) error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server takes a platform and makes it available over RPC.
func NewServer ¶
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)