Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientFacade ¶
func NewClientFacade(caller APICallCloser, facadeName string) (ClientFacade, FacadeCaller)
NewClientFacade prepares a client-facing facade for work against the API. It is expected that most client-facing facades will embed a ClientFacade and will use a FacadeCaller so this function returns both.
Types ¶
type APICallCloser ¶
type APICallCloser interface { APICaller // Close is used when we have finished with this connection. Close() error }
APICallCloser is the same as APICaller, but also provides a Close() method for when we are done with this connection.
type APICaller ¶
type APICaller interface { // APICall makes a call to the API server with the given object type, // id, request and parameters. The response is filled in with the // call's result if the call is successful. APICall(objType string, version int, id, request string, params, response interface{}) error // BestFacadeVersion returns the newest version of 'objType' that this // client can use with the current API server. BestFacadeVersion(facade string) int // EnvironTag returns the tag of the environment the client is // connected to. EnvironTag() (names.EnvironTag, error) }
APICaller is implemented by the client-facing State object.
type ClientFacade ¶
type ClientFacade interface { // BestAPIVersion returns the API version that we were able to // determine is supported by both the client and the API Server BestAPIVersion() int // Close the connection to the API server. Close() error }
ClientFacade should be embedded by client-side facades that are intended as "client" (aka user facing) facades versus agent facing facades. They provide two common methods for writing the client side code. BestAPIVersion() is used to allow for compatibility testing, and Close() is used to indicate when we are done with the connection.
type FacadeCaller ¶
type FacadeCaller interface { // FacadeCall will place a request against the API using the requested // Facade and the best version that the API server supports that is // also known to the client. FacadeCall(request string, params, response interface{}) error // Name returns the facade name. Name() string // BestAPIVersion returns the API version that we were able to // determine is supported by both the client and the API Server BestAPIVersion() int // RawAPICaller returns the wrapped APICaller. This can be used if you need // to switch what Facade you are calling (such as Facades that return // Watchers and then need to use the Watcher facade) RawAPICaller() APICaller }
FacadeCaller is a wrapper for the common paradigm that a given client just wants to make calls on a facade using the best known version of the API. And without dealing with an id parameter.
func NewFacadeCaller ¶
func NewFacadeCaller(caller APICaller, facadeName string) FacadeCaller
NewFacadeCaller wraps an APICaller for a given facade name and the best available version.
func NewFacadeCallerForVersion ¶
func NewFacadeCallerForVersion(caller APICaller, facadeName string, version int) FacadeCaller
NewFacadeCallerForVersion wraps an APICaller for a given facade name and version.