Documentation
¶
Overview ¶
Package apiserver contains the code that provides a RESTful api service
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound determines if the err is an error which indicates that a specified resource was not found.
func MakeAsync ¶
func MakeAsync(fn WorkFunc) <-chan interface{}
MakeAsync takes a function and executes it, delivering the result in the way required by RESTStorage's Update, Delete, and Create methods.
func NewNotFoundErr ¶
NewNotFoundErr returns a new error which indicates that the resource of the kind and the name was not found.
Types ¶
type APIServer ¶
type APIServer struct {
// contains filtered or unexported fields
}
APIServer is an HTTPHandler that delegates to RESTStorage objects. It handles URLs of the form: ${prefix}/${storage_key}[/${object_name}] Where 'prefix' is an arbitrary string, and 'storage_key' points to a RESTStorage object stored in storage.
TODO: consider migrating this to go-restful which is a more full-featured version of the same thing.
func New ¶
func New(storage map[string]RESTStorage, prefix string) *APIServer
New creates a new APIServer object. 'storage' contains a map of handlers. 'prefix' is the hosting path prefix.
type Operation ¶
type Operation struct { ID string // contains filtered or unexported fields }
Operation represents an ongoing action which the server is performing.
func (*Operation) StatusOrResult ¶
StatusOrResult returns status information or the result of the operation if it is complete, with a bool indicating true in the latter case.
type Operations ¶
type Operations struct {
// contains filtered or unexported fields
}
Operations tracks all the ongoing operations.
func NewOperations ¶
func NewOperations() *Operations
NewOperations returns a new Operations repository.
func (*Operations) Get ¶
func (ops *Operations) Get(id string) *Operation
Get returns the operation with the given ID, or nil
func (*Operations) List ¶
func (ops *Operations) List() api.ServerOpList
List operations for an API client.
func (*Operations) NewOperation ¶
func (ops *Operations) NewOperation(from <-chan interface{}) *Operation
NewOperation adds a new operation. It is lock-free.
type RESTStorage ¶
type RESTStorage interface { // List selects resources in the storage which match to the selector. List(labels.Selector) (interface{}, error) // Get finds a resource in the storage by id and returns it. // Although it can return an arbitrary error value, IsNotFound(err) is true for the returned error value err when the specified resource is not found. Get(id string) (interface{}, error) // Delete finds a resource in the storage and deletes it. // Although it can return an arbitrary error value, IsNotFound(err) is true for the returned error value err when the specified resource is not found. Delete(id string) (<-chan interface{}, error) Extract(body []byte) (interface{}, error) Create(interface{}) (<-chan interface{}, error) Update(interface{}) (<-chan interface{}, error) }
RESTStorage is a generic interface for RESTful storage services Resources whicih are exported to the RESTful API of apiserver need to implement this interface.
type ResourceWatcher ¶
type ResourceWatcher interface { WatchAll() (watch.Interface, error) WatchSingle(id string) (watch.Interface, error) }
ResourceWatcher should be implemented by all RESTStorage objects that want to offer the ability to watch for changes through the watch api.
type WatchServer ¶
type WatchServer struct {
// contains filtered or unexported fields
}
WatchServer serves a watch.Interface over a websocket or vanilla HTTP.
func (*WatchServer) HandleWS ¶
func (w *WatchServer) HandleWS(ws *websocket.Conn)
HandleWS implements a websocket handler.
func (*WatchServer) ServeHTTP ¶
func (self *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP serves a series of JSON encoded events via straight HTTP with Transfer-Encoding: chunked.