persist

package
v0.0.0-...-45fe538 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CleanupInterval time.Duration = time.Hour

The interval to clean expired webhook urls.

View Source
var ExpiryDuration time.Duration = time.Hour * 24 * 30

The expiry duration is the time until a non-refreshed webhook url expires. Currently set to 30 days.

Functions

This section is empty.

Types

type CleanupService

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

func NewCleanupService

func NewCleanupService(store Store) *CleanupService

func (*CleanupService) Start

func (c *CleanupService) Start(ctx context.Context)

Periodically cleans up expired webhook urls.

type MemoryStore

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

func (*MemoryStore) DeleteExpired

func (m *MemoryStore) DeleteExpired(ctx context.Context, before time.Time) error

func (*MemoryStore) GetLastUpdated

func (m *MemoryStore) GetLastUpdated(ctx context.Context, identifier string) (*Webhook, error)

func (*MemoryStore) Remove

func (m *MemoryStore) Remove(ctx context.Context, pubkey, url string) error

func (*MemoryStore) Set

func (m *MemoryStore) Set(ctx context.Context, webhook Webhook) (*Webhook, error)

type PgStore

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

func NewPgStore

func NewPgStore(databaseUrl string) (*PgStore, error)

func (*PgStore) DeleteExpired

func (s *PgStore) DeleteExpired(
	ctx context.Context,
	before time.Time,
) error

func (*PgStore) GetLastUpdated

func (s *PgStore) GetLastUpdated(ctx context.Context, identifier string) (*Webhook, error)

func (*PgStore) Remove

func (s *PgStore) Remove(ctx context.Context, pubkey, url string) error

func (*PgStore) Set

func (s *PgStore) Set(ctx context.Context, webhook Webhook) (*Webhook, error)

type PubkeyUsername

type PubkeyUsername struct {
	Pubkey   string `json:"pubkey" db:"pubkey"`
	Username string `json:"username" db:"username"`
}

type Store

type Store interface {
	Set(ctx context.Context, webhook Webhook) (*Webhook, error)
	GetLastUpdated(ctx context.Context, identifier string) (*Webhook, error)
	Remove(ctx context.Context, pubkey, url string) error
	DeleteExpired(ctx context.Context, before time.Time) error
}

type Webhook

type Webhook struct {
	Pubkey   string  `json:"pubkey" db:"pubkey"`
	Username *string `json:"username" db:"username"`
	Url      string  `json:"url" db:"url"`
}

func (Webhook) Compare

func (w Webhook) Compare(identifier string) bool

Jump to

Keyboard shortcuts

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