domain

package
v0.0.0-...-ead2a4b Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EnvTypeProduction  = EnvType{"production"}
	EnvTypeDevelopment = EnvType{"development"}
)
View Source
var (
	ErrApiKeyExists        = errors.New("the api key already exists")
	ErrApiKeyNotFound      = errors.New("api key not found")
	ErrAppNotFound         = errors.New("application not found")
	ErrEndpointNotFound    = errors.New("endpoint not found")
	ErrEventTypeNotFound   = errors.New("event type not found")
	ErrMessageNotFound     = errors.New("message not found")
	ErrEnvironmentNotFound = errors.New("environment not found")
)
View Source
var (
	ErrApiKeyIsExpired = errors.New("api key is expired")
)

Functions

This section is empty.

Types

type ApiKey

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

func NewApiKey

func NewApiKey(
	name string,
	orgID string,
	envID EnvironmentID,
	expiresAt *time.Time,
	isTestApiKey bool,
) (*ApiKey, error)

func UnMarshallApiKey

func UnMarshallApiKey(
	id ApiKeyID,
	envID EnvironmentID,
	orgID,
	name string,
	secretKey SecretKey,
	createdAt time.Time,
	expiresAt *time.Time,
) (*ApiKey, error)

func (*ApiKey) CreatedAt

func (a *ApiKey) CreatedAt() time.Time

func (*ApiKey) EnvID

func (a *ApiKey) EnvID() EnvironmentID

func (*ApiKey) ExpiresAt

func (a *ApiKey) ExpiresAt() *time.Time

func (*ApiKey) Id

func (a *ApiKey) Id() ApiKeyID

func (*ApiKey) IsExpired

func (a *ApiKey) IsExpired() bool

func (*ApiKey) Name

func (a *ApiKey) Name() string

func (*ApiKey) OrgID

func (a *ApiKey) OrgID() string

func (*ApiKey) SecretKey

func (a *ApiKey) SecretKey() SecretKey

type ApiKeyID

type ApiKeyID string

func NewApiKeyID

func NewApiKeyID() ApiKeyID

func (ApiKeyID) String

func (i ApiKeyID) String() string

type ApiKeyRepository

type ApiKeyRepository interface {
	Insert(ctx context.Context, apiKey *ApiKey) error
	Destroy(ctx context.Context, orgID string, id ApiKeyID) error
	FindBySecretKey(ctx context.Context, sk SecretKey) (*ApiKey, error)
	FindAll(ctx context.Context, orgID string, envID EnvironmentID) ([]*ApiKey, error)
}

type Application

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

func NewApplication

func NewApplication(name string, envID EnvironmentID) (*Application, error)

func UnMarshallApplication

func UnMarshallApplication(id ApplicationID, name string, envID EnvironmentID, createdAt time.Time) *Application

func (*Application) CreatedAt

func (a *Application) CreatedAt() time.Time

func (*Application) EnvID

func (a *Application) EnvID() EnvironmentID

func (*Application) ID

func (a *Application) ID() ApplicationID

func (*Application) Name

func (a *Application) Name() string

type ApplicationID

type ApplicationID string

func NewApplicationID

func NewApplicationID() ApplicationID

func (ApplicationID) String

func (i ApplicationID) String() string

type ApplicationRepository

type ApplicationRepository interface {
	Insert(ctx context.Context, application *Application) error
}

type Endpoint

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

func NewEndpoint

func NewEndpoint(
	endpointURL EndpointURL,
	applicationID ApplicationID,
	description string,
	eventTypeIDs []EventTypeID,
) (*Endpoint, error)

func UnMarshallEndpoint

func UnMarshallEndpoint(
	id EndpointID,
	applicationID ApplicationID,
	endpointURL,
	description string,
	headers Headers,
	eventTypeIDs []EventTypeID,
	signingSecret string,
	createdAt,
	updatedAt time.Time,
) (*Endpoint, error)

func (*Endpoint) ApplicationID

func (e *Endpoint) ApplicationID() ApplicationID

func (*Endpoint) CreatedAt

