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 ¶
- type ExportResponse
- type GitRepoConfigResponse
- type JobStatusResponse
- type ListImagesResponse
- type ListServicesResponse
- type NotifyChangeResponse
- type RPCClientV10
- type RPCClientV11
- type RPCClientV6
- func (p *RPCClientV6) Export(ctx context.Context) ([]byte, error)
- func (p *RPCClientV6) GitRepoConfig(ctx context.Context, regenerate bool) (v6.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) ([]v6.ImageStatus, error)
- func (p *RPCClientV6) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error)
- func (p *RPCClientV6) ListServices(ctx context.Context, namespace string) ([]v6.ControllerStatus, error)
- func (p *RPCClientV6) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error)
- func (bc RPCClientV6) NotifyChange(context.Context, v9.Change) error
- func (p *RPCClientV6) Ping(ctx context.Context) 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)
- func (p *RPCClientV6) Version(ctx context.Context) (string, error)
- type RPCClientV7
- func (p *RPCClientV7) Export(ctx context.Context) ([]byte, error)
- func (p *RPCClientV7) GitRepoConfig(ctx context.Context, regenerate bool) (v6.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) ([]v6.ImageStatus, error)
- func (p *RPCClientV7) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error)
- func (p *RPCClientV7) ListServices(ctx context.Context, namespace string) ([]v6.ControllerStatus, error)
- func (p *RPCClientV7) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error)
- func (bc RPCClientV7) NotifyChange(context.Context, v9.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
- func (p *RPCClientV8) ListImages(ctx context.Context, spec update.ResourceSpec) ([]v6.ImageStatus, error)
- func (p *RPCClientV8) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesOptions) ([]v6.ImageStatus, error)
- func (p *RPCClientV8) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error)
- func (bc RPCClientV8) NotifyChange(context.Context, v9.Change) error
- func (p *RPCClientV8) UpdateManifests(ctx context.Context, u update.Spec) (job.ID, error)
- 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) ListImagesWithOptions(opts v10.ListImagesOptions, resp *ListImagesResponse) error
- func (p *RPCServer) ListServices(namespace string, resp *ListServicesResponse) error
- func (p *RPCServer) NotifyChange(c v9.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 []v6.ImageStatus ApplicationError *fluxerr.Error }
type ListServicesResponse ¶
type ListServicesResponse struct { Result []v6.ControllerStatus ApplicationError *fluxerr.Error }
type NotifyChangeResponse ¶
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 RPCClientV11 ¶
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 ¶
func NewClientV11(conn io.ReadWriteCloser) *RPCClientV11
NewClientV11 creates a new rpc-backed implementation of the server.
func (*RPCClientV11) ListServicesWithOptions ¶
func (p *RPCClientV11) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, 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 (*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) ListServicesWithOptions ¶
func (p *RPCClientV6) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, error)
func (RPCClientV6) NotifyChange ¶
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 (*RPCClientV6) UpdateManifests ¶
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 (*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) ListServicesWithOptions ¶
func (p *RPCClientV7) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.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 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) ListServicesWithOptions ¶
func (p *RPCClientV8) ListServicesWithOptions(ctx context.Context, opts v11.ListServicesOptions) ([]v6.ControllerStatus, 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) 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) 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 an api.Server 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) server.
func (*Server) ServeConn ¶
func (c *Server) ServeConn(conn io.ReadWriteCloser)