Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertInstancesProto(instancesProto []*placementpb.Instance) ([]placement.Instance, error)
- func RegisterRoutes(r *mux.Router, opts HandlerOptions)
- func Service(clusterClient clusterclient.Client, opts ServiceOptions, now time.Time) (placement.Service, error)
- func ServiceWithAlgo(clusterClient clusterclient.Client, opts ServiceOptions, now time.Time) (placement.Service, placement.Algorithm, error)
- type AddHandler
- type DeleteAllHandler
- type DeleteHandler
- type GetHandler
- type Handler
- type HandlerOptions
- type InitHandler
- type M3AggServiceOptions
- type ServiceOptions
Constants ¶
const ( // M3DBServiceName is the service name for M3DB. M3DBServiceName = "m3db" // M3AggregatorServiceName is the service name for M3Aggregator. M3AggregatorServiceName = "m3aggregator" // M3CoordinatorServiceName is the service name for M3Coordinator. M3CoordinatorServiceName = "m3coordinator" // ServicesPathName is the services part of the API path. ServicesPathName = "services" // PlacementPathName is the placement part of the API path. PlacementPathName = "placement" // DefaultServiceEnvironment is the default service ID environment. DefaultServiceEnvironment = "default_env" // DefaultServiceZone is the default service ID zone. DefaultServiceZone = "embedded" // HeaderClusterEnvironmentName is the header used to specify the environment name. HeaderClusterEnvironmentName = "Cluster-Environment-Name" // HeaderClusterZoneName is the header used to specify the zone name. HeaderClusterZoneName = "Cluster-Zone-Name" // HeaderDryRun is the header used to specify whether this should be a dry run. HeaderDryRun = "Dry-Run" )
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 )
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, M3DBServiceName, PlacementPathName) // M3AggServicePlacementPathName is the M3Agg service placement API path. M3AggServicePlacementPathName = path.Join(ServicesPathName, M3AggregatorServiceName, PlacementPathName) // M3CoordinatorServicePlacementPathName is the M3Coordinator service placement API path. M3CoordinatorServicePlacementPathName = path.Join(ServicesPathName, 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 )
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, opts HandlerOptions)
RegisterRoutes registers the placement routes
func Service ¶
func Service( clusterClient clusterclient.Client, opts ServiceOptions, now time.Time, ) (placement.Service, error)
Service gets a placement service from m3cluster client
func ServiceWithAlgo ¶ added in v0.4.6
func ServiceWithAlgo( clusterClient clusterclient.Client, opts ServiceOptions, now time.Time, ) (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( serviceName string, httpReq *http.Request, req *admin.PlacementAddRequest, ) (placement.Placement, error)
Add adds a placement.
func (*AddHandler) ServeHTTP ¶
func (h *AddHandler) ServeHTTP(serviceName string, 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(serviceName string, 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(serviceName string, 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) ServeHTTP ¶
func (h *GetHandler) ServeHTTP(serviceName string, 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 { // This is used by other placement Handlers // nolint: structcheck ClusterClient clusterclient.Client Config config.Configuration M3AggServiceOptions *M3AggServiceOptions }
HandlerOptions is the options struct for the handler.
func NewHandlerOptions ¶ added in v0.4.7
func NewHandlerOptions( client clusterclient.Client, cfg config.Configuration, m3AggOpts *M3AggServiceOptions, ) HandlerOptions
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( serviceName string, httpReq *http.Request, req *admin.PlacementInitRequest, ) (placement.Placement, error)
Init initializes a placement.
func (*InitHandler) ServeHTTP ¶
func (h *InitHandler) ServeHTTP(serviceName string, w http.ResponseWriter, r *http.Request)
type M3AggServiceOptions ¶ added in v0.4.7
type M3AggServiceOptions struct { MaxAggregationWindowSize time.Duration WarmupDuration time.Duration }
M3AggServiceOptions contains the service options that are specific to the M3Agg service.
type ServiceOptions ¶ added in v0.4.7
type ServiceOptions struct { ServiceName string ServiceEnvironment string ServiceZone string M3Agg *M3AggServiceOptions DryRun bool }
ServiceOptions are the options for Service.
func NewServiceOptions ¶ added in v0.4.7
func NewServiceOptions( serviceName string, headers http.Header, m3AggOpts *M3AggServiceOptions) ServiceOptions
NewServiceOptions returns a ServiceOptions based on the provided values.