dbrp

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PrefixDBRP = "/api/v2/dbrps"
)

Variables

View Source
var (
	// ErrInvalidDBRPID is used when the ID of the DBRP cannot be encoded.
	ErrInvalidDBRPID = &influxdb.Error{
		Code: influxdb.EInvalid,
		Msg:  "DBRP ID is invalid",
	}

	// ErrDBRPNotFound is used when the specified DBRP cannot be found.
	ErrDBRPNotFound = &influxdb.Error{
		Code: influxdb.ENotFound,
		Msg:  "unable to find DBRP",
	}

	// ErrNotUniqueID is used when the ID of the DBRP is not unique.
	ErrNotUniqueID = &influxdb.Error{
		Code: influxdb.EConflict,
		Msg:  "ID already exists",
	}

	// ErrFailureGeneratingID occurs ony when the random number generator
	// cannot generate an ID in MaxIDGenerationN times.
	ErrFailureGeneratingID = &influxdb.Error{
		Code: influxdb.EInternal,
		Msg:  "unable to generate valid id",
	}
)

Functions

func ErrDBRPAlreadyExists

func ErrDBRPAlreadyExists(msg string) *influxdb.Error

ErrDBRPAlreadyExists is used when there is a conflict in creating a new DBRP.

func ErrInternalService

func ErrInternalService(err error) *influxdb.Error

ErrInternalService is used when the error comes from an internal system.

func ErrInvalidDBRP

func ErrInvalidDBRP(err error) *influxdb.Error

ErrInvalidDBRP is used when a service was provided an invalid DBRP.

func NewService

func NewService(ctx context.Context, bucketSvc influxdb.BucketService, st kv.Store) influxdb.DBRPMappingServiceV2

Types

type AuthorizedService

type AuthorizedService struct {
	influxdb.DBRPMappingServiceV2
}

func NewAuthorizedService

func NewAuthorizedService(s influxdb.DBRPMappingServiceV2) *AuthorizedService

func (AuthorizedService) Create

func (svc AuthorizedService) Create(ctx context.Context, t *influxdb.DBRPMappingV2) error

func (AuthorizedService) Delete

func (svc AuthorizedService) Delete(ctx context.Context, orgID, id influxdb.ID) error

func (AuthorizedService) FindByID

func (svc AuthorizedService) FindByID(ctx context.Context, orgID, id influxdb.ID) (*influxdb.DBRPMappingV2, error)

func (AuthorizedService) FindMany

func (svc AuthorizedService) FindMany(ctx context.Context, filter influxdb.DBRPMappingFilterV2, opts ...influxdb.FindOptions) ([]*influxdb.DBRPMappingV2, int, error)

func (AuthorizedService) Update

func (svc AuthorizedService) Update(ctx context.Context, u *influxdb.DBRPMappingV2) error

type BucketService

type BucketService struct {
	influxdb.BucketService
	Logger             *zap.Logger
	DBRPMappingService influxdb.DBRPMappingServiceV2
}

func NewBucketService

func NewBucketService(logger *zap.Logger, bucketService influxdb.BucketService, dbrpService influxdb.DBRPMappingServiceV2) *BucketService

func (*BucketService) DeleteBucket

func (s *BucketService) DeleteBucket(ctx context.Context, id influxdb.ID) error

type Client

type Client struct {
	Client *httpc.Client
	Prefix string
}

Client connects to Influx via HTTP using tokens to manage DBRPs.

func NewClient

func NewClient(client *httpc.Client) *Client

func (*Client) Create

func (c *Client) Create(ctx context.Context, dbrp *influxdb.DBRPMappingV2) error

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, orgID, id influxdb.ID) error

func (*Client) FindByID

func (c *Client) FindByID(ctx context.Context, orgID, id influxdb.ID) (*influxdb.DBRPMappingV2, error)

func (*Client) FindMany

func (c *Client) FindMany(ctx context.Context, filter influxdb.DBRPMappingFilterV2, opts ...influxdb.FindOptions) ([]*influxdb.DBRPMappingV2, int, error)

func (*Client) Update

func (c *Client) Update(ctx context.Context, dbrp *influxdb.DBRPMappingV2) error

type Handler

type Handler struct {
	chi.Router
	// contains filtered or unexported fields
}

func NewHTTPHandler

func NewHTTPHandler(log *zap.Logger, dbrpSvc influxdb.DBRPMappingServiceV2, orgSvc influxdb.OrganizationService) *Handler

NewHTTPHandler constructs a new http server.

type Service

type Service struct {
	IDGen influxdb.IDGenerator
	// contains filtered or unexported fields
}

func (*Service) Create

func (s *Service) Create(ctx context.Context, dbrp *influxdb.DBRPMappingV2) error

Create creates a new mapping. If another mapping with same organization ID, database, and retention policy exists, an error is returned. If the mapping already contains a valid ID, that one is used for storing the mapping.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, orgID, id influxdb.ID) error

Delete removes a mapping. Deleting a mapping that does not exists is not an error. Deleting the default mapping will cause the first one (if any) to become the default.

func (*Service) FindByID

func (s *Service) FindByID(ctx context.Context, orgID, id influxdb.ID) (*influxdb.DBRPMappingV2, error)

FindBy returns the mapping for the given ID.

func (*Service) FindMany

func (s *Service) FindMany(ctx context.Context, filter influxdb.DBRPMappingFilterV2, opts ...influxdb.FindOptions) ([]*influxdb.DBRPMappingV2, int, error)

FindMany returns a list of mappings that match filter and the total count of matching dbrp mappings. TODO(affo): find a smart way to apply FindOptions to a list of items.

func (*Service) Update

func (s *Service) Update(ctx context.Context, dbrp *influxdb.DBRPMappingV2) error

Updates a mapping. If another mapping with same organization ID, database, and retention policy exists, an error is returned. Un-setting `Default` for a mapping will cause the first one to become the default.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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