Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertInstancesProto(instancesProto []*placementpb.Instance) ([]placement.Instance, error)
- func RegisterRoutes(r *mux.Router, defaults []handleroptions.ServiceOptionsDefault, ...)
- func Service(clusterClient clusterclient.Client, opts handleroptions.ServiceOptions, ...) (placement.Service, error)
- func ServiceWithAlgo(clusterClient clusterclient.Client, opts handleroptions.ServiceOptions, ...) (placement.Service, placement.Algorithm, error)
- type AddHandler
- type DeleteAllHandler
- type DeleteHandler
- type GetHandler
- type Handler
- type HandlerOptions
- type InitHandler
- type ReplaceHandler
- type SetHandler
Constants ¶
const ( // ServicesPathName is the services part of the API path. ServicesPathName = "services" // PlacementPathName is the placement part of the API path. PlacementPathName = "placement" )
const ( // AddHTTPMethod is the HTTP method used with this resource. AddHTTPMethod = http.MethodPost )
const ( // DeleteAllHTTPMethod is the HTTP method used with this resource. DeleteAllHTTPMethod = http.MethodDelete )
const ( // DeleteHTTPMethod is the HTTP method used with this resource. DeleteHTTPMethod = http.MethodDelete )
const ( // GetHTTPMethod is the HTTP method used with this resource. GetHTTPMethod = http.MethodGet )
const ( // ReplaceHTTPMethod is the HTTP method for the the replace endpoint. ReplaceHTTPMethod = http.MethodPost )
const ( // SetHTTPMethod is the HTTP method for the the upsert endpoint. SetHTTPMethod = http.MethodPost )
Variables ¶
var ( // DeprecatedM3DBAddURL is the old url for the placement add handler, maintained for // backwards compatibility. DeprecatedM3DBAddURL = path.Join(handler.RoutePrefixV1, PlacementPathName) // M3DBAddURL is the url for the placement add handler (with the POST method) // for the M3DB service. M3DBAddURL = path.Join(handler.RoutePrefixV1, M3DBServicePlacementPathName) // M3AggAddURL is the url for the placement add handler (with the POST method) // for the M3Agg service. M3AggAddURL = path.Join(handler.RoutePrefixV1, M3AggServicePlacementPathName) // M3CoordinatorAddURL is the url for the placement add handler (with the POST method) // for the M3Coordinator service. M3CoordinatorAddURL = path.Join(handler.RoutePrefixV1, M3CoordinatorServicePlacementPathName) )
var ( // M3DBServicePlacementPathName is the M3DB service placement API path. M3DBServicePlacementPathName = path.Join(ServicesPathName, handleroptions.M3DBServiceName, PlacementPathName) // M3AggServicePlacementPathName is the M3Agg service placement API path. M3AggServicePlacementPathName = path.Join(ServicesPathName, handleroptions.M3AggregatorServiceName, PlacementPathName) // M3CoordinatorServicePlacementPathName is the M3Coordinator // service placement API path. M3CoordinatorServicePlacementPathName = path.Join(ServicesPathName, handleroptions.M3CoordinatorServiceName, PlacementPathName) )
var ( // DeprecatedM3DBDeleteURL is the old url for the placement delete handler, maintained // for backwards compatibility. DeprecatedM3DBDeleteURL = path.Join(handler.RoutePrefixV1, PlacementPathName, placementIDPath) // M3DBDeleteURL is the url for the placement delete handler for the M3DB service. M3DBDeleteURL = path.Join(handler.RoutePrefixV1, M3DBServicePlacementPathName, placementIDPath) // M3AggDeleteURL is the url for the placement delete handler for the M3Agg service. M3AggDeleteURL = path.Join(handler.RoutePrefixV1, M3AggServicePlacementPathName, placementIDPath) // M3CoordinatorDeleteURL is the url for the placement delete handler for the M3Coordinator service. M3CoordinatorDeleteURL = path.Join(handler.RoutePrefixV1, M3CoordinatorServicePlacementPathName, placementIDPath) )
var ( // DeprecatedM3DBDeleteAllURL is the old url for the handler to delete all placements, maintained // for backwards compatibility. DeprecatedM3DBDeleteAllURL = path.Join(handler.RoutePrefixV1, PlacementPathName) // M3DBDeleteAllURL is the url for the handler to delete all placements (with the DELETE method) // for the M3DB service. M3DBDeleteAllURL = path.Join(handler.RoutePrefixV1, M3DBServicePlacementPathName) // M3AggDeleteAllURL is the url for the handler to delete all placements (with the DELETE method) // for the M3Agg service. M3AggDeleteAllURL = path.Join(handler.RoutePrefixV1, M3AggServicePlacementPathName) // M3CoordinatorDeleteAllURL is the url for the handler to delete all placements (with the DELETE method) // for the M3Coordinator service. M3CoordinatorDeleteAllURL = path.Join(handler.RoutePrefixV1, M3CoordinatorServicePlacementPathName) )
var ( // DeprecatedM3DBGetURL is the old url for the placement get handler, maintained for // backwards compatibility. DeprecatedM3DBGetURL = path.Join(handler.RoutePrefixV1, PlacementPathName) // M3DBGetURL is the url for the placement get handler (with the GET method) // for the M3DB service. M3DBGetURL = path.Join(handler.RoutePrefixV1, M3DBServicePlacementPathName) // M3AggGetURL is the url for the placement get handler (with the GET method) // for the M3Agg service. M3AggGetURL = path.Join(handler.RoutePrefixV1, M3AggServicePlacementPathName) // M3CoordinatorGetURL is the url for the placement get handler (with the GET method) // for the M3Coordinator service. M3CoordinatorGetURL = path.Join(handler.RoutePrefixV1, M3CoordinatorServicePlacementPathName) )
var ( // DeprecatedM3DBInitURL is the old url for the placement init handler, maintained for backwards // compatibility. (with the POST method). DeprecatedM3DBInitURL = path.Join(handler.RoutePrefixV1, PlacementPathName, initPathName) // M3DBInitURL is the url for the placement init handler, (with the POST method). M3DBInitURL = path.Join(handler.RoutePrefixV1, M3DBServicePlacementPathName, initPathName) // M3AggInitURL is the url for the m3agg placement init handler (with the POST method). M3AggInitURL = path.Join(handler.RoutePrefixV1, M3AggServicePlacementPathName, initPathName) // M3CoordinatorInitURL is the url for the m3agg placement init handler (with the POST method). M3CoordinatorInitURL = path.Join(handler.RoutePrefixV1, M3CoordinatorServicePlacementPathName, initPathName) // InitHTTPMethod is the HTTP method used with this resource. InitHTTPMethod = http.MethodPost )
var ( // M3DBReplaceURL is the url for the m3db replace handler (method POST). M3DBReplaceURL = path.Join(handler.RoutePrefixV1, M3DBServicePlacementPathName, replacePathName) // M3AggReplaceURL is the url for the m3aggregator replace handler (method // POST). M3AggReplaceURL = path.Join(handler.RoutePrefixV1, handleroptions.M3AggregatorServiceName, replacePathName) // M3CoordinatorReplaceURL is the url for the m3coordinator replace handler // (method POST). M3CoordinatorReplaceURL = path.Join(handler.RoutePrefixV1, handleroptions.M3CoordinatorServiceName, replacePathName) )
var ( // M3DBSetURL is the url for the m3db replace handler (method POST). M3DBSetURL = path.Join(handler.RoutePrefixV1, M3DBServicePlacementPathName, setPathName) // M3AggSetURL is the url for the m3aggregator replace handler (method // POST). M3AggSetURL = path.Join(handler.RoutePrefixV1, handleroptions.M3AggregatorServiceName, setPathName) // M3CoordinatorSetURL is the url for the m3coordinator replace handler // (method POST). M3CoordinatorSetURL = path.Join(handler.RoutePrefixV1, handleroptions.M3CoordinatorServiceName, setPathName) )
Functions ¶
func ConvertInstancesProto ¶
func ConvertInstancesProto(instancesProto []*placementpb.Instance) ([]placement.Instance, error)
ConvertInstancesProto converts a slice of protobuf `Instance`s to `placement.Instance`s
func RegisterRoutes ¶
func RegisterRoutes( r *mux.Router, defaults []handleroptions.ServiceOptionsDefault, opts HandlerOptions, )
RegisterRoutes registers the placement routes
func Service ¶
func Service( clusterClient clusterclient.Client, opts handleroptions.ServiceOptions, now time.Time, validationFn placement.ValidateFn, ) (placement.Service, error)
Service gets a placement service from m3cluster client
func ServiceWithAlgo ¶ added in v0.4.6
func ServiceWithAlgo( clusterClient clusterclient.Client, opts handleroptions.ServiceOptions, now time.Time, validationFn placement.ValidateFn, ) (placement.Service, placement.Algorithm, error)
ServiceWithAlgo gets a placement service from m3cluster client and additionally returns an algorithm instance for callers that need fine-grained control over placement updates.
Types ¶
type AddHandler ¶
type AddHandler Handler
AddHandler is the handler for placement adds.
func NewAddHandler ¶
func NewAddHandler(opts HandlerOptions) *AddHandler
NewAddHandler returns a new instance of AddHandler.
func (*AddHandler) Add ¶
func (h *AddHandler) Add( svc handleroptions.ServiceNameAndDefaults, httpReq *http.Request, req *admin.PlacementAddRequest, ) (placement.Placement, error)
Add adds a placement.
func (*AddHandler) ServeHTTP ¶
func (h *AddHandler) ServeHTTP( svc handleroptions.ServiceNameAndDefaults, w http.ResponseWriter, r *http.Request, )
type DeleteAllHandler ¶
type DeleteAllHandler Handler
DeleteAllHandler is the handler to delete all placements.
func NewDeleteAllHandler ¶
func NewDeleteAllHandler(opts HandlerOptions) *DeleteAllHandler
NewDeleteAllHandler returns a new instance of DeleteAllHandler.
func (*DeleteAllHandler) ServeHTTP ¶
func (h *DeleteAllHandler) ServeHTTP( svc handleroptions.ServiceNameAndDefaults, w http.ResponseWriter, r *http.Request, )
type DeleteHandler ¶
type DeleteHandler Handler
DeleteHandler is the handler for placement deletes.
func NewDeleteHandler ¶
func NewDeleteHandler(opts HandlerOptions) *DeleteHandler
NewDeleteHandler returns a new instance of DeleteHandler.
func (*DeleteHandler) ServeHTTP ¶
func (h *DeleteHandler) ServeHTTP( svc handleroptions.ServiceNameAndDefaults, w http.ResponseWriter, r *http.Request, )
type GetHandler ¶
type GetHandler Handler
GetHandler is the handler for placement gets.
func NewGetHandler ¶
func NewGetHandler(opts HandlerOptions) *GetHandler
NewGetHandler returns a new instance of GetHandler.
func (*GetHandler) Get ¶ added in v0.6.0
func (h *GetHandler) Get( svc handleroptions.ServiceNameAndDefaults, httpReq *http.Request, ) (placement placement.Placement, badRequest bool, err error)
Get gets a placement.
func (*GetHandler) ServeHTTP ¶
func (h *GetHandler) ServeHTTP( service handleroptions.ServiceNameAndDefaults, w http.ResponseWriter, r *http.Request, )
type Handler ¶
type Handler struct { HandlerOptions // contains filtered or unexported fields }
Handler represents a generic handler for placement endpoints.
type HandlerOptions ¶ added in v0.4.7
type HandlerOptions struct {
// contains filtered or unexported fields
}
HandlerOptions is the options struct for the handler.
func NewHandlerOptions ¶ added in v0.4.7
func NewHandlerOptions( client clusterclient.Client, cfg config.Configuration, m3AggOpts *handleroptions.M3AggServiceOptions, instrumentOpts instrument.Options, ) (HandlerOptions, error)
NewHandlerOptions is the constructor function for HandlerOptions.
type InitHandler ¶
type InitHandler Handler
InitHandler is the handler for placement inits.
func NewInitHandler ¶
func NewInitHandler(opts HandlerOptions) *InitHandler
NewInitHandler returns a new instance of InitHandler.
func (*InitHandler) Init ¶
func (h *InitHandler) Init( svc handleroptions.ServiceNameAndDefaults, httpReq *http.Request, req *admin.PlacementInitRequest, ) (placement.Placement, error)
Init initializes a placement.
func (*InitHandler) ServeHTTP ¶
func (h *InitHandler) ServeHTTP( svc handleroptions.ServiceNameAndDefaults, w http.ResponseWriter, r *http.Request, )
type ReplaceHandler ¶ added in v0.4.8
type ReplaceHandler Handler
ReplaceHandler is the type for placement replaces.
func NewReplaceHandler ¶ added in v0.4.8
func NewReplaceHandler(opts HandlerOptions) *ReplaceHandler
NewReplaceHandler returns a new ReplaceHandler.
func (*ReplaceHandler) Replace ¶ added in v0.4.8
func (h *ReplaceHandler) Replace( svc handleroptions.ServiceNameAndDefaults, httpReq *http.Request, req *admin.PlacementReplaceRequest, ) (placement.Placement, error)
Replace replaces instances.
func (*ReplaceHandler) ServeHTTP ¶ added in v0.4.8
func (h *ReplaceHandler) ServeHTTP( svc handleroptions.ServiceNameAndDefaults, w http.ResponseWriter, r *http.Request, )
type SetHandler ¶ added in v0.15.0
type SetHandler Handler
SetHandler is the type for placement replaces.
func NewSetHandler ¶ added in v0.15.0
func NewSetHandler(opts HandlerOptions) *SetHandler
NewSetHandler returns a new SetHandler.
func (*SetHandler) ServeHTTP ¶ added in v0.15.0
func (h *SetHandler) ServeHTTP( svc handleroptions.ServiceNameAndDefaults, w http.ResponseWriter, r *http.Request, )