func (e *Endpoint) CreatedAt() time.Time

func (*Endpoint) Description

func (e *Endpoint) Description() string

func (*Endpoint) EndpointURL

func (e *Endpoint) EndpointURL() EndpointURL

func (*Endpoint) EventTypeIDs

func (e *Endpoint) EventTypeIDs() []EventTypeID

func (*Endpoint) Headers

func (e *Endpoint) Headers() map[string]string

func (*Endpoint) ID

func (e *Endpoint) ID() EndpointID

func (*Endpoint) SigningSecret

func (e *Endpoint) SigningSecret() SigningSecret

func (*Endpoint) UpdatedAt

func (e *Endpoint) UpdatedAt() time.Time

type EndpointID

type EndpointID string

func NewEndpointID

func NewEndpointID() EndpointID

func (EndpointID) String

func (i EndpointID) String() string

type EndpointRepository

type EndpointRepository interface {
	Insert(ctx context.Context, endpoint *Endpoint) error
	ByID(ctx context.Context, id EndpointID) (*Endpoint, error)
	ByEventTypeIdOrAppID(ctx context.Context, eventTypeID *EventTypeID, appID ApplicationID) ([]*Endpoint, error)
}

type EndpointURL

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

func NewEndpointURL

func NewEndpointURL(rawURL string) (EndpointURL, error)

func (EndpointURL) IsEmpty

func (e EndpointURL) IsEmpty() bool

func (EndpointURL) String

func (e EndpointURL) String() string

type EnvType

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

func (EnvType) String

func (e EnvType) String() string

func (EnvType) Validate

func (e EnvType) Validate() error

type Environment

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

func NewEnvironment

func NewEnvironment(name string, orgID string, envType EnvType) (*Environment, error)

func UnMarshallEnvironment

func UnMarshallEnvironment(
	id EnvironmentID,
	orgID, name, envType string,
	createdAt time.Time,
	archivedAt *time.Time,
) (*Environment, error)

func (*Environment) ArchivedAt

func (e *Environment) ArchivedAt() *time.Time

func (*Environment) CreatedAt

func (e *Environment) CreatedAt() time.Time

func (*Environment) ID

func (e *Environment) ID() EnvironmentID

func (*Environment) Name

func (e *Environment) Name() string

func (*Environment) OrgID

func (e *Environment) OrgID() string

func (*Environment) Type

func (e *Environment) Type() EnvType

type EnvironmentID

type EnvironmentID string

func NewEnvironmentID

func NewEnvironmentID() EnvironmentID

func (EnvironmentID) String

func (i EnvironmentID) String() string

type EnvironmentRepository

type EnvironmentRepository interface {
	ByID(ctx context.Context, id EnvironmentID) (*Environment, error)
	Insert(ctx context.Context, env *Environment) error
	FindAll(ctx context.Context, orgID string) ([]*Environment, error)
}

type EventType

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

func NewEventType

func NewEventType(orgID, name, description, schema, schemaExample string) (*EventType, error)

func UnMarshallEventType

func UnMarshallEventType(
	id EventTypeID,
	orgID string,
	name, description, schema, schemaExample string,
	createdAt time.Time,
	archivedAt *time.Time,
) *EventType

func (*EventType) ArchivedAt

func (e *EventType) ArchivedAt() *time.Time

func (*EventType) CreatedAt

func (e *EventType) CreatedAt() time.Time

func (*EventType) Description

func (e *EventType) Description() string

func (*EventType) ID

func (e *EventType) ID() EventTypeID

func (*EventType) Name

func (e *EventType) Name() string

func (*EventType) OrgID

func (e *EventType) OrgID() string

func (*EventType) Schema

func (e *EventType) Schema() string

func (*EventType) SchemaExample

func (e *EventType) SchemaExample() string

type EventTypeID

type EventTypeID string

func NewEventTypeID

func NewEventTypeID() EventTypeID

func (EventTypeID) String

func (i EventTypeID) String() string

type EventTypeRepository

type EventTypeRepository interface {
	Insert(ctx context.Context, eventType *EventType) error
	ByID(ctx context.Context, orgID string, id EventTypeID) (*EventType, error)
}

