app

package
v0.0.0-...-2e97daa Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RelayConnectionStateInitializing = RelayConnectionState{"initializing"}
	RelayConnectionStateConnected    = RelayConnectionState{"connected"}
	RelayConnectionStateDisconnected = RelayConnectionState{"disconnected"}
)
View Source
var (
	ErrAccountDoesNotExist = errors.New("account doesn't exist")
	ErrSessionDoesNotExist = errors.New("session doesn't exist")
)

Functions

This section is empty.

Types

type AccountIDGenerator

type AccountIDGenerator interface {
	GenerateAccountID() (accounts.AccountID, error)
}

type AccountRepository

type AccountRepository interface {
	// Returns ErrAccountDoesNotExist.
	GetByTwitterID(twitterID accounts.TwitterID) (*accounts.Account, error)

	// Returns ErrAccountDoesNotExist.
	GetByAccountID(accountID accounts.AccountID) (*accounts.Account, error)

	Save(account *accounts.Account) error

	Count() (int, error)
}

type Adapters

type Adapters struct {
	Accounts        AccountRepository
	Sessions        SessionRepository
	PublicKeys      PublicKeyRepository
	ProcessedEvents ProcessedEventRepository
	UserTokens      UserTokensRepository
	Publisher       Publisher
}

type Application

type Application struct {
	GetSessionAccount        *GetSessionAccountHandler
	GetAccountPublicKeys     *GetAccountPublicKeysHandler
	GetTwitterAccountDetails *GetTwitterAccountDetailsHandler

	LoginOrRegister *LoginOrRegisterHandler
	Logout          *LogoutHandler
	LinkPublicKey   *LinkPublicKeyHandler
	UnlinkPublicKey *UnlinkPublicKeyHandler
	UpdateMetrics   *UpdateMetricsHandler
}

type ApplicationCall

type ApplicationCall interface {
	// End accepts a pointer so that you can defer this call without wrapping it
	// in an anonymous function
	End(err *error)
}

type CurrentTimeProvider

type CurrentTimeProvider interface {
	GetCurrentTime() time.Time
}

type Downloader

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

func NewDownloader

func NewDownloader(
	transaction TransactionProvider,
	receivedEventPublisher ReceivedEventPublisher,
	logger logging.Logger,
	metrics Metrics,
	relaySource RelaySource,
	relayEventDownloader RelayEventDownloader,
) *Downloader

func (*Downloader) Run

func (d *Downloader) Run(ctx context.Context) error

type EventOrEndOfSavedEvents

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

func NewEventOrEndOfSavedEventsWithEOSE

func NewEventOrEndOfSavedEventsWithEOSE() EventOrEndOfSavedEvents

func NewEventOrEndOfSavedEventsWithEvent

func NewEventOrEndOfSavedEventsWithEvent(event domain.Event) EventOrEndOfSavedEvents

func (*EventOrEndOfSavedEvents) EOSE

func (e *EventOrEndOfSavedEvents) EOSE() bool

func (*EventOrEndOfSavedEvents) Event

type GetAccountPublicKeys

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

func NewGetAccountPublicKeys

func NewGetAccountPublicKeys(accountID accounts.AccountID) GetAccountPublicKeys

type GetAccountPublicKeysHandler

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

func NewGetAccountPublicKeysHandler

func NewGetAccountPublicKeysHandler(
	transactionProvider TransactionProvider,
	logger logging.Logger,
	metrics Metrics,
) *GetAccountPublicKeysHandler

func (*GetAccountPublicKeysHandler) Handle

type GetSessionAccount

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

func NewGetSessionAccount

func NewGetSessionAccount(sessionID sessions.SessionID) GetSessionAccount

type GetSessionAccountHandler

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

func NewGetSessionAccountHandler

func NewGetSessionAccountHandler(
	transactionProvider TransactionProvider,
	logger logging.Logger,
	metrics Metrics,
) *GetSessionAccountHandler

func (*GetSessionAccountHandler) Handle

