api

package
v0.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 36 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidBearerToken = errors.New("invalid token")
)
View Source
var JWT = jsonwebtoken{}

Functions

func APIKeyAuthMiddleware

func APIKeyAuthMiddleware(apiKey string) gin.HandlerFunc

func APIKeyOrTenantJWTAuthMiddleware

func APIKeyOrTenantJWTAuthMiddleware(apiKey string, jwtKey string) gin.HandlerFunc

func AbortWithError

func AbortWithError(c *gin.Context, code int, err error)

func AbortWithValidationError

func AbortWithValidationError(c *gin.Context, err error)

func ErrorHandlerMiddleware

func ErrorHandlerMiddleware(logger *otelzap.Logger) gin.HandlerFunc

func MetricsMiddleware

func MetricsMiddleware() gin.HandlerFunc

func NewRouter

func NewRouter(
	cfg RouterConfig,
	logger *otelzap.Logger,
	redisClient *redis.Client,
	deliveryMQ *deliverymq.DeliveryMQ,
	entityStore models.EntityStore,
	logStore models.LogStore,
	publishmqEventHandler publishmq.EventHandler,
) http.Handler

func RequireTenantMiddleware

func RequireTenantMiddleware(logger *otelzap.Logger, entityStore models.EntityStore) gin.HandlerFunc

Types

type APIService

type APIService struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(ctx context.Context, wg *sync.WaitGroup, cfg *config.Config, logger *otelzap.Logger) (*APIService, error)

func (*APIService) Run

func (s *APIService) Run(ctx context.Context) error

func (*APIService) SubscribePublishMQ

func (s *APIService) SubscribePublishMQ(ctx context.Context, subscription mqs.Subscription, eventHandler publishmq.EventHandler, concurrency int)

type CreateDestinationRequest

type CreateDestinationRequest struct {
	ID          string            `json:"id" binding:"-"`
	Type        string            `json:"type" binding:"required"`
	Topics      models.Topics     `json:"topics" binding:"required"`
	Config      map[string]string `json:"config" binding:"required"`
	Credentials map[string]string `json:"credentials" binding:"-"`
}

func (*CreateDestinationRequest) ToDestination

func (r *CreateDestinationRequest) ToDestination(tenantID string) models.Destination

type DestinationHandlers

type DestinationHandlers struct {
	// contains filtered or unexported fields
}

func NewDestinationHandlers

func NewDestinationHandlers(logger *otelzap.Logger, entityStore models.EntityStore, topics []string, registry destregistry.Registry) *DestinationHandlers

func (*DestinationHandlers) Create

func (h *DestinationHandlers) Create(c *gin.Context)

func (*DestinationHandlers) Delete

func (h *DestinationHandlers) Delete(c *gin.Context)

func (*DestinationHandlers) Disable

func (h *DestinationHandlers) Disable(c *gin.Context)

func (*DestinationHandlers) Enable

func (h *DestinationHandlers) Enable(c *gin.Context)

func (*DestinationHandlers) List

func (h *DestinationHandlers) List(c *gin.Context)

func (*DestinationHandlers) ListProviderMetadata

func (h *DestinationHandlers) ListProviderMetadata(c *gin.Context)

func (*DestinationHandlers) Retrieve

func (h *DestinationHandlers) Retrieve(c *gin.Context)

func (*DestinationHandlers) RetrieveProviderMetadata

func (h *DestinationHandlers) RetrieveProviderMetadata(c *gin.Context)

func (*DestinationHandlers) Update

func (h *DestinationHandlers) Update(c *gin.Context)

type ErrorResponse

type ErrorResponse struct {
	Err     error       `json:"-"`
	Code    int         `json:"-"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func NewErrBadRequest

func NewErrBadRequest(err error) ErrorResponse

func NewErrInternalServer

func NewErrInternalServer(err error) ErrorResponse

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

func (*ErrorResponse) Parse

func (e *ErrorResponse) Parse(err error)

type LogHandlers

type LogHandlers struct {
	// contains filtered or unexported fields
}

func NewLogHandlers

func NewLogHandlers(
	logger *otelzap.Logger,
	logStore models.LogStore,
) *LogHandlers

func (*LogHandlers) ListDeliveryByEvent

func (h *LogHandlers) ListDeliveryByEvent(c *gin.Context)

TODO: consider authz where eventID doesn't belong to tenantID?

func (*LogHandlers) ListEvent

func (h *LogHandlers) ListEvent(c *gin.Context)

func (*LogHandlers) RetrieveEvent

func (h *LogHandlers) RetrieveEvent(c *gin.Context)

type PublishHandlers

type PublishHandlers struct {
	// contains filtered or unexported fields
}

func NewPublishHandlers

func NewPublishHandlers(
	logger *otelzap.Logger,
	eventHandler publishmq.EventHandler,
) *PublishHandlers

func (*PublishHandlers) Ingest

func (h *PublishHandlers) Ingest(c *gin.Context)

type PublishedEvent

type PublishedEvent struct {
	ID               string                 `json:"id"`
	TenantID         string                 `json:"tenant_id"`
	DestinationID    string                 `json:"destination_id"`
	Topic            string                 `json:"topic"`
	EligibleForRetry bool                   `json:"eligible_for_retry"`
	Time             time.Time              `json:"time"`
	Metadata         map[string]string      `json:"metadata"`
	Data             map[string]interface{} `json:"data"`
}

TODO: validation

type RouterConfig

type RouterConfig struct {
	Hostname       string
	APIKey         string
	JWTSecret      string
	PortalProxyURL string
	Topics         []string
	Registry       destregistry.Registry
}

type TenantHandlers

type TenantHandlers struct {
	// contains filtered or unexported fields
}

func NewTenantHandlers

func NewTenantHandlers(
	logger *otelzap.Logger,
	jwtSecret string,
	entityStore models.EntityStore,
) *TenantHandlers

func (*TenantHandlers) Delete

func (h *TenantHandlers) Delete(c *gin.Context)

func (*TenantHandlers) Retrieve

func (h *TenantHandlers) Retrieve(c *gin.Context)

func (*TenantHandlers) RetrievePortal

func (h *TenantHandlers) RetrievePortal(c *gin.Context)

func (*TenantHandlers) Upsert

func (h *TenantHandlers) Upsert(c *gin.Context)

type TopicHandlers

type TopicHandlers struct {
	// contains filtered or unexported fields
}

func NewTopicHandlers

func NewTopicHandlers(logger *otelzap.Logger, topics []string) *TopicHandlers

func (*TopicHandlers) List

func (h *TopicHandlers) List(c *gin.Context)

type UpdateDestinationRequest

type UpdateDestinationRequest struct {
	Type        string            `json:"type" binding:"-"`
	Topics      models.Topics     `json:"topics" binding:"-"`
	Config      map[string]string `json:"config" binding:"-"`
	Credentials map[string]string `json:"credentials" binding:"-"`
}

Jump to

Keyboard shortcuts

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