type Headers

type Headers map[string]string

type ID

type ID string

func NewID

func NewID() ID

func NewIDFromString

func NewIDFromString(value string) (ID, error)

func (ID) IsEmpty

func (i ID) IsEmpty() bool

func (ID) String

func (i ID) String() string

func (ID) ToMessageID

func (i ID) ToMessageID() MessageID

func (ID) WithPrefix

func (i ID) WithPrefix(prefix string) ID

type Message

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

func NewMessage

func NewMessage(eventTypeID *EventTypeID, orgID string, applicationID ApplicationID, payload string) (*Message, error)

func UnMarshallMessage

func UnMarshallMessage(
	id MessageID,
	eventTypeID *EventTypeID,
	applicationID ApplicationID,
	orgID string,
	sentAt time.Time,
	payload string,
) (*Message, error)

func (*Message) ApplicationID

func (m *Message) ApplicationID() ApplicationID

func (*Message) EventTypeID

func (m *Message) EventTypeID() *EventTypeID

func (*Message) Id

func (m *Message) Id() MessageID

func (*Message) OrgID

func (m *Message) OrgID() string

func (*Message) Payload

func (m *Message) Payload() string

func (*Message) SendAttempts

func (m *Message) SendAttempts() []MessageSendAttempt

func (*Message) SentAt

func (m *Message) SentAt() time.Time

type MessageID

type MessageID string

func NewMessageID

func NewMessageID() MessageID

func (MessageID) String

func (i MessageID) String() string

type MessageRepository

type MessageRepository interface {
	ByID(ctx context.Context, id MessageID) (*Message, error)
	Insert(ctx context.Context, message *Message) error
	SaveMessageSendAttempt(ctx context.Context, attempt *MessageSendAttempt) error
}

type MessageSendAttempt

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

func NewMessageSendAttempt

func NewMessageSendAttempt(
	endpointID EndpointID,
	messageID MessageID,
	response string,
	statusCode StatusCode,
	requestHeaders Headers,
) (*MessageSendAttempt, error)

func (*MessageSendAttempt) EndpointID

func (m *MessageSendAttempt) EndpointID() EndpointID

func (*MessageSendAttempt) ID

func (*MessageSendAttempt) MessageID

func (m *MessageSendAttempt) MessageID() MessageID

func (*MessageSendAttempt) RequestHeaders

func (m *MessageSendAttempt) RequestHeaders() Headers

func (*MessageSendAttempt) Response

func (m *MessageSendAttempt) Response() string

func (*MessageSendAttempt) Status

func (*MessageSendAttempt) StatusCode

func (m *MessageSendAttempt) StatusCode() StatusCode

func (*MessageSendAttempt) Timestamp

func (m *MessageSendAttempt) Timestamp() time.Time

type MsgSendAttemptID

type MsgSendAttemptID string

func NewMsgSendAttemptID

func NewMsgSendAttemptID() MsgSendAttemptID

func (MsgSendAttemptID) String

func (i MsgSendAttemptID) String() string

type SecretKey

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

func UnMarshallSecretKey

func UnMarshallSecretKey(value string) (SecretKey, error)

func (SecretKey) FullKey

func (k SecretKey) FullKey() string

func (SecretKey) String

func (k SecretKey) String() string

String returns a trimmed version of the key by showing only the last 5 characters of the hash

type SendAttemptStatus

type SendAttemptStatus string

func (SendAttemptStatus) String

func (s SendAttemptStatus) String() string

type SigningSecret

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

func NewSigningSecret

func NewSigningSecret() (SigningSecret, error)

func UnMarshallSigningSecret

func UnMarshallSigningSecret(value string) (SigningSecret, error)

func (SigningSecret) IsEmpty

func (s SigningSecret) IsEmpty() string

func (SigningSecret) String

func (s SigningSecret) String() string

func (SigningSecret) UnEncoded

func (s SigningSecret) UnEncoded() ([]byte, error)

type StatusCode

type StatusCode uint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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