func (h *GetSessionAccountHandler) Handle(ctx context.Context, cmd GetSessionAccount) (result *accounts.Account, err error)

type GetTwitterAccountDetails

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

func NewGetTwitterAccountDetails

func NewGetTwitterAccountDetails(accountID accounts.AccountID) GetTwitterAccountDetails

type GetTwitterAccountDetailsHandler

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

func NewGetTwitterAccountDetailsHandler

func NewGetTwitterAccountDetailsHandler(
	transactionProvider TransactionProvider,
	twitter Twitter,
	cache TwitterAccountDetailsCache,
	logger logging.Logger,
	metrics Metrics,
) *GetTwitterAccountDetailsHandler

func (*GetTwitterAccountDetailsHandler) Handle

type LinkPublicKey

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

func NewLinkPublicKey

func NewLinkPublicKey(accountID accounts.AccountID, publicKey domain.PublicKey) LinkPublicKey

type LinkPublicKeyHandler

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

func NewLinkPublicKeyHandler

func NewLinkPublicKeyHandler(
	transactionProvider TransactionProvider,
	logger logging.Logger,
	metrics Metrics,
) *LinkPublicKeyHandler

func (*LinkPublicKeyHandler) Handle

func (h *LinkPublicKeyHandler) Handle(ctx context.Context, cmd LinkPublicKey) (err error)

type LoginOrRegister

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

func NewLoginOrRegister

func NewLoginOrRegister(
	twitterID accounts.TwitterID,
	accessToken accounts.TwitterUserAccessToken,
	accessSecret accounts.TwitterUserAccessSecret,
) LoginOrRegister

type LoginOrRegisterHandler

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

func NewLoginOrRegisterHandler

func NewLoginOrRegisterHandler(
	transactionProvider TransactionProvider,
	accountIDGenerator AccountIDGenerator,
	sessionIDGenerator SessionIDGenerator,
	logger logging.Logger,
	metrics Metrics,
) *LoginOrRegisterHandler

func (*LoginOrRegisterHandler) Handle

func (h *LoginOrRegisterHandler) Handle(ctx context.Context, cmd LoginOrRegister) (session *sessions.Session, err error)

type Logout

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

func NewLogout

func NewLogout(sessionID sessions.SessionID) Logout

type LogoutHandler

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

func NewLogoutHandler

func NewLogoutHandler(
	transactionProvider TransactionProvider,
	logger logging.Logger,
	metrics Metrics,
) *LogoutHandler

func (*LogoutHandler) Handle

func (h *LogoutHandler) Handle(ctx context.Context, cmd Logout) (err error)

type Metrics

type Metrics interface {
	StartApplicationCall(handlerName string) ApplicationCall
	ReportNumberOfPublicKeyDownloaders(n int)
	ReportNumberOfPublicKeyDownloaderRelays(publicKey domain.PublicKey, n int)
	ReportRelayConnectionState(m map[domain.RelayAddress]RelayConnectionState)
	ReportCallingTwitterAPIToPostATweet(err error)
	ReportCallingTwitterAPIToGetAUser(err error)
	ReportSubscriptionQueueLength(topic string, n int)
	ReportPurplePagesLookupResult(address domain.RelayAddress, err *error)
	ReportTweetCreatedCountPerAccount(m map[accounts.AccountID]int)
	ReportNumberOfAccounts(count int)
	ReportNumberOfLinkedPublicKeys(count int)
}

type ProcessReceivedEvent

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

func NewProcessReceivedEvent

func NewProcessReceivedEvent(relay domain.RelayAddress, event domain.Event) ProcessReceivedEvent

type ProcessReceivedEventHandler

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

func NewProcessReceivedEventHandler

func NewProcessReceivedEventHandler(
	transactionProvider TransactionProvider,
	tweetGenerator TweetGenerator,
	logger logging.Logger,
	metrics Metrics,
) *ProcessReceivedEventHandler

func (*ProcessReceivedEventHandler) Handle

type ProcessedEventRepository

type ProcessedEventRepository interface {
	Save(eventID domain.EventId, twitterID accounts.TwitterID) error
	WasProcessed(eventID domain.EventId, twitterID accounts.TwitterID) (bool, error)
}

type PublicKeyDownloader

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

func NewPublicKeyDownloader

func NewPublicKeyDownloader(
	receivedEventPublisher ReceivedEventPublisher,
	relaySource RelaySource,
	relayEventDownloader RelayEventDownloader,
	metrics Metrics,
	logger logging.Logger,
	publicKey domain.PublicKey,
) *PublicKeyDownloader

func (*PublicKeyDownloader) Run

func (d *PublicKeyDownloader) Run(ctx context.Context)

type PublicKeyRepository

type PublicKeyRepository interface {
	Save(linkedPublicKey *domain.LinkedPublicKey) error
	Delete(accountID accounts.AccountID, publicKey domain.PublicKey) error
	DeleteByPublicKey(publicKey domain.PublicKey) error
	List() ([]*domain.LinkedPublicKey, error)
	ListByPublicKey(publicKey domain.PublicKey) ([]*domain.LinkedPublicKey, error)
	ListByAccountID(accountID accounts.AccountID) ([]*domain.LinkedPublicKey, error)
	Count() (int, error)
}

type Publisher

type Publisher interface {
	PublishTweetCreated(event TweetCreatedEvent) error
}

type ReceivedEvent

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

func NewReceivedEvent

func NewReceivedEvent(relay domain.RelayAddress, event domain.Event) ReceivedEvent

func (ReceivedEvent) Event

func (r ReceivedEvent) Event() domain.Event

func (ReceivedEvent) Relay

func (r ReceivedEvent) Relay() domain.RelayAddress

type ReceivedEventPublisher

type ReceivedEventPublisher interface {
	Publish(relay domain.RelayAddress, event domain.Event)
}

type ReceivedEventSubscriber

type ReceivedEventSubscriber interface {
	Subscribe(ctx context.Context) <-chan ReceivedEvent
}

type RelayConnectionState

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

func (RelayConnectionState) String

func (r RelayConnectionState) String() string

type RelayEventDownloader

type RelayEventDownloader interface {
	GetEvents(ctx context.Context, publicKey domain.PublicKey, relayAddress domain.RelayAddress, eventKinds []domain.EventKind, maxAge *time.Duration) <-chan EventOrEndOfSavedEvents
}

type RelaySource

type RelaySource interface {
	GetRelays(ctx context.Context, publicKey domain.PublicKey) ([]domain.RelayAddress, error)
}

type SendTweet

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

func NewSendTweet

func NewSendTweet(accountID accounts.AccountID, tweet domain.Tweet, event domain.Event) SendTweet

func (SendTweet) AccountID

func (s SendTweet) AccountID() accounts.AccountID

func (SendTweet) Event

func (s SendTweet) Event() domain.Event

func (SendTweet) Tweet

func (s SendTweet) Tweet() domain.Tweet

type SendTweetHandler

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

func NewSendTweetHandler

func NewSendTweetHandler(
	transactionProvider TransactionProvider,
	twitter Twitter,
	currentTimeProvider CurrentTimeProvider,
	logger logging.Logger,
	metrics Metrics,
) *SendTweetHandler

func (*SendTweetHandler) Handle

func (h *SendTweetHandler) Handle(ctx context.Context, cmd SendTweet) (err error)

type SessionIDGenerator

type SessionIDGenerator interface {
	GenerateSessionID() (sessions.SessionID, error)
}

type SessionRepository

type SessionRepository interface {
	// Returns ErrSessionDoesNotExist.
	Get(id sessions.SessionID) (*sessions.Session, error)

	Save(session *sessions.Session) error

	Delete(id sessions.SessionID) error
}

type Subscriber

type Subscriber interface {
	TweetCreatedQueueLength(ctx context.Context) (int, error)
	TweetCreatedAnalysis(ctx context.Context) (TweetCreatedAnalysis, error)
}

type TransactionProvider

type TransactionProvider interface {
	Transact(context.Context, func(context.Context, Adapters) error) error
}

type TweetCreatedAnalysis

type TweetCreatedAnalysis struct {
	TweetsPerAccountID map[accounts.AccountID]int
}

type TweetCreatedEvent

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

func NewTweetCreatedEvent

func NewTweetCreatedEvent(
	accountID accounts.AccountID,
	tweet domain.Tweet,
	createdAt time.Time,
	event domain.Event,
) TweetCreatedEvent

func (TweetCreatedEvent) AccountID

func (t TweetCreatedEvent) AccountID() accounts.AccountID

func (TweetCreatedEvent) CreatedAt

func (t TweetCreatedEvent) CreatedAt() time.Time

func (TweetCreatedEvent) Event

func (t TweetCreatedEvent) Event() domain.Event

func (TweetCreatedEvent) Tweet

func (t TweetCreatedEvent) Tweet() domain.Tweet

type TweetGenerator

type TweetGenerator interface {
	Generate(event domain.Event) ([]domain.Tweet, error)
}

type Twitter

type Twitter interface {
	PostTweet(
		ctx context.Context,
		userAccessToken accounts.TwitterUserAccessToken,
		userAccessSecret accounts.TwitterUserAccessSecret,
		tweet domain.Tweet,
	) error

	GetAccountDetails(
		ctx context.Context,
		userAccessToken accounts.TwitterUserAccessToken,
		userAccessSecret accounts.TwitterUserAccessSecret,
	) (TwitterAccountDetails, error)
}

type TwitterAccountDetails

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

func NewTwitterAccountDetails

func NewTwitterAccountDetails(name string, username string, profileImageURL string) (TwitterAccountDetails, error)

func (TwitterAccountDetails) Name

func (t TwitterAccountDetails) Name() string

func (TwitterAccountDetails) ProfileImageURL

func (t TwitterAccountDetails) ProfileImageURL() string

func (TwitterAccountDetails) Username

func (t TwitterAccountDetails) Username() string

type TwitterAccountDetailsCache

type TwitterAccountDetailsCache interface {
	Get(accountID accounts.AccountID, updateFn func() (TwitterAccountDetails, error)) (TwitterAccountDetails, error)
}

type UnlinkPublicKey

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

func NewUnlinkPublicKey

func NewUnlinkPublicKey(accountID accounts.AccountID, publicKey domain.PublicKey) UnlinkPublicKey

type UnlinkPublicKeyHandler

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

func NewUnlinkPublicKeyHandler

func NewUnlinkPublicKeyHandler(
	transactionProvider TransactionProvider,
	logger logging.Logger,
	metrics Metrics,
) *UnlinkPublicKeyHandler

func (*UnlinkPublicKeyHandler) Handle

func (h *UnlinkPublicKeyHandler) Handle(ctx context.Context, cmd UnlinkPublicKey) (err error)

type UpdateMetricsHandler

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

func NewUpdateMetricsHandler

func NewUpdateMetricsHandler(
	transactionProvider TransactionProvider,
	subscriber Subscriber,
	logger logging.Logger,
	metrics Metrics,
) *UpdateMetricsHandler

func (*UpdateMetricsHandler) Handle

func (h *UpdateMetricsHandler) Handle(ctx context.Context) (err error)

type UserTokensRepository

type UserTokensRepository interface {
	Save(userTokens *accounts.TwitterUserTokens) error
	Get(id accounts.AccountID) (*accounts.TwitterUserTokens, error)
}

type VanishSubscriber

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

func NewVanishSubscriber

func NewVanishSubscriber(
	transactionProvider TransactionProvider,
	logger logging.Logger,
) *VanishSubscriber

func (*VanishSubscriber) Run

func (f *VanishSubscriber) Run(ctx context.Context) error

Processes messages from the vanish_requests stream and updates the last_id when done

Jump to

Keyboard shortcuts

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