api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = "/v1"
	Service = "/gateway"
)
View Source
const (
	ErrRedirectionRequest        = "ErrRedirection"
	ErrorTypeBadRequest          = "BadRequest"
	ErrorTypeUnauthenticated     = "Unauthenticated"
	ErrorTypeForbidden           = "Forbidden"
	ErrorTypeNotFound            = "NotFound"
	ErrPayloadTooLargeRequest    = "ErrPayloadTooLarge"
	ErrorTypeClientClosedRequest = "ClientClosedRequest"
	ErrorTypeInternalServerError = "InternalServerError"
	ErrorTypeServiceUnavailable  = "ServiceUnavailable"
	ErrorTypeTimeout             = "Timeout"
	ErrorTypeInternal            = "Internal"
	ErrorTypeNetwork             = "Network"
	ErrorTypeSDKInternal         = "SDKInternal"
	ErrorTypeUnknown             = "Unknown"
)

Variables

View Source
var (
	ErrUserRequired       = status.Error(codes.InvalidArgument, "gateway: user is required")
	ErrUserIDRequired     = status.Error(codes.InvalidArgument, "gateway: user id is required")
	ErrGoalIDRequired     = status.Error(codes.InvalidArgument, "gateway: goal id is required")
	ErrFeatureIDRequired  = status.Error(codes.InvalidArgument, "gateway: feature id is required")
	ErrTagRequired        = status.Error(codes.InvalidArgument, "gateway: tag is required")
	ErrMissingEvents      = status.Error(codes.InvalidArgument, "gateway: missing events")
	ErrMissingEventID     = status.Error(codes.InvalidArgument, "gateway: missing event id")
	ErrInvalidTimestamp   = status.Error(codes.InvalidArgument, "gateway: invalid timestamp")
	ErrContextCanceled    = status.Error(codes.Canceled, "gateway: context canceled")
	ErrFeatureNotFound    = status.Error(codes.NotFound, "gateway: feature not found")
	ErrEvaluationNotFound = status.Error(codes.NotFound, "gateway: evaluation not found")
	ErrMissingAPIKey      = status.Error(codes.Unauthenticated, "gateway: missing APIKey")
	ErrInvalidAPIKey      = status.Error(codes.PermissionDenied, "gateway: invalid APIKey")
	ErrDisabledAPIKey     = status.Error(codes.PermissionDenied, "gateway: disabled APIKey")
	ErrBadRole            = status.Error(codes.PermissionDenied, "gateway: bad role")
	ErrInternal           = status.Error(codes.Internal, "gateway: internal")
)
View Source
var (
	MetricsSaveErrUnknownEvent    = errors.New("gateway: unknown metrics event")
	MetricsSaveErrInvalidDuration = errors.New("gateway: metrics event has invalid duration")
	MetricsSaveErrUnknownApiId    = errors.New("gateway: metrics event has unknown api id")
)

Functions

func NewGatewayService

func NewGatewayService(
	featureClient featureclient.Client,
	accountClient accountclient.Client,
	gp publisher.Publisher,
	ep publisher.Publisher,
	up publisher.Publisher,
	mp publisher.Publisher,
	redisV3Cache cache.MultiGetCache,
	inMemoryCache cache.Cache,
	opts ...Option,
) *gatewayService

func NewGrpcGatewayService

func NewGrpcGatewayService(
	featureClient featureclient.Client,
	accountClient accountclient.Client,
	gp publisher.Publisher,
	ep publisher.Publisher,
	up publisher.Publisher,
	redisV3Cache cache.MultiGetCache,
	inMemoryCache cache.Cache,
	opts ...Option,
) rpc.Service

Types

type EventType added in v0.3.0

type EventType int
const (
	GoalEventType EventType = iota + 1 // eventType starts from 1 for validation.
	// Do NOT remove the goalBatchEventType because the go-server-sdk depends on the same order
	// https://github.com/ca-dp/bucketeer-go-server-sdk/blob/master/pkg/bucketeer/api/rest.go#L35
	GoalBatchEventType // nolint:deadcode,unused,varcheck
	EvaluationEventType
	MetricsEventType
)

type Option

type Option func(*options)

func WithAPIKeyMemoryCacheEvictionInterval

func WithAPIKeyMemoryCacheEvictionInterval(interval time.Duration) Option

func WithAPIKeyMemoryCacheTTL

func WithAPIKeyMemoryCacheTTL(ttl time.Duration) Option

func WithFurthestEventTimestamp

func WithFurthestEventTimestamp(d time.Duration) Option

func WithLogger

func WithLogger(l *zap.Logger) Option

func WithMetrics

func WithMetrics(r metrics.Registerer) Option

func WithOldestEventTimestamp

func WithOldestEventTimestamp(d time.Duration) Option

Jump to

Keyboard shortcuts

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