rest

package
v0.0.0-...-acd0f33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2015 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RESTMethodOrds = map[string]string{
	"GET":    "0",
	"POST":   "1",
	"PUT":    "2",
	"DELETE": "3",
}
View Source
var StartTime = time.Now()

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetFS

func AssetFS() *assetfs.AssetFS

AssetFS returns the assetfs.AssetFS "filesystem" that holds static HTTP resources (css/html/js/images, etc) for the web UI.

Users might introduce their own static HTTP resources and override resources from AssetFS() with their own resource lookup chaining.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func DiagGetPProf

func DiagGetPProf(w http.ResponseWriter, profile string, debug int)

func DocIDLookup

func DocIDLookup(req *http.Request) string

func IndexNameLookup

func IndexNameLookup(req *http.Request) string

func InitRESTRouter

func InitRESTRouter(r *mux.Router, versionMain string,
	mgr *cbgt.Manager, staticDir, staticETag string,
	mr *cbgt.MsgRing,
	assetDir func(name string) ([]string, error),
	asset func(name string) ([]byte, error)) (
	*mux.Router, map[string]RESTMeta, error)

InitRESTRouter initializes a mux.Router with REST API routes.

func InitStaticRouter

func InitStaticRouter(r *mux.Router, staticDir, staticETag string,
	pages []string, pagesHandler http.Handler) *mux.Router

InitStaticRouter adds static HTTP resource routes to a router.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MustEncode

func MustEncode(w io.Writer, i interface{})

func MuxVariableLookup

func MuxVariableLookup(req *http.Request, name string) string

func NewRESTRouter

func NewRESTRouter(versionMain string, mgr *cbgt.Manager,
	staticDir, staticETag string, mr *cbgt.MsgRing,
	assetDir func(name string) ([]string, error),
	asset func(name string) ([]byte, error)) (
	*mux.Router, map[string]RESTMeta, error)

NewRESTRouter creates a mux.Router initialized with the REST API and web UI routes. See also InitStaticRouter and InitRESTRouter if you need finer control of the router initialization.

func PIndexNameLookup

func PIndexNameLookup(req *http.Request) string

func PIndexTypesInitRouter

func PIndexTypesInitRouter(r *mux.Router, phase string)

PIndexTypesInitRouter initializes a mux.Router with the REST API routes provided by registered pindex types.

func RESTGetRuntimeArgs

func RESTGetRuntimeArgs(w http.ResponseWriter, r *http.Request)

func RESTGetRuntimeStats

func RESTGetRuntimeStats(w http.ResponseWriter, r *http.Request)

func RESTGetRuntimeStatsMem

func RESTGetRuntimeStatsMem(w http.ResponseWriter, r *http.Request)

func RESTPostRuntimeGC

func RESTPostRuntimeGC(w http.ResponseWriter, r *http.Request)

func RESTProfileCPU

func RESTProfileCPU(w http.ResponseWriter, r *http.Request)

To start a cpu profiling...

curl -X POST http://127.0.0.1:9090/api/runtime/profile/cpu -d secs=5

To analyze a profiling...

go tool pprof [program-binary] run-cpu.pprof

func RESTProfileMemory

func RESTProfileMemory(w http.ResponseWriter, r *http.Request)

To grab a memory profiling...

curl -X POST http://127.0.0.1:9090/api/runtime/profile/memory

To analyze a profiling...

go tool pprof [program-binary] run-memory.pprof

func RestoreAsset

func RestoreAsset(dir, name string) error

Restore an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

Restore assets under the given directory recursively

func RewriteURL

func RewriteURL(to string, h http.Handler) http.Handler

RewriteURL is a helper function that returns a URL path rewriter HandlerFunc, rewriting the URL path to a provided "to" string.

func ShowError

func ShowError(w http.ResponseWriter, r *http.Request,
	msg string, code int)

Types

type CfgGetHandler

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

CfgGetHandler is a REST handler that retrieves the contents of the Cfg system.

func NewCfgGetHandler

func NewCfgGetHandler(mgr *cbgt.Manager) *CfgGetHandler

func (*CfgGetHandler) ServeHTTP

