Documentation ¶
Index ¶
- Variables
- func IsValidPeriod(period string) bool
- type AppMetadata
- type Application
- type ApplicationRepository
- type Datastore
- type DocumentStatus
- type Endpoint
- type EndpointMetadata
- type EventType
- type HttpMethod
- type Message
- type MessageAttempt
- type MessageMetadata
- type MessageRepository
- type MessageStatus
- type Organisation
- type OrganisationRepository
- type Period
- type Plugin
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrApplicationNotFound = errors.New("application not found") ErrEndpointNotFound = errors.New("endpoint not found") )
View Source
var ( ErrMessageNotFound = errors.New("event not found") ErrMessageDeliveryAttemptNotFound = errors.New("delivery attempt not found") )
View Source
var ErrOrganisationNotFound = errors.New("organisation not found")
Functions ¶
func IsValidPeriod ¶ added in v0.1.0
Types ¶
type AppMetadata ¶ added in v0.1.0
type AppMetadata struct { OrgID string `json:"org_id" bson:"org_id"` Secret string `json:"secret" bson:"secret"` Endpoints []EndpointMetadata `json:"endpoints" bson:"endpoints"` }
type Application ¶ added in v0.1.0
type Application struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` OrgID string `json:"org_id" bson:"org_id"` Title string `json:"name" bson:"title"` Secret string `json:"secret" bson:"secret"` Endpoints []Endpoint `json:"endpoints" bson:"endpoints"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty"` Events int64 `json:"events" bson:"-"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
type ApplicationRepository ¶ added in v0.1.0
type ApplicationRepository interface { CreateApplication(context.Context, *Application) error LoadApplicationsPaged(context.Context, string, models.Pageable) ([]Application, pager.PaginationData, error) FindApplicationByID(context.Context, string) (*Application, error) UpdateApplication(context.Context, *Application) error DeleteApplication(context.Context, *Application) error LoadApplicationsPagedByOrgId(context.Context, string, models.Pageable) ([]Application, pager.PaginationData, error) SearchApplicationsByOrgId(context.Context, string, models.SearchParams) ([]Application, error) }
type Datastore ¶ added in v0.1.0
type Datastore interface { OrganisationRepository ApplicationRepository // EndpointRepository io.Closer Migrate() error }
Datastore provides an abstraction for all database related operations
type DocumentStatus ¶ added in v0.1.0
type DocumentStatus string
const ( ActiveDocumentStatus DocumentStatus = "Active" InactiveDocumentStatus DocumentStatus = "Inactive" DeletedDocumentStatus DocumentStatus = "Deleted" )
type Endpoint ¶ added in v0.1.0
type Endpoint struct { UID string `json:"uid" bson:"uid"` TargetURL string `json:"target_url" bson:"target_url"` Description string `json:"description" bson:"description"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
type EndpointMetadata ¶ added in v0.1.0
type EventType ¶ added in v0.1.0
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 Message ¶ added in v0.1.0
type Message struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` AppID string `json:"app_id" bson:"app_id"` EventType EventType `json:"event_type" bson:"event_type"` // ProviderID is a custom ID that can be used to reconcile this message // 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"` Metadata *MessageMetadata `json:"metadata" bson:"metadata"` Description string `json:"description,omitempty" bson:"description"` Status MessageStatus `json:"status" bson:"status"` AppMetadata *AppMetadata `json:"app_metadata,omitempty" bson:"app_metadata"` MessageAttempts []MessageAttempt `json:"-" bson:"attempts"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
Message defines a payload to be sent to an application
type MessageAttempt ¶ added in v0.1.0
type MessageAttempt struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` MsgID string `json:"msg_id" bson:"msg_id"` 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"` ContentType string `json:"content_type,omitempty" bson:"content_type,omitempty"` Header http.Header `json:"http_header,omitempty" bson:"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 MessageStatus `json:"status,omitempty" bson:"status,omitempty"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty"` }
type MessageMetadata ¶ added in v0.1.0
type MessageMetadata struct { Strategy config.StrategyProvider `json:"strategy" bson:"strategy"` // NextSendTime denotes the next time a message 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 message 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 MessageRepository ¶ added in v0.1.0
type MessageRepository interface { CreateMessage(context.Context, *Message) error LoadMessageIntervals(context.Context, string, models.SearchParams, Period, int) ([]models.MessageInterval, error) LoadMessagesPagedByAppId(context.Context, string, models.Pageable) ([]Message, pager.PaginationData, error) FindMessageByID(ctx context.Context, id string) (*Message, error) LoadMessagesScheduledForPosting(context.Context) ([]Message, error) LoadMessagesForPostingRetry(context.Context) ([]Message, error) LoadAbandonedMessagesForPostingRetry(context.Context) ([]Message, error) UpdateStatusOfMessages(context.Context, []Message, MessageStatus) error UpdateMessageWithAttempt(ctx context.Context, m Message, attempt MessageAttempt) error LoadMessagesPaged(context.Context, string, models.Pageable) ([]Message, pager.PaginationData, error) }
type MessageStatus ¶ added in v0.1.0
type MessageStatus string
const ( // ScheduledMessageStatus : when a message has been scheduled for delivery ScheduledMessageStatus MessageStatus = "Scheduled" ProcessingMessageStatus MessageStatus = "Processing" FailureMessageStatus MessageStatus = "Failure" SuccessMessageStatus MessageStatus = "Success" RetryMessageStatus MessageStatus = "Retry" )
type Organisation ¶ added in v0.1.0
type Organisation struct { ID primitive.ObjectID `json:"-" bson:"_id"` UID string `json:"uid" bson:"uid"` OrgName string `json:"name" bson:"org_name"` CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty"` DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty"` DocumentStatus DocumentStatus `json:"-" bson:"document_status"` }
func (*Organisation) IsDeleted ¶ added in v0.1.0
func (o *Organisation) IsDeleted() bool
func (*Organisation) IsOwner ¶ added in v0.1.0
func (o *Organisation) IsOwner(a *Application) bool
type OrganisationRepository ¶ added in v0.1.0
type OrganisationRepository interface { LoadOrganisations(context.Context) ([]*Organisation, error) CreateOrganisation(context.Context, *Organisation) error UpdateOrganisation(context.Context, *Organisation) error FetchOrganisationByID(context.Context, string) (*Organisation, error) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.