Documentation ¶
Index ¶
- Variables
- func IsValidPeriod(period string) bool
- type APIKey
- type APIKeyRepository
- type AppMetadata
- type Application
- type ApplicationRepository
- type DatabaseClient
- type DefaultStrategyConfiguration
- type DeliveryAttempt
- type DocumentStatus
- type Endpoint
- type EndpointMetadata
- type EndpointStatus
- type Event
- type EventDelivery
- type EventDeliveryRepository
- type EventDeliveryStatus
- type EventInterval
- type EventIntervalData
- type EventMetadata
- type EventRepository
- type EventType
- type ExponentialBackoffStrategyConfiguration
- type Filter
- type Group
- type GroupConfig
- type GroupFilter
- type GroupRepository
- type GroupStatistics
- type HttpHeader
- type KeyType
- type Metadata
- type Pageable
- type PaginationData
- type Period
- type SearchParams
- type SignatureConfiguration
- type SignatureValues
- type StrategyConfiguration
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrApplicationNotFound = errors.New("application not found") ErrEndpointNotFound = errors.New("endpoint not found") )
View Source
var ( ErrEventDeliveryNotFound = errors.New("event not found") ErrEventDeliveryAttemptNotFound = errors.New("delivery attempt not found") )
View Source
var (
ErrAPIKeyNotFound = errors.New("api key not found")
)
View Source
var (
ErrEventNotFound = errors.New("event not found")
)
View Source
var ErrGroupNotFound = errors.New("group not found")
Functions ¶
func IsValidPeriod ¶
Types ¶
type APIKey ¶
type APIKey struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` MaskID string `json:"mask_id,omitempty" bson:"mask_id"` Name string `json:"name" bson:"name"` Role auth.Role `json:"role" bson:"role"` Hash string `json:"hash,omitempty" bson:"hash"` Salt string `json:"salt,omitempty" bson:"salt"` Type KeyType `json:"key_type" bson:"key_type"` ExpiresAt primitive.DateTime `json:"expires_at,omitempty" bson:"expires_at,omitempty"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at"` DeletedAt primitive.DateTime `json:"delted_at,omitempty" bson:"deleted_at"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
type APIKeyRepository ¶
type APIKeyRepository interface { CreateAPIKey(context.Context, *APIKey) error UpdateAPIKey(context.Context, *APIKey) error FindAPIKeyByID(context.Context, string) (*APIKey, error) FindAPIKeyByMaskID(context.Context, string) (*APIKey, error) FindAPIKeyByHash(context.Context, string) (*APIKey, error) RevokeAPIKeys(context.Context, []string) error LoadAPIKeysPaged(context.Context, *Pageable) ([]APIKey, PaginationData, error) }
type AppMetadata ¶
type Application ¶
type Application struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` GroupID string `json:"group_id" bson:"group_id"` Title string `json:"name" bson:"title"` SupportEmail string `json:"support_email" bson:"support_email"` SlackWebhookURL string `json:"slack_webhook_url,omitempty" bson:"slack_webhook_url"` IsDisabled bool `json:"is_disabled" bson:"is_disabled"` Endpoints []Endpoint `json:"endpoints" bson:"endpoints"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty" swaggertype:"string"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty" swaggertype:"string"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty" swaggertype:"string"` Events int64 `json:"events" bson:"-"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
type ApplicationRepository ¶
type ApplicationRepository interface { CreateApplication(context.Context, *Application) error LoadApplicationsPaged(context.Context, string, string, Pageable) ([]Application, PaginationData, error) FindApplicationByID(context.Context, string) (*Application, error) UpdateApplication(context.Context, *Application) error DeleteApplication(context.Context, *Application) error CountGroupApplications(ctx context.Context, groupID string) (int64, error) DeleteGroupApps(context.Context, string) error LoadApplicationsPagedByGroupId(context.Context, string, Pageable) ([]Application, PaginationData, error) SearchApplicationsByGroupId(context.Context, string, SearchParams) ([]Application, error) FindApplicationEndpointByID(context.Context, string, string) (*Endpoint, error) UpdateApplicationEndpointsStatus(context.Context, string, []string, EndpointStatus) error }
type DatabaseClient ¶
type DatabaseClient interface { GetName() string Client() interface{} Disconnect(context.Context) error APIRepo() APIKeyRepository GroupRepo() GroupRepository EventRepo() EventRepository AppRepo() ApplicationRepository EventDeliveryRepo() EventDeliveryRepository }
type DeliveryAttempt ¶
type DeliveryAttempt struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` MsgID string `json:"msg_id" bson:"msg_id"` URL string `json:"url" bson:"url"` Method string `json:"method" bson:"method"` EndpointID string `json:"endpoint_id" bson:"endpoint_id"` APIVersion string `json:"api_version" bson:"api_version"` IPAddress string `json:"ip_address,omitempty" bson:"ip_address,omitempty"` RequestHeader HttpHeader `json:"request_http_header,omitempty" bson:"request_http_header,omitempty"` ResponseHeader HttpHeader `json:"response_http_header,omitempty" bson:"response_http_header,omitempty"` HttpResponseCode string `json:"http_status,omitempty" bson:"http_status,omitempty"` ResponseData string `json:"response_data,omitempty" bson:"response_data,omitempty"` Error string `json:"error,omitempty" bson:"error,omitempty"` Status bool `json:"status,omitempty" bson:"status,omitempty"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty" swaggertype:"string"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty" swaggertype:"string"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty" swaggertype:"string"` }
type DocumentStatus ¶
type DocumentStatus string
const ( ActiveDocumentStatus DocumentStatus = "Active" InactiveDocumentStatus DocumentStatus = "Inactive" DeletedDocumentStatus DocumentStatus = "Deleted" )
type Endpoint ¶
type Endpoint struct { UID string `json:"uid" bson:"uid"` TargetURL string `json:"target_url" bson:"target_url"` Description string `json:"description" bson:"description"` Status EndpointStatus `json:"status" bson:"status"` Secret string `json:"secret" bson:"secret"` HttpTimeout string `json:"http_timeout" bson:"http_timeout"` RateLimit int `json:"rate_limit" bson:"rate_limit"` RateLimitDuration string `json:"rate_limit_duration" bson:"rate_limit_duration"` Events []string `json:"events" bson:"events"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty" swaggertype:"string"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty" swaggertype:"string"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty" swaggertype:"string"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
type EndpointMetadata ¶
type EndpointMetadata struct { UID string `json:"uid" bson:"uid"` TargetURL string `json:"target_url" bson:"target_url"` Status EndpointStatus `json:"status" bson:"status"` Secret string `json:"secret" bson:"secret"` HttpTimeout string `json:"http_timeout" bson:"http_timeout"` RateLimit int `json:"rate_limit" bson:"rate_limit"` RateLimitDuration string `json:"rate_limit_duration" bson:"rate_limit_duration"` Sent bool `json:"sent" bson:"sent"` }
type EndpointStatus ¶
type EndpointStatus string
const ( ActiveEndpointStatus EndpointStatus = "active" InactiveEndpointStatus EndpointStatus = "inactive" PendingEndpointStatus EndpointStatus = "pending" )
type Event ¶
type Event struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` EventType EventType `json:"event_type" bson:"event_type"` MatchedEndpoints int `json:"matched_endpoints" bson:"matched_enpoints"` // ProviderID is a custom ID that can be used to reconcile this Event // with your internal systems. // This is optional // If not provided, we will generate one for you ProviderID string `json:"provider_id" bson:"provider_id"` // Data is an arbitrary JSON value that gets sent as the body of the // webhook to the endpoints Data json.RawMessage `json:"data" bson:"data"` AppMetadata *AppMetadata `json:"app_metadata,omitempty" bson:"app_metadata"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty" swaggertype:"string"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty" swaggertype:"string"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty" swaggertype:"string"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
Event defines a payload to be sent to an application
type EventDelivery ¶
type EventDelivery struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` EventMetadata *EventMetadata `json:"event_metadata" bson:"event_metadata"` // Endpoint contains the destination of the event. EndpointMetadata *EndpointMetadata `json:"endpoint" bson:"endpoint"` AppMetadata *AppMetadata `json:"app_metadata,omitempty" bson:"app_metadata"` Metadata *Metadata `json:"metadata" bson:"metadata"` Description string `json:"description,omitempty" bson:"description"` Status EventDeliveryStatus `json:"status" bson:"status"` DeliveryAttempts []DeliveryAttempt `json:"-" bson:"attempts"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty" swaggertype:"string"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty" swaggertype:"string"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty" swaggertype:"string"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
Event defines a payload to be sent to an application
type EventDeliveryRepository ¶
type EventDeliveryRepository interface { CreateEventDelivery(context.Context, *EventDelivery) error FindEventDeliveryByID(context.Context, string) (*EventDelivery, error) FindEventDeliveriesByIDs(context.Context, []string) ([]EventDelivery, error) FindEventDeliveriesByEventID(context.Context, string) ([]EventDelivery, error) CountDeliveriesByStatus(context.Context, EventDeliveryStatus, SearchParams) (int64, error) UpdateStatusOfEventDelivery(context.Context, EventDelivery, EventDeliveryStatus) error UpdateStatusOfEventDeliveries(context.Context, []string, EventDeliveryStatus) error UpdateEventDeliveryWithAttempt(context.Context, EventDelivery, DeliveryAttempt) error CountEventDeliveries(context.Context, string, string, string, []EventDeliveryStatus, SearchParams) (int64, error) LoadEventDeliveriesPaged(context.Context, string, string, string, []EventDeliveryStatus, SearchParams, Pageable) ([]EventDelivery, PaginationData, error) }
type EventDeliveryStatus ¶
type EventDeliveryStatus string
const ( // ScheduledEventStatus : when a Event has been scheduled for delivery ScheduledEventStatus EventDeliveryStatus = "Scheduled" ProcessingEventStatus EventDeliveryStatus = "Processing" DiscardedEventStatus EventDeliveryStatus = "Discarded" FailureEventStatus EventDeliveryStatus = "Failure" SuccessEventStatus EventDeliveryStatus = "Success" RetryEventStatus EventDeliveryStatus = "Retry" )
func (EventDeliveryStatus) IsValid ¶ added in v0.4.10
func (e EventDeliveryStatus) IsValid() bool
type EventInterval ¶
type EventInterval struct { Data EventIntervalData `json:"data" bson:"_id"` Count uint64 `json:"count" bson:"count"` }
type EventIntervalData ¶
type EventMetadata ¶
type EventRepository ¶
type EventRepository interface { CreateEvent(context.Context, *Event) error LoadEventIntervals(context.Context, string, SearchParams, Period, int) ([]EventInterval, error) FindEventByID(ctx context.Context, id string) (*Event, error) CountGroupMessages(ctx context.Context, groupID string) (int64, error) LoadEventsPaged(context.Context, string, string, SearchParams, Pageable) ([]Event, PaginationData, error) DeleteGroupEvents(context.Context, string) error }
type EventType ¶
type EventType string
EventType is used to identify an specific event. This could be "user.new" This will be used for data indexing Makes it easy to filter by a list of events
type ExponentialBackoffStrategyConfiguration ¶ added in v0.4.10
type ExponentialBackoffStrategyConfiguration struct {
RetryLimit uint64 `json:"retryLimit"`
}
type Filter ¶ added in v0.5.0
type Filter struct { Group *Group AppID string EventID string Pageable Pageable Status []EventDeliveryStatus SearchParams SearchParams }
type Group ¶
type Group struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` Name string `json:"name" bson:"name"` LogoURL string `json:"logo_url" bson:"logo_url"` Config *GroupConfig `json:"config" bson:"config"` Statistics *GroupStatistics `json:"statistics" bson:"-"` RateLimit int `json:"rate_limit" bson:"rate_limit"` RateLimitDuration string `json:"rate_limit_duration" bson:"rate_limit_duration"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty" swaggertype:"string"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty" swaggertype:"string"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty" swaggertype:"string"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
func (*Group) IsOwner ¶
func (o *Group) IsOwner(a *Application) bool
type GroupConfig ¶
type GroupConfig struct { Strategy StrategyConfiguration `json:"strategy"` Signature SignatureConfiguration `json:"signature"` DisableEndpoint bool `json:"disable_endpoint"` ReplayAttacks bool `json:"replay_attacks"` }
type GroupFilter ¶
type GroupFilter struct {
Names []string `json:"name" bson:"name"`
}
func (*GroupFilter) WithNamesTrimmed ¶ added in v0.5.3
func (g *GroupFilter) WithNamesTrimmed() *GroupFilter
type GroupRepository ¶
type GroupRepository interface { LoadGroups(context.Context, *GroupFilter) ([]*Group, error) CreateGroup(context.Context, *Group) error UpdateGroup(context.Context, *Group) error DeleteGroup(ctx context.Context, uid string) error FetchGroupByID(context.Context, string) (*Group, error) FetchGroupsByIDs(context.Context, []string) ([]Group, error) }
type GroupStatistics ¶
type HttpHeader ¶
type Metadata ¶
type Metadata struct { // Data to be sent to endpoint. Data json.RawMessage `json:"data" bson:"data"` Strategy config.StrategyProvider `json:"strategy" bson:"strategy"` // NextSendTime denotes the next time a Event will be published in // case it failed the first time NextSendTime primitive.DateTime `json:"next_send_time" bson:"next_send_time"` // NumTrials: number of times we have tried to deliver this Event to // an application NumTrials uint64 `json:"num_trials" bson:"num_trials"` IntervalSeconds uint64 `json:"interval_seconds" bson:"interval_seconds"` RetryLimit uint64 `json:"retry_limit" bson:"retry_limit"` }
type PaginationData ¶
type SearchParams ¶
type SignatureConfiguration ¶
type SignatureConfiguration struct { Header config.SignatureHeaderProvider `json:"header" valid:"required~please provide a valid signature header"` Hash string `json:"hash" valid:"required~please provide a valid hash,supported_hash~unsupported hash type"` }
type SignatureValues ¶ added in v0.5.3
type SignatureValues struct { Header config.SignatureHeaderProvider `json:"header" valid:"required~please provide a valid signature header"` Hash string `json:"hash" valid:"required~please provide a valid hash,supported_hash~unsupported hash type"` }
type StrategyConfiguration ¶
type StrategyConfiguration struct { Type config.StrategyProvider `json:"type" valid:"required~please provide a valid strategy type, in(default)~unsupported strategy type"` Default DefaultStrategyConfiguration `json:"default"` ExponentialBackoff ExponentialBackoffStrategyConfiguration `json:"exponentialBackoff,omitempty"` }
Click to show internal directories.
Click to hide internal directories.