placement

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServicesPathName is the services part of the API path.
	ServicesPathName = "services"
	// PlacementPathName is the placement part of the API path.
	PlacementPathName = "placement"
)
View Source
const (
	// AddHTTPMethod is the HTTP method used with this resource.
	AddHTTPMethod = http.MethodPost
)
View Source
const (
	// DeleteAllHTTPMethod is the HTTP method used with this resource.
	DeleteAllHTTPMethod = http.MethodDelete
)
View Source
const (

	// DeleteHTTPMethod is the HTTP method used with this resource.
	DeleteHTTPMethod = http.MethodDelete
)
View Source
const (
	// GetHTTPMethod is the HTTP method used with this resource.
	GetHTTPMethod = http.MethodGet
)
View Source
const (
	// ReplaceHTTPMethod is the HTTP method for the the replace endpoint.
	ReplaceHTTPMethod = http.MethodPost
)

Variables

View Source
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)
)
View Source
var (
	// M3DBServicePlacementPathName is the M3DB service placement API path.
	M3DBServicePlacementPathName = path.Join(ServicesPathName, handler.M3DBServiceName, PlacementPathName)
	// M3AggServicePlacementPathName is the M3Agg service placement API path.
	M3AggServicePlacementPathName = path.Join(ServicesPathName, handler.M3AggregatorServiceName, PlacementPathName)
	// M3CoordinatorServicePlacementPathName is the M3Coordinator service placement API path.
	M3CoordinatorServicePlacementPathName = path.Join(ServicesPathName, handler.M3CoordinatorServiceName, PlacementPathName)
)
View Source
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)
)
View Source
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)
)
View Source
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)
)
View Source
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
)
View Source
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, handler.M3AggregatorServiceName, replacePathName)

	// M3CoordinatorReplaceURL is the url for the m3coordinator replace handler
	// (method POST).
	M3CoordinatorReplaceURL = path.Join(handler.RoutePrefixV1, handler.M3CoordinatorServiceName, replacePathName)
)

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 handler.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 handler.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(
	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) Get added in v0.6.0

func (h *GetHandler) Get(
	serviceName string,
	httpReq *http.Request,
) (placement placement.Placement, badRequest bool, err error)

Get gets a placement.

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 *handler.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 *handler.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 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(
	serviceName string,
	httpReq *http.Request,
	req *admin.PlacementReplaceRequest,
) (placement.Placement, error)

Replace replaces instances.

func (*ReplaceHandler) ServeHTTP added in v0.4.8

func (h *ReplaceHandler) ServeHTTP(serviceName string, w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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