func (h *CfgGetHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type CfgRefreshHandler

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

CfgRefreshHandler is a REST handler that processes a request for the manager/node to refresh its cached snapshot of the Cfg system contents.

func NewCfgRefreshHandler

func NewCfgRefreshHandler(mgr *cbgt.Manager) *CfgRefreshHandler

func (*CfgRefreshHandler) ServeHTTP

func (h *CfgRefreshHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type CountHandler

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

CountHandler is a REST handler for counting documents/entries in an index.

func NewCountHandler

func NewCountHandler(mgr *cbgt.Manager) *CountHandler

func (*CountHandler) RESTOpts

func (h *CountHandler) RESTOpts(opts map[string]string)

func (*CountHandler) ServeHTTP

func (h *CountHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type CountPIndexHandler

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

CountPIndexHandler is a REST handler for counting the documents/entries in a pindex.

func NewCountPIndexHandler

func NewCountPIndexHandler(mgr *cbgt.Manager) *CountPIndexHandler

func (*CountPIndexHandler) ServeHTTP

func (h *CountPIndexHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type CreateIndexHandler

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

CreateIndexHandler is a REST handler that processes an index creation request.

func NewCreateIndexHandler

func NewCreateIndexHandler(mgr *cbgt.Manager) *CreateIndexHandler

func (*CreateIndexHandler) RESTOpts

func (h *CreateIndexHandler) RESTOpts(opts map[string]string)

func (*CreateIndexHandler) ServeHTTP

func (h *CreateIndexHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type DeleteIndexHandler

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

DeleteIndexHandler is a REST handler that processes an index deletion request.

func NewDeleteIndexHandler

func NewDeleteIndexHandler(mgr *cbgt.Manager) *DeleteIndexHandler

func (*DeleteIndexHandler) RESTOpts

func (h *DeleteIndexHandler) RESTOpts(opts map[string]string)

func (*DeleteIndexHandler) ServeHTTP

func (h *DeleteIndexHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type DiagGetHandler

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

DiagGetHandler is a REST handler that retrieves diagnostic information for a node.

func NewDiagGetHandler

func NewDiagGetHandler(versionMain string,
	mgr *cbgt.Manager, mr *cbgt.MsgRing,
	assetDir func(name string) ([]string, error),
	asset func(name string) ([]byte, error)) *DiagGetHandler

func (*DiagGetHandler) ServeHTTP

func (h *DiagGetHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type ETagFileHandler

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

func (ETagFileHandler) ServeHTTP

func (mfh ETagFileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GetIndexHandler

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

GetIndexHandler is a REST handler for retrieving an index definition.

func NewGetIndexHandler

func NewGetIndexHandler(mgr *cbgt.Manager) *GetIndexHandler

func (*GetIndexHandler) RESTOpts

func (h *GetIndexHandler) RESTOpts(opts map[string]string)

func (*GetIndexHandler) ServeHTTP

func (h *GetIndexHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type GetPIndexHandler

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

GetPIndexHandler is a REST handler for retrieving information on a pindex.

func NewGetPIndexHandler

func NewGetPIndexHandler(mgr *cbgt.Manager) *GetPIndexHandler

func (*GetPIndexHandler) ServeHTTP

func (h *GetPIndexHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type IndexControlHandler

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

IndexControlHandler is a REST handler for processing admin control requests on an index.

func NewIndexControlHandler

func NewIndexControlHandler(mgr *cbgt.Manager, control string,
	allowedOps map[string]bool) *IndexControlHandler

func (*IndexControlHandler) RESTOpts

func (h *IndexControlHandler) RESTOpts(opts map[string]string)

func (*IndexControlHandler) ServeHTTP

func (h *IndexControlHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type ListIndexHandler

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

ListIndexHandler is a REST handler for list indexes.

func NewListIndexHandler

func NewListIndexHandler(mgr *cbgt.Manager) *ListIndexHandler

func (*ListIndexHandler) ServeHTTP

func (h *ListIndexHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type ListPIndexHandler

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

ListPIndexHandler is a REST handler for listing pindexes.

func NewListPIndexHandler

func NewListPIndexHandler(mgr *cbgt.Manager) *ListPIndexHandler

func (*ListPIndexHandler) ServeHTTP

func (h *ListPIndexHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type LogGetHandler

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

LogGetHandler is a REST handler that retrieves recent log messages.

func NewLogGetHandler

func NewLogGetHandler(
	mgr *cbgt.Manager, mr *cbgt.MsgRing) *LogGetHandler

func (*LogGetHandler) ServeHTTP

func (h *LogGetHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type ManagerKickHandler

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

ManagerKickHandler is a REST handler that processes a request to kick a manager.

func NewManagerKickHandler

func NewManagerKickHandler(mgr *cbgt.Manager) *ManagerKickHandler

func (*ManagerKickHandler) ServeHTTP

func (h *ManagerKickHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type ManagerMetaHandler

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

ManagerMetaHandler is a REST handler that returns metadata about a manager/node.

func NewManagerMetaHandler

func NewManagerMetaHandler(mgr *cbgt.Manager,
	meta map[string]RESTMeta) *ManagerMetaHandler

func (*ManagerMetaHandler) ServeHTTP

func (h *ManagerMetaHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type MetaDesc

type MetaDesc struct {
	Description     string            `json:"description"`
	StartSample     interface{}       `json:"startSample"`
	StartSampleDocs map[string]string `json:"startSampleDocs"`
}

MetaDesc represents a part of the JSON of a ManagerMetaHandler REST response.

type MetaDescIndex

type MetaDescIndex struct {
	MetaDesc

	CanCount bool `json:"canCount"`
	CanQuery bool `json:"canQuery"`

	QuerySamples interface{} `json:"querySamples"`
	QueryHelp    string      `json:"queryHelp"`
}

MetaDescSource represents the index-type parts of the JSON of a ManagerMetaHandler REST response.

type MetaDescSource

type MetaDescSource MetaDesc

MetaDescSource represents the source-type/feed-type parts of the JSON of a ManagerMetaHandler REST response.

type QueryHandler

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

QueryHandler is a REST handler for querying an index.

func NewQueryHandler

func NewQueryHandler(mgr *cbgt.Manager) *QueryHandler

func (*QueryHandler) RESTOpts

func (h *QueryHandler) RESTOpts(opts map[string]string)

func (*QueryHandler) ServeHTTP

func (h *QueryHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type QueryPIndexHandler

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

QueryPIndexHandler is a REST handler for querying a pindex.

func NewQueryPIndexHandler

func NewQueryPIndexHandler(mgr *cbgt.Manager) *QueryPIndexHandler

func (*QueryPIndexHandler) ServeHTTP

func (h *QueryPIndexHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

type RESTCfg

type RESTCfg struct {
	Status            string             `json:"status"`
	IndexDefs         *cbgt.IndexDefs    `json:"indexDefs"`
	IndexDefsCAS      uint64             `json:"indexDefsCAS"`
	IndexDefsErr      error              `json:"indexDefsErr"`
	NodeDefsWanted    *cbgt.NodeDefs     `json:"nodeDefsWanted"`
	NodeDefsWantedCAS uint64             `json:"nodeDefsWantedCAS"`
	NodeDefsWantedErr error              `json:"nodeDefsWantedErr"`
	NodeDefsKnown     *cbgt.NodeDefs     `json:"nodeDefsKnown"`
	NodeDefsKnownCAS  uint64             `json:"nodeDefsKnownCAS"`
	NodeDefsKnownErr  error              `json:"nodeDefsKnownErr"`
	PlanPIndexes      *cbgt.PlanPIndexes `json:"planPIndexes"`
	PlanPIndexesCAS   uint64             `json:"planPIndexesCAS"`
	PlanPIndexesErr   error              `json:"planPIndexesErr"`
}

type RESTMeta

type RESTMeta struct {
	Path   string
	Method string
	Opts   map[string]string
}

RESTMeta represents the metadata of a REST API endpoint and is used for auto-generated REST API documentation.

type RESTOpts

type RESTOpts interface {
	RESTOpts(map[string]string)
}

RESTOpts interface may be optionally implemented by REST API handlers to provide even more information for auto-generated REST API documentation.

type RuntimeGetHandler

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

RuntimeGetHandler is a REST handler for runtime GET endpoint.

func NewRuntimeGetHandler

func NewRuntimeGetHandler(
	versionMain string, mgr *cbgt.Manager) *RuntimeGetHandler

func (*RuntimeGetHandler) ServeHTTP

func (h *RuntimeGetHandler) ServeHTTP(
	w http.ResponseWriter, r *http.Request)

type StatsHandler

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

StatsHandler is a REST handler that provides stats/metrics for a node.

func NewStatsHandler

func NewStatsHandler(mgr *cbgt.Manager) *StatsHandler

func (*StatsHandler) ServeHTTP

func (h *StatsHandler) ServeHTTP(
	w http.ResponseWriter, req *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL