gotimestatus

package
v0.0.0-...-5fb48e9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultStore

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

DefaultStore is a default implementation of the Store interface.

func NewStore

func NewStore(rc *redis.Client) (*DefaultStore, error)

NewStore returns a new DefaultStore.

func (*DefaultStore) Get

func (s *DefaultStore) Get(ctx context.Context) (string, bool, error)

Get satisfies Store.

func (*DefaultStore) Put

func (s *DefaultStore) Put(ctx context.Context, id string) error

Put satisfies Store.

type GoTimeStatus

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

GoTimeStatus posts social status updates from @gotime@changelog.social

func New

func New(s Store, c *http.Client, logger zerolog.Logger, statusMaxAge time.Duration, notify NotifyFunc) (*GoTimeStatus, error)

New constructs a *GoTimeStatus.

statusMaxAge sets the max age of a status to notify on

func (*GoTimeStatus) Poll

func (gt *GoTimeStatus) Poll(ctx context.Context) error

Poll conditionally calls notify if there is a status update from @gotime@changelog.social

For a status to be posted, it needs to be younger than the maxStatusAge this prevents very old statuses from being notified and acts as a safeguard if the last status ID could not be persisted to state storage, and prevents reposts if we lose the last status ID.

type NotifyFunc

type NotifyFunc func(ctx context.Context, statusURL string) error

NotifyFunc represents the function signature the poller notifies on a new social status. If error is not nil, the item will be retried at some point in the future.

type Store

type Store interface {
	Get(ctx context.Context) (id string, notFound bool, err error)
	Put(ctx context.Context, lastID string) error
}

Store represents the shape of the storage system.

Jump to

Keyboard shortcuts

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