dbrp

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

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

Variables

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

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

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

	ErrNoOrgProvided = &errors.Error{
		Code: errors.EInvalid,
		Msg:  "either 'org' or 'orgID' must be provided",
	}
)
View Source
var (
	ByOrgIDIndexMapping = kv.NewIndexMapping(bucket, byOrgIDIndexBucket, func(v []byte) ([]byte, error) {
		var dbrp influxdb.DBRPMapping
		if err := json.Unmarshal(v, &dbrp); err != nil {
			return nil, err
		}

		id, _ := dbrp.OrganizationID.Encode()
		return id, nil
	})
)

Functions

func ErrDBRPAlreadyExists

func ErrDBRPAlreadyExists(msg string) *errors.Error

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

func ErrInternalService

func ErrInternalService(err error) *errors.Error

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

func ErrInvalidBucketID added in v2.0.4

func ErrInvalidBucketID(id string, err error) error

ErrInvalidBucketID returns a more informative error about a failure to decode a bucket ID.

func ErrInvalidDBRP

func ErrInvalidDBRP(err error) *errors.Error

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

func ErrInvalidDBRPID

func ErrInvalidDBRPID(id string, err error) error

ErrInvalidDBRPID is used when the ID of the DBRP cannot be encoded.

func ErrInvalidOrgID added in v2.0.4

func ErrInvalidOrgID(id string, err error) error

ErrInvalidOrgID returns a more informative error about a failure to decode an organization ID.

func ErrOrgNotFound added in v2.0.4

func ErrOrgNotFound(org string) error

ErrOrgNotFound returns a more informative error about a 404 on org name.

func NewService

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

Types

type AuthorizedService

type AuthorizedService struct {
	influxdb.DBRPMappingService
}

func NewAuthorizedService

func NewAuthorizedService(s influxdb.DBRPMappingService) *AuthorizedService

func (AuthorizedService) Create

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

func (AuthorizedService) Delete

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

func (AuthorizedService) FindByID

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

func (AuthorizedService) FindMany

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

func (AuthorizedService) Update

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

type BucketService

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

func NewBucketService

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

func (*BucketService) DeleteBucket

func (s *BucketService) DeleteBucket(ctx context.Context, id platform.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.DBRPMapping) error

func (*Client) Delete

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

func (*Client) FindByID

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

func (*Client) FindMany

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

func (*Client) Update

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

type Handler

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

func NewHTTPHandler

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

NewHTTPHandler constructs a new http server.

type Service

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

func (*Service) Create

func (s *Service) Create(ctx context.Context, dbrp *influxdb.DBRPMapping) 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 platform.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 platform.ID) (*influxdb.DBRPMapping, error)

FindBy returns the mapping for the given ID.

func (*Service) FindMany

func (s *Service) FindMany(ctx context.Context, filter influxdb.DBRPMappingFilter, opts ...influxdb.FindOptions) ([]*influxdb.DBRPMapping, 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.DBRPMapping) 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