sqlstore

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 18 Imported by: 1

Documentation

Overview

Package sqlstore contains SQL-backed persistence adapters for core stores. Cached rate-limit state keys use RateLimitStateCacheKey.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RateLimitStateCacheKey

func RateLimitStateCacheKey(key core.RateLimitKey) (string, error)

RateLimitStateCacheKey returns the deterministic cache key contract for rate-limit state reads: go-services::ratelimit_state::v1::<provider>::<scope_type>::<scope_id>::<bucket_key> with each segment URL-path escaped after key normalization.

func RedactMetadata

func RedactMetadata(metadata map[string]any) map[string]any

Types

type ActivityStore

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

func NewActivityStore

func NewActivityStore(db *bun.DB) (*ActivityStore, error)

func (*ActivityStore) List

func (*ActivityStore) Prune

func (*ActivityStore) Record

type AppendServiceEventInput

type AppendServiceEventInput struct {
	ConnectionID string
	ProviderID   string
	ScopeType    string
	ScopeID      string
	EventType    string
	Status       string
	Error        string
	Metadata     map[string]any
}

type CachedRateLimitStateStore

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

func NewCachedRateLimitStateStore

func NewCachedRateLimitStateStore(
	base ratelimit.StateStore,
	cacheService repositorycache.CacheService,
) (*CachedRateLimitStateStore, error)

func (*CachedRateLimitStateStore) Get

func (*CachedRateLimitStateStore) Upsert

type ConnectionStore

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

func (*ConnectionStore) Create

func (*ConnectionStore) FindByScope

func (s *ConnectionStore) FindByScope(ctx context.Context, providerID string, scope core.ScopeRef) ([]core.Connection, error)

func (*ConnectionStore) FindByScopeAndExternalAccount added in v0.2.0

func (s *ConnectionStore) FindByScopeAndExternalAccount(
	ctx context.Context,
	providerID string,
	scope core.ScopeRef,
	externalAccountID string,
) (core.Connection, bool, error)

func (*ConnectionStore) Get

func (*ConnectionStore) UpdateStatus

func (s *ConnectionStore) UpdateStatus(
	ctx context.Context,
	id string,
	status core.ConnectionStatus,
	reason string,
) error

type CredentialStore

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

func (*CredentialStore) GetActiveByConnection

func (s *CredentialStore) GetActiveByConnection(ctx context.Context, connectionID string) (core.Credential, error)

func (*CredentialStore) RevokeActive

func (s *CredentialStore) RevokeActive(ctx context.Context, connectionID string, reason string) error

func (*CredentialStore) SaveNewVersion

type GrantStore

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

func NewGrantStore

func NewGrantStore(db *bun.DB) (*GrantStore, error)

func (*GrantStore) AppendEvent

func (s *GrantStore) AppendEvent(ctx context.Context, in core.AppendGrantEventInput) error

func (*GrantStore) GetLatestSnapshot

func (s *GrantStore) GetLatestSnapshot(ctx context.Context, connectionID string) (core.GrantSnapshot, bool, error)

func (*GrantStore) SaveSnapshot

func (s *GrantStore) SaveSnapshot(ctx context.Context, in core.SaveGrantSnapshotInput) error

func (*GrantStore) SaveSnapshotAndEvent

func (s *GrantStore) SaveSnapshotAndEvent(
	ctx context.Context,
	snapshot core.SaveGrantSnapshotInput,
	event *core.AppendGrantEventInput,
) error

type InstallationStore

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

func NewInstallationStore

func NewInstallationStore(db *bun.DB) (*InstallationStore, error)

func (*InstallationStore) Get

func (*InstallationStore) ListByScope

func (s *InstallationStore) ListByScope(
	ctx context.Context,
	providerID string,
	scope core.ScopeRef,
) ([]core.Installation, error)

func (*InstallationStore) UpdateStatus

func (s *InstallationStore) UpdateStatus(
	ctx context.Context,
	id string,
	status core.InstallationStatus,
	reason string,
) error

func (*InstallationStore) Upsert

type NotificationDispatchStore

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

func NewNotificationDispatchStore

func NewNotificationDispatchStore(db *bun.DB) (*NotificationDispatchStore, error)

func (*NotificationDispatchStore) Record

func (*NotificationDispatchStore) Seen

func (s *NotificationDispatchStore) Seen(ctx context.Context, idempotencyKey string) (bool, error)

type OutboxStore

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

func NewOutboxStore

func NewOutboxStore(db *bun.DB) (*OutboxStore, error)

func (*OutboxStore) Ack

func (s *OutboxStore) Ack(ctx context.Context, eventID string) error

func (*OutboxStore) ClaimBatch

func (s *OutboxStore) ClaimBatch(ctx context.Context, limit int) ([]core.LifecycleEvent, error)

func (*OutboxStore) Enqueue

func (s *OutboxStore) Enqueue(ctx context.Context, event core.LifecycleEvent) error

func (*OutboxStore) Retry

func (s *OutboxStore) Retry(ctx context.Context, eventID string, cause error, nextAttemptAt time.Time) error

type RateLimitStateStore

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

func NewRateLimitStateStore

func NewRateLimitStateStore(db *bun.DB) (*RateLimitStateStore, error)

func (*RateLimitStateStore) Get

func (*RateLimitStateStore) Upsert

func (s *RateLimitStateStore) Upsert(ctx context.Context, state ratelimit.State) error

type RepositoryFactory

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

func NewRepositoryFactory

func NewRepositoryFactory(opts ...RepositoryFactoryOption) *RepositoryFactory

func NewRepositoryFactoryFromDB

func NewRepositoryFactoryFromDB(db *bun.DB) (*RepositoryFactory, error)

func NewRepositoryFactoryFromPersistence

func NewRepositoryFactoryFromPersistence(client *persistence.Client) (*RepositoryFactory, error)

func (*RepositoryFactory) ActivityStore

func (f *RepositoryFactory) ActivityStore() *ActivityStore

func (*RepositoryFactory) BuildStores

func (f *RepositoryFactory) BuildStores(persistenceClient any) (core.StoreProvider, error)

func (*RepositoryFactory) ConnectionStore

func (f *RepositoryFactory) ConnectionStore() core.ConnectionStore

func (*RepositoryFactory) CredentialStore

func (f *RepositoryFactory) CredentialStore() core.CredentialStore

func (*RepositoryFactory) DB

func (f *RepositoryFactory) DB() *bun.DB

func (*RepositoryFactory) InstallationStore

func (f *RepositoryFactory) InstallationStore() core.InstallationStore

func (*RepositoryFactory) NotificationDispatchStore

func (f *RepositoryFactory) NotificationDispatchStore() *NotificationDispatchStore

func (*RepositoryFactory) OutboxStore

func (f *RepositoryFactory) OutboxStore() *OutboxStore

func (*RepositoryFactory) RateLimitPolicy

func (f *RepositoryFactory) RateLimitPolicy() core.RateLimitPolicy

func (*RepositoryFactory) RateLimitStateStore

func (f *RepositoryFactory) RateLimitStateStore() *RateLimitStateStore

func (*RepositoryFactory) SubscriptionStore

func (f *RepositoryFactory) SubscriptionStore() core.SubscriptionStore

func (*RepositoryFactory) SyncCursorStore

func (f *RepositoryFactory) SyncCursorStore() core.SyncCursorStore

func (*RepositoryFactory) SyncJobStore

func (f *RepositoryFactory) SyncJobStore() *SyncJobStore

func (*RepositoryFactory) SyncJobStoreCore added in v0.2.0

func (f *RepositoryFactory) SyncJobStoreCore() core.SyncJobStore

type RepositoryFactoryOption

type RepositoryFactoryOption func(*RepositoryFactory)

func WithRateLimitStateCache

func WithRateLimitStateCache(cacheService repositorycache.CacheService) RepositoryFactoryOption

type ServiceEventStore

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

func NewServiceEventStore

func NewServiceEventStore(db *bun.DB) (*ServiceEventStore, error)

func (*ServiceEventStore) Append

type SubscriptionStore

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

func NewSubscriptionStore

func NewSubscriptionStore(db *bun.DB) (*SubscriptionStore, error)

func (*SubscriptionStore) Get

func (*SubscriptionStore) GetByChannelID

func (s *SubscriptionStore) GetByChannelID(ctx context.Context, providerID, channelID string) (core.Subscription, error)

func (*SubscriptionStore) ListExpiring

func (s *SubscriptionStore) ListExpiring(ctx context.Context, before time.Time) ([]core.Subscription, error)

func (*SubscriptionStore) UpdateState

func (s *SubscriptionStore) UpdateState(
	ctx context.Context,
	id string,
	status core.SubscriptionStatus,
	reason string,
) error

func (*SubscriptionStore) Upsert

type SyncCursorStore

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

func NewSyncCursorStore

func NewSyncCursorStore(db *bun.DB) (*SyncCursorStore, error)

func (*SyncCursorStore) Advance

func (*SyncCursorStore) Get

func (s *SyncCursorStore) Get(
	ctx context.Context,
	connectionID string,
	resourceType string,
	resourceID string,
) (core.SyncCursor, error)

func (*SyncCursorStore) Upsert

type SyncJobStore

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

func NewSyncJobStore

func NewSyncJobStore(db *bun.DB) (*SyncJobStore, error)

func (*SyncJobStore) Create

func (s *SyncJobStore) Create(ctx context.Context, job core.SyncJob) (core.SyncJob, error)

func (*SyncJobStore) CreateSyncJob added in v0.2.0

func (*SyncJobStore) Get

func (s *SyncJobStore) Get(ctx context.Context, id string) (core.SyncJob, error)

func (*SyncJobStore) GetSyncJob added in v0.2.0

func (s *SyncJobStore) GetSyncJob(ctx context.Context, id string) (core.SyncJob, error)

func (*SyncJobStore) Update

func (s *SyncJobStore) Update(ctx context.Context, job core.SyncJob) (core.SyncJob, error)

type WebhookDeliveryStore

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

func NewWebhookDeliveryStore

func NewWebhookDeliveryStore(db *bun.DB) (*WebhookDeliveryStore, error)

func (*WebhookDeliveryStore) Claim

func (s *WebhookDeliveryStore) Claim(
	ctx context.Context,
	providerID string,
	deliveryID string,
	payload []byte,
	lease time.Duration,
) (webhooks.DeliveryRecord, bool, error)

func (*WebhookDeliveryStore) Complete

func (s *WebhookDeliveryStore) Complete(ctx context.Context, claimID string) error

func (*WebhookDeliveryStore) Fail

func (s *WebhookDeliveryStore) Fail(
	ctx context.Context,
	claimID string,
	_ error,
	nextAttemptAt time.Time,
	maxAttempts int,
) error

func (*WebhookDeliveryStore) Get

func (s *WebhookDeliveryStore) Get(
	ctx context.Context,
	providerID string,
	deliveryID string,
) (webhooks.DeliveryRecord, error)

Jump to

Keyboard shortcuts

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