theorydb

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: AGPL-3.0 Imports: 30 Imported by: 0

README

DynamORM Integration

This package implements the DynamoDB access layer using the DynamORM library. It provides a type-safe, efficient way to interact with DynamoDB tables.

Structure

  • base_model.go: Contains standard model structs with common fields and key generation utilities
  • client.go: Handles DynamoDB client initialization and optimization for Lambda functions
  • lambda_init.go: Provides helpers for Lambda function initialization
  • errors.go: Maps DynamORM errors to storage errors with detailed context
  • adapter.go: Provides backward compatibility with the existing storage interface
  • repository_adapter.go: Implements generic repository adapters for common patterns
  • model.go: Sample model implementation (template for specific models)

Usage

Lambda Initialization

For Lambda functions, initialize the client in the init() function using the Lambda-optimized client:

var db core.DB

func init() {
    var err error
    // Initialize with models to pre-register
    db, err = dynamorm.LambdaInit(&User{}, &Actor{}, &Status{})
    if err != nil {
        panic(err)
    }
}
Model Definition

Define models by embedding the StandardModel struct:

type User struct {
    // Embed StandardModel for PK, SK, CreatedAt, UpdatedAt
    dynamorm.StandardModel
    
    // Business ID
    ID        string    `json:"id"`                         // User ID
    
    // GSI attributes
    Email     string    `dynamorm:"index:email-index,pk" json:"email"`
    
    // Business attributes
    Name      string    `json:"name"`
    Username  string    `json:"username"`
    Active    bool      `json:"active"`
}

// SetKeys implements the KeySetter interface
func (u *User) SetKeys() {
    if u.PK == "" || u.SK == "" {
        u.PK, u.SK = dynamorm.GenerateSimpleKeys("user", u.ID)
    }
}

For multi-tenant models, embed the TenantModel:

type TenantResource struct {
    // Embed TenantModel for PK, SK, CreatedAt, UpdatedAt, TenantID
    dynamorm.TenantModel
    
    // Business ID
    ID          string `json:"id"`
    
    // Business attributes
    Name        string `json:"name"`
    Description string `json:"description"`
}

// SetKeys implements the KeySetter interface
func (r *TenantResource) SetKeys() {
    if r.PK == "" || r.SK == "" {
        r.PK, r.SK = dynamorm.GenerateTenantKeys(r.TenantID, "resource", r.ID)
    }
}

For models with TTL, embed the TTLModel:

type Session struct {
    // Embed TTLModel for PK, SK, CreatedAt, UpdatedAt, TTL
    dynamorm.TTLModel
    
    // Business ID
    UserID     string `json:"user_id"`
    SessionID  string `json:"session_id"`
    
    // Business attributes
    IP         string `json:"ip"`
    UserAgent  string `json:"user_agent"`
}

// SetKeys implements the KeySetter interface
func (s *Session) SetKeys() {
    if s.PK == "" || s.SK == "" {
        s.PK, s.SK = dynamorm.GenerateHierarchicalKeys("user", s.UserID, "session", s.SessionID)
    }
    
    // Set TTL to expire in 24 hours
    s.SetTTL(24 * time.Hour)
}
Repository Implementation

Implement repositories for each model:

type UserRepository struct {
    BaseRepository
}

func NewUserRepository(db core.DB, tableName string) *UserRepository {
    return &UserRepository{
        BaseRepository: *NewBaseRepository(db, tableName),
    }
}

func (r *UserRepository) GetUser(ctx context.Context, id string) (*User, error) {
    user := &User{ID: id}
    user.SetKeys()
    
    err := r.GetDB().Model(user).
        Where("PK", "=", user.PK).
        Where("SK", "=", user.SK).
        First(user)
        
    if err != nil {
        return nil, MapRepositoryError(err, "GetUser", "User", id)
    }
    
    return user, nil
}
Generic Repository Usage

For simple CRUD operations, use the GenericRepository:

// Create a generic repository for users
userRepo := dynamorm.NewGenericRepository(db, tableName, "user")

// Create a user
user := &User{ID: "123", Name: "John Doe"}
user.SetKeys()
err := userRepo.Create(ctx, user)

// Get a user
user = &User{}
err = userRepo.Get(ctx, "123", user)

// Update a user
user.Name = "Jane Doe"
err = userRepo.Update(ctx, user)

// Delete a user
err = userRepo.Delete(ctx, "123", &User{})

// List users
var users []*User
err = userRepo.List(ctx, map[string]any{
    "Active": true,
}, &users)
Adapter Usage

Use the adapter to maintain backward compatibility:

// Create the original storage implementation
originalStorage := dynamodb.New(...)

// Create the DynamORM client
db, err := dynamorm.GetLambdaClient(context.Background())
if err != nil {
    panic(err)
}

// Create the adapter
adapter := dynamorm.NewStorageAdapter(db, tableName, logger)

// Use the adapter as a storage.Storage implementation
user, err := adapter.GetUser(ctx, "username")
Error Handling

Use the error mapping functions to handle errors:

user, err := userRepo.GetUser(ctx, id)
if err != nil {
    if dynamorm.IsNotFound(err) {
        // Handle not found error
        return nil, fmt.Errorf("user not found: %s", id)
    }
    
    // Handle other errors
    return nil, fmt.Errorf("failed to get user: %w", err)
}

Migration Strategy

  1. Implement models and repositories for core entities
  2. Use the adapter to maintain backward compatibility
  3. Gradually migrate methods from the original storage implementation to DynamORM
  4. Once all methods are migrated, remove the adapter and use DynamORM directly

Best Practices

  1. Use the StandardModel: Embed StandardModel in all your models to get standard fields and hooks
  2. Implement KeySetter: Implement the KeySetter interface to automatically set keys
  3. Use Lambda-optimized client: Use LambdaInit in Lambda functions to optimize performance
  4. Use error mapping: Use MapRepositoryError to provide detailed error context
  5. Use generic repositories: Use GenericRepository for simple CRUD operations
  6. Use adapters: Use adapters to maintain backward compatibility during migration

Documentation

Overview

Package theorydb provides repository interfaces and implementations backed by the TheoryDB adapter layer.

Package theorydb provides the critical StorageAdapter bridge that connects the comprehensive storage interface to repository implementations. This adapter is the architectural keystone that enables the Lesser application to work during the DynamORM migration while maintaining compatibility with all existing storage operations.

CRITICAL PATTERNS PRESERVED: - Users: PK=`USER#username`, SK=`PROFILE` - Actors: PK=`ACTOR#username`, SK=`PROFILE` - Objects: PK=`object#id`, SK=`object#id` - DNS Cache: PK=`DNSCACHE#hostname`, SK=`ENTRY` - All existing GSI patterns and TTL logic

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConditionalCheckFailed is returned when a conditional write fails
	ErrConditionalCheckFailed = errors.DynamoDBConditionalCheckFailed("")

	// ErrThrottling is returned when DynamoDB throttles the request
	ErrThrottling = errors.DynamoDBProvisionedThroughputExceeded()

	// ErrResourceNotFound is returned when a DynamoDB resource is not found
	ErrResourceNotFound = errors.DatabaseUnavailable(stdErrors.New("database resource not found"))

	// ErrInternal is returned for internal errors
	ErrInternal = errors.NewStorageError(errors.CodeInternal, "internal error")

	// ErrInvalidKey is returned when a key is invalid
	ErrInvalidKey = errors.InvalidFormat("key", "valid key format")

	// ErrBatchOperationFailed is returned when a batch operation fails
	ErrBatchOperationFailed = errors.BatchOperationFailed("batch operation", stdErrors.New("batch operation failed"))

	// ErrTransactionCanceled is returned when a transaction is canceled
	ErrTransactionCanceled = errors.TransactionFailed(stdErrors.New("transaction was canceled"))

	// ErrValidation is returned when validation fails
	ErrValidation = errors.NewValidationError("", "validation failed")
)

Legacy error variables for backward compatibility - using centralized error system

Functions

func ExampleCreateUserWithPosts

func ExampleCreateUserWithPosts(ctx context.Context) error

ExampleCreateUserWithPosts demonstrates how to use transactions to create a user and their posts atomically

func ExampleTransferBalance

func ExampleTransferBalance(ctx context.Context, fromAccountID, toAccountID string, amount float64) error

ExampleTransferBalance demonstrates how to use transactions for a balance transfer between accounts

func ExecuteLambdaTransaction

func ExecuteLambdaTransaction(ctx context.Context, fn TransactionFunc) error

ExecuteLambdaTransaction is a helper function to execute a transaction with the Lambda-optimized client

func ExecuteSimpleTransaction

func ExecuteSimpleTransaction(ctx context.Context, client core.DB, operations ...TransactionOperation) error

ExecuteSimpleTransaction executes a simple transaction with default settings

func ExecuteTransaction

func ExecuteTransaction(ctx context.Context, fn TransactionFunc) error

ExecuteTransaction is a helper function to execute a transaction with the default client

func ExecuteTransactionWithCostTracking

func ExecuteTransactionWithCostTracking(ctx context.Context, client core.DB, logger *zap.Logger, tracker *cost.Tracker, operations ...TransactionOperation) error

ExecuteTransactionWithCostTracking executes a transaction with cost tracking

func ExecuteTransactionWithLogger

func ExecuteTransactionWithLogger(ctx context.Context, client core.DB, logger *zap.Logger, operations ...TransactionOperation) error

ExecuteTransactionWithLogger executes a transaction with logging

func ExtractIDFromKey

func ExtractIDFromKey(key, prefix string) string

ExtractIDFromKey extracts the ID portion from a composite key For example, "user#123" would return "123"

func GenerateHierarchicalKeys

func GenerateHierarchicalKeys(parentType, parentID, childType, childID string) (string, string)

GenerateHierarchicalKeys generates PK and SK values for hierarchical data For example, a user's posts would have PK=user#{user_id} and SK=post#{post_id}

func GenerateKeys

func GenerateKeys(components KeyComponents) (string, string)

GenerateKeys generates standard PK and SK values based on the provided components

func GenerateSimpleKeys

func GenerateSimpleKeys(entityType, id string) (string, string)

GenerateSimpleKeys generates simple PK and SK values for a single entity

func GenerateTenantKeys

func GenerateTenantKeys(tenantID, entityType, id string) (string, string)

GenerateTenantKeys generates PK and SK values for tenant-isolated entities

func GetClient

func GetClient(_ context.Context) (core.DB, error)

GetClient returns a singleton DynamORM client instance This ensures that the client is only initialized once per Lambda container

func GetInitMetrics

func GetInitMetrics() (coldStartTime time.Duration, modelCount int, connectionCount int)

GetInitMetrics returns initialization performance metrics

func GetLambdaClient

func GetLambdaClient(ctx context.Context) (*tabletheory.LambdaDB, error)

GetLambdaClient returns a singleton DynamORM Lambda-optimized client instance This ensures that the client is only initialized once per Lambda container and includes Lambda-specific optimizations like timeout handling

func InitializeModels

func InitializeModels(models ...any) error

InitializeModels pre-registers models with the DynamORM client to reduce cold start time This should be called in the init() function of Lambda handlers

func IsConditionalCheckFailed

func IsConditionalCheckFailed(err error) bool

IsConditionalCheckFailed checks if an error is a conditional check failed error using centralized error system

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error is a not found error using centralized error system

func IsThrottling

func IsThrottling(err error) bool

IsThrottling checks if an error is a throttling error using centralized error system

func IsTransactionCanceled

func IsTransactionCanceled(err error) bool

IsTransactionCanceled checks if an error is a transaction canceled error using centralized error system

func IsValidation

func IsValidation(err error) bool

IsValidation checks if an error is a validation error using centralized error system

func LambdaInit

func LambdaInit(models ...any) (core.DB, error)

LambdaInit is a helper function to initialize DynamORM in Lambda functions It creates a Lambda-optimized client and pre-registers the provided models This should be called in the init() function of Lambda handlers

func LambdaInitWithOptions

func LambdaInitWithOptions(opts *LambdaInitOptions) (core.DB, error)

LambdaInitWithOptions initializes DynamORM with advanced performance options

func MapError

func MapError(err error) error

MapError maps DynamORM errors to storage errors using centralized error system

func MapErrorWithContext

func MapErrorWithContext(err error, context string) error

MapErrorWithContext maps DynamORM errors to storage errors with additional context using centralized error system

func MapRepositoryError

func MapRepositoryError(err error, operation, entityType, entityID string) error

MapRepositoryError maps repository errors with context using centralized error system

func NewDetailedError

func NewDetailedError(err error, operation, entityType, entityID, context string) error

NewDetailedError creates a new DetailedError using centralized error system

func NewLambdaOptimizedClient

func NewLambdaOptimizedClient(_ context.Context, region string) (core.DB, error)

NewLambdaOptimizedClient creates a new DynamORM client optimized for Lambda functions This should be used in the init() function of Lambda handlers to ensure connection reuse

func PreRegisterModels

func PreRegisterModels(_ core.DB, _ ...any) error

PreRegisterModels pre-registers models with the DynamORM client to reduce cold start time Note: The latest version of DynamORM doesn't have a PreRegisterModels method This is a placeholder for compatibility

func WithTimeoutBuffer

func WithTimeoutBuffer(db core.DB, buffer time.Duration) core.DB

WithTimeoutBuffer returns a new client with the specified timeout buffer

Types

type AccountRepository

type AccountRepository interface {
	// ===== Core Account Operations =====
	CreateAccount(ctx context.Context, username, email, passwordHash string, approved bool, actor *activitypub.Actor, privateKey string) error
	GetAccount(ctx context.Context, username string) (*storage.Account, error)
	DeleteAccount(ctx context.Context, username string) error

	// ===== User Operations (Authentication) =====
	GetUser(ctx context.Context, username string) (*storage.User, error)
	GetUserByEmail(ctx context.Context, email string) (*storage.User, error)
	UpdateUser(ctx context.Context, username string, updates map[string]interface{}) error

	// ===== Actor Operations (ActivityPub) =====
	GetActor(ctx context.Context, username string) (*activitypub.Actor, error)
	GetActorByUsername(ctx context.Context, username string) (*activitypub.Actor, error)
	GetActorPrivateKey(ctx context.Context, username string) (string, error)

	// ===== Authentication Methods =====
	ValidatePassword(ctx context.Context, username, password string) (*storage.User, error)
	GetRecentLoginAttempts(ctx context.Context, username string, since time.Time) ([]*storage.LoginAttempt, error)
	CreatePasswordResetToken(ctx context.Context, username, email string) (string, error)
	ValidatePasswordResetToken(ctx context.Context, token string) (*storage.PasswordReset, error)
	ResetPassword(ctx context.Context, token, newPasswordHash string) error
	GetUserSessions(ctx context.Context, username string) ([]*storage.Session, error)
	CreateSession(ctx context.Context, username, ipAddress, userAgent string) (*storage.Session, error)
	InvalidateSession(ctx context.Context, username, sessionID string) error
	InvalidateAllSessions(ctx context.Context, username string) error
	UpdateLastLogin(ctx context.Context, username string) error
	GetUserByRecoveryCode(ctx context.Context, recoveryCode string) (*storage.User, error)

	// ===== Social Features =====
	Follow(ctx context.Context, followerUsername, followeeUsername string) error
	Unfollow(ctx context.Context, followerUsername, followeeUsername string) error
	IsFollowing(ctx context.Context, followerUsername, followeeUsername string) (bool, error)
	GetFollowers(ctx context.Context, username string, limit int, cursor string) ([]*activitypub.Actor, string, error)
	GetFollowing(ctx context.Context, username string, limit int, cursor string) ([]*activitypub.Actor, string, error)
	Block(ctx context.Context, blockerUsername, blockedUsername string) error
	Unblock(ctx context.Context, blockerUsername, blockedUsername string) error
	IsBlocked(ctx context.Context, blockerUsername, blockedUsername string) (bool, error)
	GetBlocks(ctx context.Context, username string) ([]*storage.Block, error)
	Mute(ctx context.Context, muterUsername, mutedUsername string, notifications bool, duration time.Duration) error
	Unmute(ctx context.Context, muterUsername, mutedUsername string) error
	IsMuted(ctx context.Context, muterUsername, mutedUsername string) (bool, bool, error)
	GetMutes(ctx context.Context, username string) ([]*storage.Mute, error)
	AddBookmark(ctx context.Context, username, objectID string) error
	RemoveBookmark(ctx context.Context, username, objectID string) error
	GetBookmarks(ctx context.Context, username string, limit int, cursor string) ([]*storage.Bookmark, string, error)
	PinAccount(ctx context.Context, username, pinnedUsername string) error
	UnpinAccount(ctx context.Context, username, pinnedUsername string) error
	GetPinnedAccounts(ctx context.Context, username string) ([]*activitypub.Actor, error)

	// ===== Timeline Operations =====
	GetHomeTimeline(ctx context.Context, username string, limit int, maxID, sinceID string) ([]*storage.TimelineEntry, error)
	GetLocalTimeline(ctx context.Context, limit int, maxID, sinceID string) ([]*storage.TimelineEntry, error)
	GetPublicTimeline(ctx context.Context, limit int, maxID, sinceID string, onlyMedia bool) ([]*storage.TimelineEntry, error)
	GetHashtagTimeline(ctx context.Context, hashtag string, limit int, maxID, sinceID string) ([]*storage.TimelineEntry, error)
	GetListTimeline(ctx context.Context, username, listID string, limit int, maxID, sinceID string) ([]*storage.TimelineEntry, error)
	AddToTimeline(ctx context.Context, username string, entry *storage.TimelineEntry) error
	RemoveFromTimeline(ctx context.Context, username, objectID string) error
	GetConversations(ctx context.Context, username string, limit int, maxID, sinceID string) ([]*storage.Conversation, error)
	MuteConversation(ctx context.Context, username, conversationID string) error
	UnmuteConversation(ctx context.Context, username, conversationID string) error
	IsConversationMuted(ctx context.Context, username, conversationID string) (bool, error)
	GetTimelineMarkers(ctx context.Context, username string, timelines []string) (map[string]*storage.Marker, error)
	UpdateTimelineMarker(ctx context.Context, username, timeline, lastReadID string) error

	// ===== Search and Discovery =====
	SearchActors(ctx context.Context, query string, limit int, offset int, following bool, username string) ([]*activitypub.Actor, error)
	GetAccountSuggestions(ctx context.Context, username string, limit int) ([]*storage.AccountSuggestion, error)
	GetTrendingActors(ctx context.Context, limit int) ([]*activitypub.Actor, error)
	SearchByWebfinger(ctx context.Context, webfinger string) (*activitypub.Actor, error)
	CacheRemoteActor(ctx context.Context, actor *activitypub.Actor) error
	UpdateLastSeen(ctx context.Context, username string) error
	GetActiveUsers(ctx context.Context, since time.Time, limit int) ([]*storage.User, error)
	GetInactiveUsers(ctx context.Context, inactiveSince time.Time, limit int) ([]*storage.User, error)

	// ===== OAuth 2.0 Operations =====
	CreateAuthorizationCode(ctx context.Context, code *storage.AuthorizationCode) error
	GetAuthorizationCode(ctx context.Context, code string) (*storage.AuthorizationCode, error)
	DeleteAuthorizationCode(ctx context.Context, code string) error
	CreateRefreshToken(ctx context.Context, token *storage.RefreshToken) error
	GetRefreshToken(ctx context.Context, token string) (*storage.RefreshToken, error)
	DeleteRefreshToken(ctx context.Context, token string) error
	CreateOAuthClient(ctx context.Context, client *storage.OAuthClient) error
	GetOAuthClient(ctx context.Context, clientID string) (*storage.OAuthClient, error)
	DeleteOAuthClient(ctx context.Context, clientID string) error
	StoreOAuthState(ctx context.Context, state string, data *storage.OAuthState) error
	GetOAuthState(ctx context.Context, state string) (*storage.OAuthState, error)
	DeleteOAuthState(ctx context.Context, state string) error
	UpdateOAuthClient(ctx context.Context, clientID string, updates map[string]interface{}) error
	ListOAuthClients(ctx context.Context, limit int, cursor string) ([]*storage.OAuthClient, string, error)
	GetOAuthApp(ctx context.Context, clientID string) (*storage.OAuthApp, error)
	SaveUserAppConsent(ctx context.Context, consent *storage.UserAppConsent) error
	GetUserAppConsent(ctx context.Context, userID, appID string) (*storage.UserAppConsent, error)

	// ===== WebAuthn Operations =====
	CreateWebAuthnCredential(ctx context.Context, credential *storage.WebAuthnCredential) error
	GetWebAuthnCredential(ctx context.Context, credentialID string) (*storage.WebAuthnCredential, error)
	GetUserWebAuthnCredentials(ctx context.Context, username string) ([]*storage.WebAuthnCredential, error)
	UpdateWebAuthnLastUsed(ctx context.Context, credentialID string, signCount uint32) error
	DeleteWebAuthnCredential(ctx context.Context, credentialID string) error
	CreateWebAuthnChallenge(ctx context.Context, challenge *storage.WebAuthnChallenge) error
	GetWebAuthnChallenge(ctx context.Context, challengeID string) (*storage.WebAuthnChallenge, error)
	DeleteWebAuthnChallenge(ctx context.Context, challengeID string) error

	// ===== Wallet Operations =====
	StoreWalletChallenge(ctx context.Context, challenge *storage.WalletChallenge) error
	GetWalletChallenge(ctx context.Context, challengeID string) (*storage.WalletChallenge, error)
	StoreWalletCredential(ctx context.Context, credential *storage.WalletCredential) error
	GetWalletByAddress(ctx context.Context, walletType, address string) (*storage.WalletCredential, error)
	DeleteWalletChallenge(ctx context.Context, challengeID string) error
	GetUserWallets(ctx context.Context, username string) ([]*storage.WalletCredential, error)
	DeleteWalletCredential(ctx context.Context, username, address string) error

	// Set storage for operations not yet migrated
	SetStorage(storage interface{})
}

AccountRepository unifies User and Actor operations

type BaseModel

type BaseModel struct {
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

BaseModel provides common fields for all DynamORM models

func (*BaseModel) BeforeCreate

func (m *BaseModel) BeforeCreate() error

BeforeCreate is a hook that sets CreatedAt and UpdatedAt before creating a record

func (*BaseModel) BeforeUpdate

func (m *BaseModel) BeforeUpdate() error

BeforeUpdate is a hook that updates the UpdatedAt timestamp before updating a record

type BaseRepository

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

BaseRepository provides common functionality for all repositories

func NewBaseRepository

func NewBaseRepository(db core.DB, tableName string) *BaseRepository

NewBaseRepository creates a new BaseRepository

func (*BaseRepository) GetDB

func (r *BaseRepository) GetDB() core.DB

GetDB returns the DynamORM client

func (*BaseRepository) GetTableName

func (r *BaseRepository) GetTableName() string

GetTableName returns the name of the DynamoDB table

type DetailedError

type DetailedError struct {
	// Original error
	Err error

	// Operation that caused the error
	Operation string

	// Entity type that was being operated on
	EntityType string

	// Entity ID that was being operated on
	EntityID string

	// Additional context
	Context string
}

DetailedError provides detailed error information

func (*DetailedError) Error

func (e *DetailedError) Error() string

Error implements the error interface

func (*DetailedError) Unwrap

func (e *DetailedError) Unwrap() error

Unwrap returns the original error

type ExamplePost

type ExamplePost struct {
	StandardModel
	UserID  string `json:"user_id"`
	Title   string `json:"title"`
	Content string `json:"content"`
}

ExamplePost is a simple post model for examples

type ExampleUser

type ExampleUser struct {
	StandardModel
	Name  string `json:"name"`
	Email string `json:"email"`
}

ExampleUser is a simple user model for examples

type GenericRepository

type GenericRepository struct {
	DB         core.DB
	TableName  string
	EntityType string
	// contains filtered or unexported fields
}

GenericRepository provides a generic repository implementation that can be used to adapt DynamORM to existing repository interfaces

func NewGenericRepository

func NewGenericRepository(db core.DB, tableName, entityType string) *GenericRepository

NewGenericRepository creates a new GenericRepository

func (*GenericRepository) BatchGet

func (r *GenericRepository) BatchGet(ctx context.Context, ids []string, entities any) error

BatchGet retrieves multiple entities by their IDs

func (*GenericRepository) Create

func (r *GenericRepository) Create(_ context.Context, entity any) error

Create creates a new entity

func (*GenericRepository) Delete

func (r *GenericRepository) Delete(_ context.Context, id string, entityPtr any) error

Delete deletes an entity by ID

func (*GenericRepository) Get

func (r *GenericRepository) Get(_ context.Context, id string, entity any) error

Get retrieves an entity by ID

func (*GenericRepository) List

func (r *GenericRepository) List(_ context.Context, filter map[string]any, entities any) error

List lists entities with optional filtering

func (*GenericRepository) Update

func (r *GenericRepository) Update(_ context.Context, entity any) error

Update updates an entity

func (*GenericRepository) WithTransaction

func (r *GenericRepository) WithTransaction(tx *Transaction) *GenericRepository

WithTransaction returns a new repository that uses the provided transaction

type KeyComponents

type KeyComponents struct {
	EntityType string
	ID         string
	Tenant     string
	Sort       string
}

KeyComponents defines the components of a composite key

type KeySetter

type KeySetter interface {
	SetKeys()
}

KeySetter is an interface for entities that can set their own keys

type LambdaInitOptions

type LambdaInitOptions struct {
	// Models to pre-register during initialization
	Models []any

	// EnableCostTracking wraps the DB client with cost tracking
	EnableCostTracking bool

	// Logger for cost tracking and debugging
	Logger *zap.Logger

	// RequestID for cost tracking context
	RequestID string

	// OperationType for cost tracking context
	OperationType string

	// PrewarmConnections creates and validates connections during init
	PrewarmConnections bool

	// ConnectionCount number of connections to prewarm (default: 2)
	ConnectionCount int

	// EnableLazyLoading defers non-critical initialization
	EnableLazyLoading bool

	// TimeoutBuffer for Lambda context timeout handling
	TimeoutBuffer time.Duration
}

LambdaInitOptions provides configuration for Lambda initialization

type LazyLoader

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

LazyLoader provides deferred initialization for non-critical components

func NewLazyLoader

func NewLazyLoader(loader func() (any, error)) *LazyLoader

NewLazyLoader creates a new lazy loader for deferred initialization

func (*LazyLoader) Get

func (l *LazyLoader) Get() (any, error)

Get returns the lazily loaded value, initializing it on first access

func (*LazyLoader) Reset

func (l *LazyLoader) Reset()

Reset clears the cached value, forcing re-initialization on next access

type MockTx

type MockTx struct {
	core.Tx
}

MockTx is a mock implementation of the core.Tx interface for testing

func (*MockTx) ConditionCheck

func (m *MockTx) ConditionCheck(_ string, _ map[string]any, _ string, _ ...any) error

ConditionCheck adds a condition check to the transaction

func (*MockTx) Delete

func (m *MockTx) Delete(_ any) error

Delete adds a Delete operation to the transaction

func (*MockTx) DeleteByKey

func (m *MockTx) DeleteByKey(_ string, _ map[string]any) error

DeleteByKey adds a Delete operation by key to the transaction

func (*MockTx) Put

func (m *MockTx) Put(_ any) error

Put adds a Put operation to the transaction

func (*MockTx) Update

func (m *MockTx) Update(_ any) error

Update adds an Update operation to the transaction

func (*MockTx) UpdateWithExpression

func (m *MockTx) UpdateWithExpression(_ any, _ string, _ ...any) error

UpdateWithExpression adds an Update operation with expression to the transaction

type Model

type Model struct {
	// Primary keys using standard naming
	PK string `theorydb:"pk" json:"pk"` // entity_type#{id}
	SK string `theorydb:"sk" json:"sk"` // entity_type#{id}

	// Standard fields from BaseModel
	BaseModel

	// Example GSI attributes
	GSI1PK string `theorydb:"index:gsi1,pk,attr:gsi1PK" json:"gsi1_pk"`
	GSI1SK string `theorydb:"index:gsi1,sk,attr:gsi1SK" json:"gsi1_sk"`

	// Business data
	ID          string `json:"id"`
	Type        string `theorydb:"attr:type" json:"type"`
	Timestamp   string `theorydb:"attr:timestamp" json:"timestamp"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Active      bool   `json:"active"`
}

Model is a sample implementation of a DynamORM model This serves as a template for implementing specific models

type ModelConverter

type ModelConverter interface {
	// ToStorage converts a DynamORM model to a storage model
	ToStorage() any

	// FromStorage converts a storage model to a DynamORM model
	FromStorage(any) error
}

ModelConverter is an interface for converting between model types

type ModelRepository

type ModelRepository struct {
	BaseRepository
}

ModelRepository is a sample implementation of a DynamORM repository This serves as a template for implementing specific repositories

func NewModelRepository

func NewModelRepository(db core.DB, tableName string) *ModelRepository

NewModelRepository creates a new ModelRepository

func (*ModelRepository) Create

func (r *ModelRepository) Create(_ context.Context, model *Model) error

Create creates a new model

func (*ModelRepository) Delete

func (r *ModelRepository) Delete(_ context.Context, id string) error

Delete deletes a model

func (*ModelRepository) Get

func (r *ModelRepository) Get(_ context.Context, id string) (*Model, error)

Get gets a model by ID

func (*ModelRepository) List

func (r *ModelRepository) List(_ context.Context, modelType string, limit int) ([]*Model, error)

List lists models by type

func (*ModelRepository) Update

func (r *ModelRepository) Update(_ context.Context, model *Model) error

Update updates a model

type OperationType

type OperationType int

OperationType defines the type of transaction operation

const (
	// OperationPut represents a put operation
	OperationPut OperationType = iota
	// OperationUpdate represents an update operation
	OperationUpdate
	// OperationDelete represents a delete operation
	OperationDelete
	// OperationConditionCheck represents a condition check operation
	OperationConditionCheck
)

func (OperationType) String

func (ot OperationType) String() string

String returns the string representation of the operation type

type Repository

type Repository interface {
	// GetTableName returns the name of the DynamoDB table
	GetTableName() string

	// GetDB returns the DynamORM client
	GetDB() core.DB
}

Repository defines the interface for DynamoDB operations This is the base interface that all repositories should implement

type RepositoryAdapterConfig

type RepositoryAdapterConfig struct {
	DB              core.DB
	TableName       string
	EntityType      string
	OriginalRepo    any
	ConversionFuncs map[string]any
}

RepositoryAdapterConfig provides configuration for repository adapters

func NewRepositoryAdapterConfig

func NewRepositoryAdapterConfig(db core.DB, tableName, entityType string) *RepositoryAdapterConfig

NewRepositoryAdapterConfig creates a new RepositoryAdapterConfig

func (*RepositoryAdapterConfig) WithConversion

func (c *RepositoryAdapterConfig) WithConversion(name string, fn any) *RepositoryAdapterConfig

WithConversion adds a conversion function

func (*RepositoryAdapterConfig) WithOriginalRepo

func (c *RepositoryAdapterConfig) WithOriginalRepo(repo any) *RepositoryAdapterConfig

WithOriginalRepo sets the original repository

type RepositoryMethodCall

type RepositoryMethodCall struct {
	MethodName       string
	RepositoryMethod string
}

RepositoryMethodCall defines a repository method invocation

type StandardModel

type StandardModel struct {
	// Primary keys using standard naming
	PK string `theorydb:"pk" json:"pk"` // entity_type#{id}
	SK string `theorydb:"sk" json:"sk"` // entity_type#{id} or hierarchical structure

	// Standard timestamps
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

StandardModel provides the base structure for all DynamORM models with standardized primary key fields and timestamps

func (*StandardModel) BeforeCreate

func (m *StandardModel) BeforeCreate() error

BeforeCreate is a hook that sets CreatedAt and UpdatedAt before creating a record

func (*StandardModel) BeforeUpdate

func (m *StandardModel) BeforeUpdate() error

BeforeUpdate is a hook that updates the UpdatedAt timestamp before updating a record

type StorageAdapter

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

StorageAdapter bridges the comprehensive storage interface to repository implementations. This adapter is the architectural keystone that enables Phase 1 completion of the DynamORM migration.

The adapter pattern enables gradual migration while maintaining compatibility with all existing storage operations by delegating each method to the appropriate repository implementation.

func NewStorageAdapter

func NewStorageAdapter(repos core.RepositoryStorage) *StorageAdapter

NewStorageAdapter creates a new storage adapter with repository access. This constructor initializes the adapter with all necessary dependencies for bridging the legacy storage interface to the new repository-based architecture.

func (*StorageAdapter) AI

func (s *StorageAdapter) AI() interface{}

AI returns the AI repository instance

func (*StorageAdapter) AcceptFollowRequest

func (s *StorageAdapter) AcceptFollowRequest(ctx context.Context, followerUsername, followingID, _ string) error

AcceptFollowRequest accepts a follow request

func (*StorageAdapter) Account

func (s *StorageAdapter) Account() interface{}

Account returns the Account repository instance

func (*StorageAdapter) Activity

func (s *StorageAdapter) Activity() interface{}

Activity returns the Activity repository instance

func (*StorageAdapter) Actor

func (s *StorageAdapter) Actor() interface{}

Actor returns the Actor repository instance

func (*StorageAdapter) AddAnnouncementReaction

func (s *StorageAdapter) AddAnnouncementReaction(ctx context.Context, username, announcementID, emoji string) error

AddAnnouncementReaction adds a reaction to an announcement

func (*StorageAdapter) AddListMember

func (s *StorageAdapter) AddListMember(ctx context.Context, listID, username string) error

AddListMember adds a member to a list

func (*StorageAdapter) AddToTimeline

func (s *StorageAdapter) AddToTimeline(ctx context.Context, username string, objectID string, activityType string) error

AddToTimeline adds an entry to timeline

func (*StorageAdapter) Analytics

func (s *StorageAdapter) Analytics() interface{}

Analytics returns the Analytics repository instance

func (*StorageAdapter) Announcement

func (s *StorageAdapter) Announcement() interface{}

Announcement returns the Announcement repository instance

func (*StorageAdapter) Audit

func (s *StorageAdapter) Audit() interface{}

Audit returns the Audit repository instance

func (*StorageAdapter) BeginTransaction

func (s *StorageAdapter) BeginTransaction(ctx context.Context) (interfaces.Transaction, error)

BeginTransaction begins a new database transaction

func (*StorageAdapter) BlockActor

func (s *StorageAdapter) BlockActor(ctx context.Context, blockerUsername, blockedUsername string) error

BlockActor creates a block relationship

func (*StorageAdapter) CastPollVote

func (s *StorageAdapter) CastPollVote(ctx context.Context, vote interface{}) error

CastPollVote casts a vote in a poll

func (*StorageAdapter) CleanupExpiredDNSCache

func (s *StorageAdapter) CleanupExpiredDNSCache(ctx context.Context) error

CleanupExpiredDNSCache removes expired DNS entries

func (*StorageAdapter) CleanupExpiredSessions

func (s *StorageAdapter) CleanupExpiredSessions(ctx context.Context) error

CleanupExpiredSessions removes expired sessions

func (*StorageAdapter) CleanupExpiredTokens

func (s *StorageAdapter) CleanupExpiredTokens(ctx context.Context) error

CleanupExpiredTokens removes expired tokens

func (*StorageAdapter) ClearCache

func (s *StorageAdapter) ClearCache(ctx context.Context, pattern string) error

ClearCache clears cache entries by pattern

func (*StorageAdapter) CloudWatchMetrics

func (s *StorageAdapter) CloudWatchMetrics() interface{}

CloudWatchMetrics returns the CloudWatchMetrics repository instance

func (*StorageAdapter) CommunityNote

func (s *StorageAdapter) CommunityNote() interface{}

CommunityNote returns the CommunityNote repository instance

func (*StorageAdapter) Conversation

func (s *StorageAdapter) Conversation() interface{}

Conversation returns the Conversation repository instance

func (*StorageAdapter) Cost

func (s *StorageAdapter) Cost() interface{}

Cost returns the Cost repository instance

func (*StorageAdapter) CreateAccessToken

func (s *StorageAdapter) CreateAccessToken(ctx context.Context, token interface{}) error

CreateAccessToken creates a new access token

func (*StorageAdapter) CreateActivity

func (s *StorageAdapter) CreateActivity(ctx context.Context, activity *activitypub.Activity) error

CreateActivity creates a new ActivityPub activity

func (*StorageAdapter) CreateActor

func (s *StorageAdapter) CreateActor(ctx context.Context, actor *activitypub.Actor, privateKey string) error

CreateActor creates a new actor with private key

func (*StorageAdapter) CreateAnnouncement

func (s *StorageAdapter) CreateAnnouncement(ctx context.Context, announcement interface{}) error

CreateAnnouncement creates a new announcement

func (*StorageAdapter) CreateBackgroundJob

func (s *StorageAdapter) CreateBackgroundJob(ctx context.Context, job interface{}) error

CreateBackgroundJob creates a background job

func (*StorageAdapter) CreateCostAlert

func (s *StorageAdapter) CreateCostAlert(ctx context.Context, alert interface{}) error

CreateCostAlert creates a cost alert

func (*StorageAdapter) CreateDomainBlock

func (s *StorageAdapter) CreateDomainBlock(ctx context.Context, domain string, reason string) error

CreateDomainBlock creates a domain block

func (*StorageAdapter) CreateFederationInstance

func (s *StorageAdapter) CreateFederationInstance(ctx context.Context, instance interface{}) error

CreateFederationInstance creates a federation instance

func (*StorageAdapter) CreateFlag

func (s *StorageAdapter) CreateFlag(ctx context.Context, flag interface{}) error

CreateFlag creates a content flag

func (*StorageAdapter) CreateFollowRequest

func (s *StorageAdapter) CreateFollowRequest(ctx context.Context, followerUsername, followingID, activityID string) error

CreateFollowRequest creates a follow request

func (*StorageAdapter) CreateHashtag

func (s *StorageAdapter) CreateHashtag(ctx context.Context, hashtag interface{}) error

CreateHashtag creates a new hashtag

func (*StorageAdapter) CreateLike

func (s *StorageAdapter) CreateLike(ctx context.Context, actorID, objectID, activityID string) error

CreateLike creates a like for an object

func (*StorageAdapter) CreateList

func (s *StorageAdapter) CreateList(ctx context.Context, list interface{}) error

CreateList creates a new list

func (*StorageAdapter) CreateMediaAttachment

func (s *StorageAdapter) CreateMediaAttachment(ctx context.Context, media interface{}) error

CreateMediaAttachment creates a media attachment

func (*StorageAdapter) CreateModerationDecision

func (s *StorageAdapter) CreateModerationDecision(ctx context.Context, decision interface{}) error

CreateModerationDecision creates a moderation decision

func (*StorageAdapter) CreateNotification

func (s *StorageAdapter) CreateNotification(ctx context.Context, notification interface{}) error

CreateNotification creates a new notification

func (*StorageAdapter) CreateOAuthClient

func (s *StorageAdapter) CreateOAuthClient(ctx context.Context, client interface{}) error

CreateOAuthClient creates an OAuth client

func (*StorageAdapter) CreateOAuthState

func (s *StorageAdapter) CreateOAuthState(ctx context.Context, state interface{}) error

CreateOAuthState creates OAuth state

func (*StorageAdapter) CreateObject

func (s *StorageAdapter) CreateObject(ctx context.Context, object interface{}) error

CreateObject creates a new object (PK=`object#id`, SK=`object#id`)

func (*StorageAdapter) CreatePoll

func (s *StorageAdapter) CreatePoll(ctx context.Context, poll interface{}) error

CreatePoll creates a new poll

func (*StorageAdapter) CreateRelationship

func (s *StorageAdapter) CreateRelationship(ctx context.Context, followerUsername, followingID, activityID string) error

CreateRelationship creates a follow relationship

func (*StorageAdapter) CreateReport

func (s *StorageAdapter) CreateReport(ctx context.Context, report interface{}) error

CreateReport creates a moderation report

func (*StorageAdapter) CreateScheduledStatus

func (s *StorageAdapter) CreateScheduledStatus(ctx context.Context, scheduled interface{}) error

CreateScheduledStatus creates a scheduled status

func (*StorageAdapter) CreateSession

func (s *StorageAdapter) CreateSession(ctx context.Context, session interface{}) error

CreateSession creates a new user session

func (*StorageAdapter) CreateUser

func (s *StorageAdapter) CreateUser(ctx context.Context, user interface{}) error

CreateUser creates a new user (PK=`USER#username`, SK=`PROFILE`)

func (*StorageAdapter) DLQ

func (s *StorageAdapter) DLQ() interface{}

DLQ returns the DLQ repository instance

func (*StorageAdapter) DNSCache

func (s *StorageAdapter) DNSCache() interface{}

DNSCache returns the DNSCache repository instance

func (*StorageAdapter) DecrementReplyCount

func (s *StorageAdapter) DecrementReplyCount(ctx context.Context, objectID string) error

DecrementReplyCount decrements the reply count for an object

func (*StorageAdapter) DeleteActivity

func (s *StorageAdapter) DeleteActivity(ctx context.Context, activityID string) error

DeleteActivity removes an activity by ID

func (*StorageAdapter) DeleteActor

func (s *StorageAdapter) DeleteActor(ctx context.Context, username string) error

DeleteActor removes an actor by username

func (*StorageAdapter) DeleteAnnouncement

func (s *StorageAdapter) DeleteAnnouncement(ctx context.Context, announcementID string) error

DeleteAnnouncement deletes an announcement

func (*StorageAdapter) DeleteCache

func (s *StorageAdapter) DeleteCache(ctx context.Context, key string) error

DeleteCache removes general cache entry

func (*StorageAdapter) DeleteDNSCache

func (s *StorageAdapter) DeleteDNSCache(ctx context.Context, hostname string) error

DeleteDNSCache removes DNS cache entry

func (*StorageAdapter) DeleteList

func (s *StorageAdapter) DeleteList(ctx context.Context, listID string) error

DeleteList deletes a list

func (*StorageAdapter) DeleteMediaAttachment

func (s *StorageAdapter) DeleteMediaAttachment(ctx context.Context, mediaID string) error

DeleteMediaAttachment deletes a media attachment

func (*StorageAdapter) DeleteNotification

func (s *StorageAdapter) DeleteNotification(ctx context.Context, notificationID string) error

DeleteNotification deletes a notification

func (*StorageAdapter) DeleteNotificationsByObject

func (s *StorageAdapter) DeleteNotificationsByObject(ctx context.Context, objectID string) error

DeleteNotificationsByObject deletes notifications for an object

func (*StorageAdapter) DeleteOAuthState

func (s *StorageAdapter) DeleteOAuthState(ctx context.Context, state string) error

DeleteOAuthState removes OAuth state

func (*StorageAdapter) DeleteObject

func (s *StorageAdapter) DeleteObject(ctx context.Context, objectID string) error

DeleteObject removes an object by ID

func (*StorageAdapter) DeleteScheduledStatus

func (s *StorageAdapter) DeleteScheduledStatus(ctx context.Context, id string) error

DeleteScheduledStatus deletes a scheduled status

func (*StorageAdapter) DeleteSession

func (s *StorageAdapter) DeleteSession(ctx context.Context, sessionID string) error

DeleteSession removes a session

func (*StorageAdapter) DeleteUser

func (s *StorageAdapter) DeleteUser(ctx context.Context, username string) error

DeleteUser removes a user by username

func (*StorageAdapter) DismissAnnouncement

func (s *StorageAdapter) DismissAnnouncement(ctx context.Context, username, announcementID string) error

DismissAnnouncement dismisses an announcement for a user

func (*StorageAdapter) DomainBlock

func (s *StorageAdapter) DomainBlock() interface{}

DomainBlock returns the DomainBlock repository instance

func (*StorageAdapter) Emoji

func (s *StorageAdapter) Emoji() interface{}

Emoji returns the Emoji repository instance

func (*StorageAdapter) ExecuteInTransaction

func (s *StorageAdapter) ExecuteInTransaction(ctx context.Context, fn func(tx interfaces.Transaction) error) error

ExecuteInTransaction executes a function within a transaction

func (*StorageAdapter) Export

func (s *StorageAdapter) Export() interface{}

Export returns the Export repository instance

func (*StorageAdapter) FanOutPost

func (s *StorageAdapter) FanOutPost(ctx context.Context, activity *activitypub.Activity) error

FanOutPost distributes a post to timelines

func (*StorageAdapter) FeaturedTag

func (s *StorageAdapter) FeaturedTag() interface{}

FeaturedTag returns the FeaturedTag repository instance

func (*StorageAdapter) Federation

func (s *StorageAdapter) Federation() interface{}

Federation returns the Federation repository instance

func (*StorageAdapter) Filter

func (s *StorageAdapter) Filter() interface{}

Filter returns the Filter repository instance

func (*StorageAdapter) FollowActor

func (s *StorageAdapter) FollowActor(ctx context.Context, followerUsername, targetUsername string) error

FollowActor creates a follow relationship

func (*StorageAdapter) FollowHashtag

func (s *StorageAdapter) FollowHashtag(ctx context.Context, username, hashtagName string) error

FollowHashtag follows a hashtag

func (*StorageAdapter) GetAccessToken

func (s *StorageAdapter) GetAccessToken(ctx context.Context, tokenID string) (interface{}, error)

GetAccessToken retrieves an access token

func (*StorageAdapter) GetActiveAnnouncements

func (s *StorageAdapter) GetActiveAnnouncements(ctx context.Context) ([]interface{}, error)

GetActiveAnnouncements retrieves active announcements

func (*StorageAdapter) GetActivitiesByActor

func (s *StorageAdapter) GetActivitiesByActor(ctx context.Context, actorID string, limit int, cursor string) ([]*activitypub.Activity, string, error)

GetActivitiesByActor retrieves activities by actor ID

func (*StorageAdapter) GetActivity

func (s *StorageAdapter) GetActivity(ctx context.Context, activityID string) (*activitypub.Activity, error)

GetActivity retrieves an activity by ID

func (*StorageAdapter) GetActor

func (s *StorageAdapter) GetActor(ctx context.Context, username string) (*activitypub.Actor, error)

GetActor retrieves an actor by username (PK=`ACTOR#username`, SK=`PROFILE`)

func (*StorageAdapter) GetActorByID

func (s *StorageAdapter) GetActorByID(ctx context.Context, actorID string) (*activitypub.Actor, error)

GetActorByID retrieves an actor by ID

func (*StorageAdapter) GetActorPrivateKey

func (s *StorageAdapter) GetActorPrivateKey(ctx context.Context, username string) (string, error)

GetActorPrivateKey retrieves the private key for an actor

func (*StorageAdapter) GetAllAnnouncements

func (s *StorageAdapter) GetAllAnnouncements(ctx context.Context, limit int, cursor string) ([]interface{}, string, error)

GetAllAnnouncements retrieves all announcements

func (*StorageAdapter) GetAllFederationInstances

func (s *StorageAdapter) GetAllFederationInstances(ctx context.Context, limit int, cursor string) ([]interface{}, string, error)

GetAllFederationInstances retrieves all federation instances

func (*StorageAdapter) GetAllServiceHealth

func (s *StorageAdapter) GetAllServiceHealth(ctx context.Context) ([]interface{}, error)

GetAllServiceHealth retrieves all service health

func (*StorageAdapter) GetAnnouncement

func (s *StorageAdapter) GetAnnouncement(ctx context.Context, announcementID string) (interface{}, error)

GetAnnouncement retrieves an announcement by ID

func (*StorageAdapter) GetBackgroundJob

func (s *StorageAdapter) GetBackgroundJob(ctx context.Context, jobID string) (interface{}, error)

GetBackgroundJob retrieves a background job

func (*StorageAdapter) GetBlockedUsers

func (s *StorageAdapter) GetBlockedUsers(ctx context.Context, username string, limit int, cursor string) ([]string, string, error)

GetBlockedUsers retrieves blocked users list

func (*StorageAdapter) GetCache

func (s *StorageAdapter) GetCache(ctx context.Context, key string, value interface{}) error

GetCache retrieves general cache entry

func (*StorageAdapter) GetContentMetrics

func (s *StorageAdapter) GetContentMetrics(ctx context.Context, since time.Time) (interface{}, error)

GetContentMetrics retrieves content metrics

func (*StorageAdapter) GetCostAlerts

func (s *StorageAdapter) GetCostAlerts(ctx context.Context) ([]interface{}, error)

GetCostAlerts retrieves cost alerts

func (*StorageAdapter) GetCostSummary

func (s *StorageAdapter) GetCostSummary(ctx context.Context, since time.Time) (interface{}, error)

GetCostSummary retrieves cost summary

func (*StorageAdapter) GetDB

func (s *StorageAdapter) GetDB() interface{}

GetDB returns the database connection instance.

func (*StorageAdapter) GetDNSCache

func (s *StorageAdapter) GetDNSCache(ctx context.Context, hostname string) (interface{}, error)

GetDNSCache retrieves DNS cache entry

func (*StorageAdapter) GetDailyCostSummary

func (s *StorageAdapter) GetDailyCostSummary(ctx context.Context, date time.Time) (interface{}, error)

GetDailyCostSummary retrieves daily cost summary

func (*StorageAdapter) GetDatabaseMetrics

func (s *StorageAdapter) GetDatabaseMetrics(ctx context.Context, since time.Time) (interface{}, error)

GetDatabaseMetrics retrieves database metrics

func (*StorageAdapter) GetDatabaseStatus

func (s *StorageAdapter) GetDatabaseStatus(_ context.Context) (interface{}, error)

GetDatabaseStatus retrieves database status

func (*StorageAdapter) GetDomainBlocks

func (s *StorageAdapter) GetDomainBlocks(ctx context.Context, limit int, cursor string) ([]interface{}, string, error)

GetDomainBlocks retrieves domain blocks

func (*StorageAdapter) GetDueScheduledStatuses

func (s *StorageAdapter) GetDueScheduledStatuses(ctx context.Context, before time.Time, limit int) ([]interface{}, error)

GetDueScheduledStatuses retrieves due scheduled statuses

func (*StorageAdapter) GetFederationActivities

func (s *StorageAdapter) GetFederationActivities(ctx context.Context, domain string, limit int, cursor string) ([]interface{}, string, error)

GetFederationActivities retrieves federation activities

func (*StorageAdapter) GetFederationHealth

func (s *StorageAdapter) GetFederationHealth(ctx context.Context, domain string) (interface{}, error)

GetFederationHealth retrieves federation health

func (*StorageAdapter) GetFederationInstance

func (s *StorageAdapter) GetFederationInstance(ctx context.Context, domain string) (interface{}, error)

GetFederationInstance retrieves a federation instance

func (*StorageAdapter) GetFederationStatistics

func (s *StorageAdapter) GetFederationStatistics(ctx context.Context, domain string, since time.Time) (interface{}, error)

GetFederationStatistics retrieves federation statistics

func (*StorageAdapter) GetFlags

func (s *StorageAdapter) GetFlags(ctx context.Context, objectID string) ([]interface{}, error)

GetFlags retrieves flags for content

func (*StorageAdapter) GetFlagsByUser

func (s *StorageAdapter) GetFlagsByUser(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetFlagsByUser retrieves flags by user

func (*StorageAdapter) GetFollowedHashtags

func (s *StorageAdapter) GetFollowedHashtags(ctx context.Context, username string, limit int, cursor string) ([]*storage.HashtagFollow, string, error)

GetFollowedHashtags retrieves followed hashtags

func (*StorageAdapter) GetFollowers

func (s *StorageAdapter) GetFollowers(ctx context.Context, username string, limit int, cursor string) ([]string, string, error)

GetFollowers retrieves followers list

func (*StorageAdapter) GetFollowersCount

func (s *StorageAdapter) GetFollowersCount(ctx context.Context, username string) (int64, error)

GetFollowersCount gets the count of followers

func (*StorageAdapter) GetFollowing

func (s *StorageAdapter) GetFollowing(ctx context.Context, username string, limit int, cursor string) ([]string, string, error)

GetFollowing retrieves following list

func (*StorageAdapter) GetFollowingCount

func (s *StorageAdapter) GetFollowingCount(ctx context.Context, username string) (int64, error)

GetFollowingCount gets the count of following

func (*StorageAdapter) GetHashtag

func (s *StorageAdapter) GetHashtag(ctx context.Context, name string) (interface{}, error)

GetHashtag retrieves a hashtag by name

func (*StorageAdapter) GetHashtagNotificationSettings

func (s *StorageAdapter) GetHashtagNotificationSettings(ctx context.Context, username, hashtagName string) (*storage.HashtagNotificationSettings, error)

GetHashtagNotificationSettings fetches notification preferences.

func (*StorageAdapter) GetHashtagTimeline

func (s *StorageAdapter) GetHashtagTimeline(ctx context.Context, hashtag string, limit int, cursor string) ([]interface{}, string, error)

GetHashtagTimeline retrieves hashtag timeline

func (*StorageAdapter) GetHashtagsByPopularity

func (s *StorageAdapter) GetHashtagsByPopularity(ctx context.Context, limit int, since time.Time) ([]interface{}, error)

GetHashtagsByPopularity retrieves hashtags by popularity

func (*StorageAdapter) GetHomeTimeline

func (s *StorageAdapter) GetHomeTimeline(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetHomeTimeline retrieves home timeline

func (*StorageAdapter) GetInfrastructureHealth

func (s *StorageAdapter) GetInfrastructureHealth(_ context.Context) (*model.InfrastructureStatus, error)

GetInfrastructureHealth retrieves infrastructure health status

func (*StorageAdapter) GetInstanceBudgets

func (s *StorageAdapter) GetInstanceBudgets(_ context.Context, exceeded *bool) ([]*model.InstanceBudget, error)

GetInstanceBudgets retrieves instance budgets

func (*StorageAdapter) GetInstanceHealthReport

func (s *StorageAdapter) GetInstanceHealthReport(ctx context.Context, domain string) (*model.InstanceHealthReport, error)

GetInstanceHealthReport retrieves instance health report

func (*StorageAdapter) GetInstanceMetrics

func (s *StorageAdapter) GetInstanceMetrics(ctx context.Context, since time.Time) (interface{}, error)

GetInstanceMetrics retrieves instance metrics

func (*StorageAdapter) GetInstanceRelationships

func (s *StorageAdapter) GetInstanceRelationships(ctx context.Context, domain string) (*model.InstanceRelations, error)

GetInstanceRelationships retrieves instance relationships

func (*StorageAdapter) GetLikeCount

func (s *StorageAdapter) GetLikeCount(ctx context.Context, objectID string) (int64, error)

GetLikeCount gets the like count for an object

func (*StorageAdapter) GetLikedObjects

func (s *StorageAdapter) GetLikedObjects(ctx context.Context, actorID string, limit int, cursor string) ([]string, string, error)

GetLikedObjects retrieves objects liked by an actor

func (*StorageAdapter) GetList

func (s *StorageAdapter) GetList(ctx context.Context, listID string) (interface{}, error)

GetList retrieves a list by ID

func (*StorageAdapter) GetListMembers

func (s *StorageAdapter) GetListMembers(ctx context.Context, listID string, limit int, cursor string) ([]interface{}, string, error)

GetListMembers retrieves list members

func (*StorageAdapter) GetListsByUser

func (s *StorageAdapter) GetListsByUser(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetListsByUser retrieves lists for a user

func (*StorageAdapter) GetLogger

func (s *StorageAdapter) GetLogger() interface{}

GetLogger returns the logger instance.

func (*StorageAdapter) GetMaintenanceStatus

func (s *StorageAdapter) GetMaintenanceStatus(_ context.Context) (interface{}, error)

GetMaintenanceStatus retrieves maintenance status

func (*StorageAdapter) GetMediaAttachment

func (s *StorageAdapter) GetMediaAttachment(ctx context.Context, mediaID string) (interface{}, error)

GetMediaAttachment retrieves a media attachment

func (*StorageAdapter) GetMediaAttachmentsByUser

func (s *StorageAdapter) GetMediaAttachmentsByUser(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetMediaAttachmentsByUser retrieves media attachments for a user

func (*StorageAdapter) GetMediaMetadata

func (s *StorageAdapter) GetMediaMetadata(ctx context.Context, mediaID string) (interface{}, error)

GetMediaMetadata retrieves media metadata

func (*StorageAdapter) GetMigrationStatus

func (s *StorageAdapter) GetMigrationStatus(_ context.Context) (interface{}, error)

GetMigrationStatus retrieves migration status

func (*StorageAdapter) GetModerationDecision

func (s *StorageAdapter) GetModerationDecision(ctx context.Context, contentID string) (interface{}, error)

GetModerationDecision retrieves a moderation decision

func (*StorageAdapter) GetModerationQueue

func (s *StorageAdapter) GetModerationQueue(ctx context.Context, filter interface{}) ([]interface{}, error)

GetModerationQueue retrieves moderation queue

func (*StorageAdapter) GetMutedUsers

func (s *StorageAdapter) GetMutedUsers(ctx context.Context, username string, limit int, cursor string) ([]string, string, error)

GetMutedUsers retrieves muted users list

func (*StorageAdapter) GetNotifications

func (s *StorageAdapter) GetNotifications(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetNotifications retrieves notifications for a user

func (*StorageAdapter) GetOAuthClient

func (s *StorageAdapter) GetOAuthClient(ctx context.Context, clientID string) (interface{}, error)

GetOAuthClient retrieves an OAuth client

func (*StorageAdapter) GetOAuthState

func (s *StorageAdapter) GetOAuthState(ctx context.Context, state string) (interface{}, error)

GetOAuthState retrieves OAuth state

func (*StorageAdapter) GetObject

func (s *StorageAdapter) GetObject(ctx context.Context, objectID string) (interface{}, error)

GetObject retrieves an object by ID

func (*StorageAdapter) GetObjectHistory

func (s *StorageAdapter) GetObjectHistory(ctx context.Context, objectID string) ([]interface{}, error)

GetObjectHistory retrieves object version history

func (*StorageAdapter) GetObjectLikes

func (s *StorageAdapter) GetObjectLikes(ctx context.Context, objectID string, limit int, cursor string) ([]interface{}, string, error)

GetObjectLikes retrieves likes for an object

func (*StorageAdapter) GetObjectMetadata

func (s *StorageAdapter) GetObjectMetadata(ctx context.Context, objectID string) (interface{}, error)

GetObjectMetadata retrieves object metadata

func (*StorageAdapter) GetPendingBackgroundJobs

func (s *StorageAdapter) GetPendingBackgroundJobs(ctx context.Context, jobType string, limit int) ([]interface{}, error)

GetPendingBackgroundJobs retrieves pending background jobs

func (*StorageAdapter) GetPendingFollowRequests

func (s *StorageAdapter) GetPendingFollowRequests(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetPendingFollowRequests retrieves pending follow requests

func (*StorageAdapter) GetPoll

func (s *StorageAdapter) GetPoll(ctx context.Context, pollID string) (interface{}, error)

GetPoll retrieves a poll by ID

func (*StorageAdapter) GetPollResults

func (s *StorageAdapter) GetPollResults(ctx context.Context, pollID string) (interface{}, error)

GetPollResults retrieves poll results

func (*StorageAdapter) GetPollVote

func (s *StorageAdapter) GetPollVote(ctx context.Context, pollID, voterID string) (interface{}, error)

GetPollVote retrieves a user's vote in a poll

func (*StorageAdapter) GetPollsByUser

func (s *StorageAdapter) GetPollsByUser(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetPollsByUser retrieves polls for a user

func (*StorageAdapter) GetPublicTimeline

func (s *StorageAdapter) GetPublicTimeline(ctx context.Context, limit int, cursor string) ([]interface{}, string, error)

GetPublicTimeline retrieves public timeline

func (*StorageAdapter) GetRelationship

func (s *StorageAdapter) GetRelationship(ctx context.Context, followerUsername, followingID string) (interface{}, error)

GetRelationship retrieves relationship details

func (*StorageAdapter) GetReport

func (s *StorageAdapter) GetReport(ctx context.Context, reportID string) (interface{}, error)

GetReport retrieves a moderation report

func (*StorageAdapter) GetReportsByStatus

func (s *StorageAdapter) GetReportsByStatus(ctx context.Context, status interface{}, limit int, cursor string) ([]interface{}, string, error)

GetReportsByStatus retrieves reports by status

func (*StorageAdapter) GetReportsByUser

func (s *StorageAdapter) GetReportsByUser(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetReportsByUser retrieves reports by user

func (*StorageAdapter) GetScheduledStatus

func (s *StorageAdapter) GetScheduledStatus(ctx context.Context, id string) (interface{}, error)

GetScheduledStatus retrieves a scheduled status

func (*StorageAdapter) GetScheduledStatuses

func (s *StorageAdapter) GetScheduledStatuses(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetScheduledStatuses retrieves scheduled statuses for user

func (*StorageAdapter) GetSearchSuggestions

func (s *StorageAdapter) GetSearchSuggestions(ctx context.Context, query string, limit int) ([]interface{}, error)

GetSearchSuggestions gets search suggestions

func (*StorageAdapter) GetServiceHealth

func (s *StorageAdapter) GetServiceHealth(ctx context.Context, service string) (interface{}, error)

GetServiceHealth retrieves service health

func (*StorageAdapter) GetSession

func (s *StorageAdapter) GetSession(ctx context.Context, sessionID string) (interface{}, error)

GetSession retrieves a session by ID

func (*StorageAdapter) GetStorageInfo

func (s *StorageAdapter) GetStorageInfo(_ context.Context) (interface{}, error)

GetStorageInfo retrieves storage configuration and metadata

func (*StorageAdapter) GetStorageStatistics

func (s *StorageAdapter) GetStorageStatistics(ctx context.Context) (interface{}, error)

GetStorageStatistics retrieves storage usage statistics

func (*StorageAdapter) GetTableName

func (s *StorageAdapter) GetTableName() string

GetTableName returns the name of the DynamoDB table.

func (*StorageAdapter) GetTimeline

func (s *StorageAdapter) GetTimeline(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetTimeline retrieves user timeline

func (*StorageAdapter) GetTrendingHashtags

func (s *StorageAdapter) GetTrendingHashtags(ctx context.Context, limit int) ([]interface{}, error)

GetTrendingHashtags gets trending hashtags

func (*StorageAdapter) GetTrendingStatuses

func (s *StorageAdapter) GetTrendingStatuses(ctx context.Context, limit int, cursor string) ([]interface{}, string, error)

GetTrendingStatuses gets trending statuses

func (*StorageAdapter) GetUnhealthyFederationInstances

func (s *StorageAdapter) GetUnhealthyFederationInstances(ctx context.Context, limit int) ([]interface{}, error)

GetUnhealthyFederationInstances retrieves unhealthy federation instances

func (*StorageAdapter) GetUnreadNotificationCount

func (s *StorageAdapter) GetUnreadNotificationCount(ctx context.Context, username string) (int64, error)

GetUnreadNotificationCount gets unread notification count

func (*StorageAdapter) GetUser

func (s *StorageAdapter) GetUser(ctx context.Context, username string) (interface{}, error)

GetUser retrieves a user by username

func (*StorageAdapter) GetUserActivityMetrics

func (s *StorageAdapter) GetUserActivityMetrics(ctx context.Context, username string, since time.Time) (interface{}, error)

GetUserActivityMetrics retrieves user activity metrics

func (*StorageAdapter) GetUserByEmail

func (s *StorageAdapter) GetUserByEmail(ctx context.Context, email string) (interface{}, error)

GetUserByEmail retrieves a user by email address

func (*StorageAdapter) GetUserByID

func (s *StorageAdapter) GetUserByID(ctx context.Context, userID string) (interface{}, error)

GetUserByID retrieves a user by ID

func (*StorageAdapter) GetUserLists

func (s *StorageAdapter) GetUserLists(ctx context.Context, username string) ([]interface{}, error)

GetUserLists retrieves lists that contain a user

func (*StorageAdapter) GetUserPreferences

func (s *StorageAdapter) GetUserPreferences(ctx context.Context, username string) (interface{}, error)

GetUserPreferences retrieves user preferences

func (*StorageAdapter) GetUserSessions

func (s *StorageAdapter) GetUserSessions(ctx context.Context, username string) ([]interface{}, error)

GetUserSessions retrieves all sessions for a user

func (*StorageAdapter) GetUserTimeline

func (s *StorageAdapter) GetUserTimeline(ctx context.Context, username string, limit int, cursor string) ([]interface{}, string, error)

GetUserTimeline retrieves user timeline

func (*StorageAdapter) HasLiked

func (s *StorageAdapter) HasLiked(ctx context.Context, actorID, objectID string) (bool, error)

HasLiked checks if an actor has liked an object

func (*StorageAdapter) Hashtag

func (s *StorageAdapter) Hashtag() interface{}

Hashtag returns the Hashtag repository instance

func (*StorageAdapter) Import

func (s *StorageAdapter) Import() interface{}

Import returns the Import repository instance

func (*StorageAdapter) IncrementHashtagUsage

func (s *StorageAdapter) IncrementHashtagUsage(ctx context.Context, name string) error

IncrementHashtagUsage increments hashtag usage count

func (*StorageAdapter) IncrementReplyCount

func (s *StorageAdapter) IncrementReplyCount(ctx context.Context, objectID string) error

IncrementReplyCount increments the reply count for an object

func (*StorageAdapter) Instance

func (s *StorageAdapter) Instance() interface{}

Instance returns the Instance repository instance

func (*StorageAdapter) IsBlocked

func (s *StorageAdapter) IsBlocked(ctx context.Context, blockerUsername, blockedUsername string) (bool, error)

IsBlocked checks if a user is blocked

func (*StorageAdapter) IsDomainBlocked

func (s *StorageAdapter) IsDomainBlocked(ctx context.Context, domain string) (bool, error)

IsDomainBlocked checks if a domain is blocked

func (*StorageAdapter) IsFollowing

func (s *StorageAdapter) IsFollowing(ctx context.Context, followerUsername, followingID string) (bool, error)

IsFollowing checks if a user is following another

func (*StorageAdapter) IsFollowingHashtag

func (s *StorageAdapter) IsFollowingHashtag(ctx context.Context, username, hashtagName string) (bool, error)

IsFollowingHashtag checks if user follows hashtag

func (*StorageAdapter) IsHashtagMuted

func (s *StorageAdapter) IsHashtagMuted(ctx context.Context, username, hashtagName string) (bool, error)

IsHashtagMuted reports whether the user has muted the hashtag.

func (*StorageAdapter) IsListMember

func (s *StorageAdapter) IsListMember(ctx context.Context, listID, username string) (bool, error)

IsListMember checks if user is a list member

func (*StorageAdapter) IsMuted

func (s *StorageAdapter) IsMuted(ctx context.Context, muterUsername, mutedUsername string) (bool, error)

IsMuted checks if a user is muted

func (*StorageAdapter) Like

func (s *StorageAdapter) Like() interface{}

Like returns the Like repository instance

func (*StorageAdapter) List

func (s *StorageAdapter) List() interface{}

List returns the List repository instance

func (*StorageAdapter) MarkAllNotificationsAsRead

func (s *StorageAdapter) MarkAllNotificationsAsRead(ctx context.Context, username string) error

MarkAllNotificationsAsRead marks all notifications as read

func (*StorageAdapter) MarkNotificationAsRead

func (s *StorageAdapter) MarkNotificationAsRead(ctx context.Context, notificationID string) error

MarkNotificationAsRead marks a notification as read

func (*StorageAdapter) MarkScheduledStatusPublished

func (s *StorageAdapter) MarkScheduledStatusPublished(ctx context.Context, id string) error

MarkScheduledStatusPublished marks scheduled status as published

func (*StorageAdapter) Marker

func (s *StorageAdapter) Marker() interface{}

Marker returns the Marker repository instance

func (*StorageAdapter) Media

func (s *StorageAdapter) Media() interface{}

Media returns the Media repository instance

func (*StorageAdapter) MediaAnalytics

func (s *StorageAdapter) MediaAnalytics() interface{}

MediaAnalytics returns the media analytics repository

func (*StorageAdapter) MediaMetadata

func (s *StorageAdapter) MediaMetadata() interface{}

MediaMetadata returns the MediaMetadata repository instance

func (*StorageAdapter) MediaPopularity

func (s *StorageAdapter) MediaPopularity() interface{}

MediaPopularity returns the media popularity repository

func (*StorageAdapter) MediaSession

func (s *StorageAdapter) MediaSession() interface{}

MediaSession returns the media session repository

func (*StorageAdapter) MetricRecord

func (s *StorageAdapter) MetricRecord() interface{}

MetricRecord returns the MetricRecord repository instance

func (*StorageAdapter) Moderation

func (s *StorageAdapter) Moderation() interface{}

Moderation returns the Moderation repository instance

func (*StorageAdapter) MuteActor

func (s *StorageAdapter) MuteActor(ctx context.Context, muterUsername, mutedUsername string) error

MuteActor creates a mute relationship

func (*StorageAdapter) MuteHashtag

func (s *StorageAdapter) MuteHashtag(ctx context.Context, username, hashtagName string, until *time.Time) error

MuteHashtag mutes a hashtag for a user.

func (*StorageAdapter) Notification

func (s *StorageAdapter) Notification() interface{}

Notification returns the Notification repository instance

func (*StorageAdapter) OAuth

func (s *StorageAdapter) OAuth() interface{}

OAuth returns the OAuth repository instance

func (*StorageAdapter) Object

func (s *StorageAdapter) Object() interface{}

Object returns the Object repository instance

func (*StorageAdapter) PerformMaintenance

func (s *StorageAdapter) PerformMaintenance(_ context.Context, operation interface{}) error

PerformMaintenance performs storage maintenance operation

func (*StorageAdapter) Poll

func (s *StorageAdapter) Poll() interface{}

Poll returns the Poll repository instance

func (*StorageAdapter) ProcessInboundActivity

func (s *StorageAdapter) ProcessInboundActivity(ctx context.Context, activity *activitypub.Activity, fromDomain string) error

ProcessInboundActivity processes inbound federated activity

func (*StorageAdapter) ProcessOutboundActivity

func (s *StorageAdapter) ProcessOutboundActivity(ctx context.Context, activity *activitypub.Activity) error

ProcessOutboundActivity processes outbound federated activity

func (*StorageAdapter) PushSubscription

func (s *StorageAdapter) PushSubscription() interface{}

PushSubscription returns the PushSubscription repository instance

func (*StorageAdapter) QueueMediaProcessing

func (s *StorageAdapter) QueueMediaProcessing(ctx context.Context, mediaID string, processingType interface{}) error

QueueMediaProcessing queues media for processing

func (*StorageAdapter) RateLimit

func (s *StorageAdapter) RateLimit() interface{}

RateLimit returns the RateLimit repository instance

func (*StorageAdapter) RecordActivity

func (s *StorageAdapter) RecordActivity(ctx context.Context, activityType, actorID string, timestamp time.Time) error

RecordActivity records activity metric

func (*StorageAdapter) RecordDatabaseError

func (s *StorageAdapter) RecordDatabaseError(ctx context.Context, operation string, err error) error

RecordDatabaseError records a database error

func (*StorageAdapter) RecordFederationActivity

func (s *StorageAdapter) RecordFederationActivity(ctx context.Context, activity interface{}) error

RecordFederationActivity records federation activity

func (*StorageAdapter) RecordHashtagUsage

func (s *StorageAdapter) RecordHashtagUsage(ctx context.Context, hashtag, objectID, actorID string) error

RecordHashtagUsage records hashtag usage metric

func (*StorageAdapter) RecordInstanceActivity

func (s *StorageAdapter) RecordInstanceActivity(ctx context.Context, activityType string, timestamp time.Time) error

RecordInstanceActivity records instance activity metric

func (*StorageAdapter) RecordLinkShare

func (s *StorageAdapter) RecordLinkShare(ctx context.Context, link, objectID, actorID string) error

RecordLinkShare records link share metric

func (*StorageAdapter) RecordServiceHealth

func (s *StorageAdapter) RecordServiceHealth(ctx context.Context, service string, status interface{}, metrics map[string]interface{}) error

RecordServiceHealth records service health status

func (*StorageAdapter) RecordStatusEngagement

func (s *StorageAdapter) RecordStatusEngagement(ctx context.Context, objectID, engagementType, actorID string) error

RecordStatusEngagement records status engagement metric

func (*StorageAdapter) Recovery

func (s *StorageAdapter) Recovery() interface{}

Recovery returns the Recovery repository instance

func (*StorageAdapter) RejectFollowRequest

func (s *StorageAdapter) RejectFollowRequest(ctx context.Context, followerUsername, followingID string) error

RejectFollowRequest rejects a follow request

func (*StorageAdapter) Relationship

func (s *StorageAdapter) Relationship() interface{}

Relationship returns the Relationship repository instance

func (*StorageAdapter) Relay

func (s *StorageAdapter) Relay() interface{}

Relay returns the Relay repository instance

func (*StorageAdapter) RemoveAnnouncementReaction

func (s *StorageAdapter) RemoveAnnouncementReaction(ctx context.Context, username, announcementID, emoji string) error

RemoveAnnouncementReaction removes a reaction from an announcement

func (*StorageAdapter) RemoveDomainBlock

func (s *StorageAdapter) RemoveDomainBlock(ctx context.Context, domain string) error

RemoveDomainBlock removes a domain block

func (*StorageAdapter) RemoveFromTimeline

func (s *StorageAdapter) RemoveFromTimeline(ctx context.Context, username, objectID string) error

RemoveFromTimeline removes an entry from timeline

func (*StorageAdapter) RemoveFromTimelines

func (s *StorageAdapter) RemoveFromTimelines(ctx context.Context, objectID string) error

RemoveFromTimelines removes an entry from all timelines

func (*StorageAdapter) RemoveLike

func (s *StorageAdapter) RemoveLike(ctx context.Context, actorID, objectID string) error

RemoveLike removes a like for an object

func (*StorageAdapter) RemoveListMember

func (s *StorageAdapter) RemoveListMember(ctx context.Context, listID, username string) error

RemoveListMember removes a member from a list

func (*StorageAdapter) RemoveRelationship

func (s *StorageAdapter) RemoveRelationship(ctx context.Context, followerUsername, followingID string) error

RemoveRelationship removes a follow relationship

func (*StorageAdapter) RestoreObjectVersion

func (s *StorageAdapter) RestoreObjectVersion(ctx context.Context, objectID string, version int) error

RestoreObjectVersion restores an object to a specific version

func (*StorageAdapter) RevokeAccessToken

func (s *StorageAdapter) RevokeAccessToken(ctx context.Context, tokenID string) error

RevokeAccessToken revokes an access token

func (*StorageAdapter) ScheduledStatus

func (s *StorageAdapter) ScheduledStatus() interface{}

ScheduledStatus returns the ScheduledStatus repository instance

func (*StorageAdapter) Search

func (s *StorageAdapter) Search() interface{}

Search returns the Search repository instance

func (*StorageAdapter) SearchAll

func (s *StorageAdapter) SearchAll(ctx context.Context, query string, limit int, cursor string) (interface{}, string, error)

SearchAll performs universal search

func (*StorageAdapter) SearchHashtags

func (s *StorageAdapter) SearchHashtags(ctx context.Context, query string, limit int, cursor string) ([]interface{}, string, error)

SearchHashtags searches for hashtags

func (*StorageAdapter) SearchStatuses

func (s *StorageAdapter) SearchStatuses(ctx context.Context, query string, limit int, cursor string) ([]interface{}, string, error)

SearchStatuses searches for statuses

func (*StorageAdapter) SearchUsers

func (s *StorageAdapter) SearchUsers(ctx context.Context, query string, limit int, cursor string) ([]interface{}, string, error)

SearchUsers searches for users

func (*StorageAdapter) SetCache

func (s *StorageAdapter) SetCache(ctx context.Context, key string, value interface{}, ttl time.Duration) error

SetCache sets general cache entry

func (*StorageAdapter) SetDNSCache

func (s *StorageAdapter) SetDNSCache(ctx context.Context, hostname string, record interface{}) error

SetDNSCache sets DNS cache entry (PK=`DNSCACHE#hostname`, SK=`ENTRY`)

func (*StorageAdapter) Social

func (s *StorageAdapter) Social() interface{}

Social returns the Social repository instance

func (*StorageAdapter) Status

func (s *StorageAdapter) Status() interface{}

Status returns the Status repository instance

func (*StorageAdapter) StoreActivity

func (s *StorageAdapter) StoreActivity(ctx context.Context, activity *activitypub.Activity) error

StoreActivity stores an ActivityPub activity

func (*StorageAdapter) StreamingCloudWatch

func (s *StorageAdapter) StreamingCloudWatch() interface{}

StreamingCloudWatch returns the StreamingCloudWatch repository instance

func (*StorageAdapter) Timeline

func (s *StorageAdapter) Timeline() interface{}

Timeline returns the Timeline repository instance

func (*StorageAdapter) TombstoneObject

func (s *StorageAdapter) TombstoneObject(ctx context.Context, objectID, actorID string) error

TombstoneObject creates a tombstone for deleted object

func (*StorageAdapter) TrackAWSCost

func (s *StorageAdapter) TrackAWSCost(ctx context.Context, service string, operation string, cost float64) error

TrackAWSCost tracks AWS service cost

func (*StorageAdapter) TrackDynamoOperation

func (s *StorageAdapter) TrackDynamoOperation(ctx context.Context, operation interface{}) error

TrackDynamoOperation tracks DynamoDB operation

func (*StorageAdapter) TrackDynamoRead

func (s *StorageAdapter) TrackDynamoRead(ctx context.Context, tableName string, units int64) error

TrackDynamoRead tracks DynamoDB read units

func (*StorageAdapter) TrackDynamoWrite

func (s *StorageAdapter) TrackDynamoWrite(ctx context.Context, tableName string, units int64) error

TrackDynamoWrite tracks DynamoDB write units

func (*StorageAdapter) TrackLambdaInvocation

func (s *StorageAdapter) TrackLambdaInvocation(ctx context.Context, functionName string, duration time.Duration) error

TrackLambdaInvocation tracks Lambda invocation cost

func (*StorageAdapter) TrackS3Operation

func (s *StorageAdapter) TrackS3Operation(ctx context.Context, bucket string, operation string, bytes int64) error

TrackS3Operation tracks S3 operation cost

func (*StorageAdapter) Trust

func (s *StorageAdapter) Trust() interface{}

Trust returns the Trust repository instance

func (*StorageAdapter) UnblockActor

func (s *StorageAdapter) UnblockActor(ctx context.Context, blockerUsername, blockedUsername string) error

UnblockActor removes a block relationship

func (*StorageAdapter) UnfollowActor

func (s *StorageAdapter) UnfollowActor(ctx context.Context, followerUsername, targetUsername string) error

UnfollowActor removes a follow relationship

func (*StorageAdapter) UnfollowHashtag

func (s *StorageAdapter) UnfollowHashtag(ctx context.Context, username, hashtagName string) error

UnfollowHashtag unfollows a hashtag

func (*StorageAdapter) UnmuteActor

func (s *StorageAdapter) UnmuteActor(ctx context.Context, muterUsername, mutedUsername string) error

UnmuteActor removes a mute relationship

func (*StorageAdapter) UnmuteHashtag

func (s *StorageAdapter) UnmuteHashtag(ctx context.Context, username, hashtagName string) error

UnmuteHashtag unmutes a hashtag for a user.

func (*StorageAdapter) UpdateActivity

func (s *StorageAdapter) UpdateActivity(ctx context.Context, activity *activitypub.Activity) error

UpdateActivity updates an existing activity

func (*StorageAdapter) UpdateActor

func (s *StorageAdapter) UpdateActor(ctx context.Context, actor *activitypub.Actor) error

UpdateActor updates an existing actor

func (*StorageAdapter) UpdateActorKeys

func (s *StorageAdapter) UpdateActorKeys(ctx context.Context, username, publicKey, privateKey string) error

UpdateActorKeys updates the public and private keys for an actor

func (*StorageAdapter) UpdateAnnouncement

func (s *StorageAdapter) UpdateAnnouncement(ctx context.Context, announcement interface{}) error

UpdateAnnouncement updates an existing announcement

func (*StorageAdapter) UpdateBackgroundJobStatus

func (s *StorageAdapter) UpdateBackgroundJobStatus(ctx context.Context, jobID string, status interface{}, result interface{}) error

UpdateBackgroundJobStatus updates background job status

func (*StorageAdapter) UpdateCostAlert

func (s *StorageAdapter) UpdateCostAlert(ctx context.Context, alertID string, alert interface{}) error

UpdateCostAlert updates a cost alert

func (*StorageAdapter) UpdateFederationHealth

func (s *StorageAdapter) UpdateFederationHealth(ctx context.Context, domain string, isHealthy bool, responseTime time.Duration) error

UpdateFederationHealth updates federation health

func (*StorageAdapter) UpdateFederationInstance

func (s *StorageAdapter) UpdateFederationInstance(ctx context.Context, instance interface{}) error

UpdateFederationInstance updates a federation instance

func (*StorageAdapter) UpdateHashtag

func (s *StorageAdapter) UpdateHashtag(ctx context.Context, hashtag interface{}) error

UpdateHashtag updates an existing hashtag

func (*StorageAdapter) UpdateHashtagNotificationSettings

func (s *StorageAdapter) UpdateHashtagNotificationSettings(ctx context.Context, username, hashtagName string, settings *storage.HashtagNotificationSettings) error

UpdateHashtagNotificationSettings updates notification preferences.

func (*StorageAdapter) UpdateList

func (s *StorageAdapter) UpdateList(ctx context.Context, list interface{}) error

UpdateList updates an existing list

func (*StorageAdapter) UpdateMediaAttachment

func (s *StorageAdapter) UpdateMediaAttachment(ctx context.Context, media interface{}) error

UpdateMediaAttachment updates a media attachment

func (*StorageAdapter) UpdateMediaProcessingStatus

func (s *StorageAdapter) UpdateMediaProcessingStatus(ctx context.Context, mediaID string, status interface{}, metadata map[string]interface{}) error

UpdateMediaProcessingStatus updates media processing status

func (*StorageAdapter) UpdateMigrationProgress

func (s *StorageAdapter) UpdateMigrationProgress(_ context.Context, step string, progress int) error

UpdateMigrationProgress updates migration progress

func (*StorageAdapter) UpdateModerationDecision

func (s *StorageAdapter) UpdateModerationDecision(ctx context.Context, contentID string, decision interface{}) error

UpdateModerationDecision updates a moderation decision

func (*StorageAdapter) UpdateObject

func (s *StorageAdapter) UpdateObject(ctx context.Context, _ string, object interface{}) error

UpdateObject updates an existing object

func (*StorageAdapter) UpdatePassword

func (s *StorageAdapter) UpdatePassword(ctx context.Context, username, hashedPassword string) error

UpdatePassword updates user password hash

func (*StorageAdapter) UpdatePoll

func (s *StorageAdapter) UpdatePoll(ctx context.Context, poll interface{}) error

UpdatePoll updates an existing poll

func (*StorageAdapter) UpdateRelationshipStatus

func (s *StorageAdapter) UpdateRelationshipStatus(ctx context.Context, followerUsername, followingID string, status string) error

UpdateRelationshipStatus updates relationship status

func (*StorageAdapter) UpdateReport

func (s *StorageAdapter) UpdateReport(ctx context.Context, report interface{}) error

UpdateReport updates a moderation report

func (*StorageAdapter) UpdateScheduledStatus

func (s *StorageAdapter) UpdateScheduledStatus(ctx context.Context, scheduled interface{}) error

UpdateScheduledStatus updates a scheduled status

func (*StorageAdapter) UpdateSession

func (s *StorageAdapter) UpdateSession(ctx context.Context, session interface{}) error

UpdateSession updates an existing session

func (*StorageAdapter) UpdateUser

func (s *StorageAdapter) UpdateUser(ctx context.Context, user interface{}) error

UpdateUser updates an existing user

func (*StorageAdapter) UpdateUserPreferences

func (s *StorageAdapter) UpdateUserPreferences(ctx context.Context, username string, preferences interface{}) error

UpdateUserPreferences updates user preferences

func (*StorageAdapter) User

func (s *StorageAdapter) User() interface{}

User returns the User repository instance

func (*StorageAdapter) ValidateCredentials

func (s *StorageAdapter) ValidateCredentials(ctx context.Context, username, password string) (interface{}, error)

ValidateCredentials validates user login credentials

func (*StorageAdapter) ValidateToken

func (s *StorageAdapter) ValidateToken(ctx context.Context, token string) (interface{}, error)

ValidateToken validates an access token

func (*StorageAdapter) WebSocketCost

func (s *StorageAdapter) WebSocketCost() interface{}

WebSocketCost returns the WebSocketCost repository instance

type TTLModel

type TTLModel struct {
	StandardModel

	// TTL for automatic expiration
	TTL int64 `theorydb:"ttl" json:"ttl,omitempty"`
}

TTLModel extends StandardModel with TTL support

func (*TTLModel) SetTTL

func (m *TTLModel) SetTTL(duration time.Duration)

SetTTL sets the TTL value based on the provided duration from now

type TenantModel

type TenantModel struct {
	StandardModel

	// Tenant ID for multi-tenant applications
	TenantID string `theorydb:"index:gsi1,pk,attr:gsi1PK" json:"tenant_id"`
}

TenantModel extends StandardModel with tenant isolation

type Transaction

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

Transaction represents a DynamoDB transaction

func NewTransaction

func NewTransaction(client core.DB) *Transaction

NewTransaction creates a new transaction wrapper

func (*Transaction) ConditionCheck

func (t *Transaction) ConditionCheck(tableName string, key map[string]any, condition string, values ...any) error

ConditionCheck adds a condition check to the transaction The transaction will fail if the condition is not met

func (*Transaction) Delete

func (t *Transaction) Delete(item any) error

Delete adds a Delete operation to the transaction

func (*Transaction) Execute

func (t *Transaction) Execute(_ context.Context, fn TransactionFunc) error

Execute runs the provided function within a transaction If the function returns an error, the transaction is aborted Otherwise, the transaction is committed

func (*Transaction) Put

func (t *Transaction) Put(item any) error

Put adds a Put operation to the transaction

func (*Transaction) Update

func (t *Transaction) Update(item any) error

Update adds an Update operation to the transaction

type TransactionBuilder

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

TransactionBuilder provides a fluent interface for building transactions

func NewTransactionBuilder

func NewTransactionBuilder() *TransactionBuilder

NewTransactionBuilder creates a new transaction builder

func (*TransactionBuilder) Build

Build returns the operations and configuration

func (*TransactionBuilder) Clear

Clear clears all operations from the builder

func (*TransactionBuilder) ConditionCheck

func (tb *TransactionBuilder) ConditionCheck(tableName string, key map[string]any, condition string, values ...any) *TransactionBuilder

ConditionCheck adds a condition check to the transaction

func (*TransactionBuilder) Delete

func (tb *TransactionBuilder) Delete(item any) *TransactionBuilder

Delete adds a delete operation to the transaction

func (*TransactionBuilder) DeleteByKey

func (tb *TransactionBuilder) DeleteByKey(tableName string, key map[string]any) *TransactionBuilder

DeleteByKey adds a delete operation by key to the transaction

func (*TransactionBuilder) Execute

func (tb *TransactionBuilder) Execute(ctx context.Context, manager *TransactionManager) error

Execute executes the transaction using the provided manager

func (*TransactionBuilder) GetOperationCount

func (tb *TransactionBuilder) GetOperationCount() int

GetOperationCount returns the number of operations in the builder

func (*TransactionBuilder) Put

func (tb *TransactionBuilder) Put(item any) *TransactionBuilder

Put adds a put operation to the transaction

func (*TransactionBuilder) Update

func (tb *TransactionBuilder) Update(item any) *TransactionBuilder

Update adds an update operation to the transaction

func (*TransactionBuilder) UpdateWithExpression

func (tb *TransactionBuilder) UpdateWithExpression(item any, expr string, values ...any) *TransactionBuilder

UpdateWithExpression adds an update operation with expression to the transaction

func (*TransactionBuilder) WithBaseDelay

func (tb *TransactionBuilder) WithBaseDelay(delay time.Duration) *TransactionBuilder

WithBaseDelay sets the base delay for exponential backoff

func (*TransactionBuilder) WithConfig

WithConfig sets the transaction configuration

func (*TransactionBuilder) WithMaxRetries

func (tb *TransactionBuilder) WithMaxRetries(maxRetries int) *TransactionBuilder

WithMaxRetries sets the maximum number of retries

type TransactionConfig

type TransactionConfig struct {
	MaxRetries         int
	BaseDelay          time.Duration
	MaxDelay           time.Duration
	BackoffFactor      float64
	EnableCostTracking bool
}

TransactionConfig holds configuration for transaction execution

func DefaultTransactionConfig

func DefaultTransactionConfig() TransactionConfig

DefaultTransactionConfig returns the default transaction configuration

type TransactionFunc

type TransactionFunc func(tx *Transaction) error

TransactionFunc is a function that executes within a transaction

type TransactionManager

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

TransactionManager provides enhanced transaction management with retry logic and cost tracking

func NewTransactionManager

func NewTransactionManager(client core.DB, logger *zap.Logger) *TransactionManager

NewTransactionManager creates a new transaction manager

func NewTransactionManagerWithTracker

func NewTransactionManagerWithTracker(client core.DB, logger *zap.Logger, tracker *cost.Tracker) *TransactionManager

NewTransactionManagerWithTracker creates a new transaction manager with cost tracking

func (*TransactionManager) ExecuteWithRetry

func (tm *TransactionManager) ExecuteWithRetry(ctx context.Context, operations ...TransactionOperation) error

ExecuteWithRetry executes a transaction with default retry configuration

func (*TransactionManager) ExecuteWrite

func (tm *TransactionManager) ExecuteWrite(ctx context.Context, operations ...TransactionOperation) error

ExecuteWrite executes a transaction with the provided operations

func (*TransactionManager) ExecuteWriteWithConfig

func (tm *TransactionManager) ExecuteWriteWithConfig(ctx context.Context, config TransactionConfig, operations ...TransactionOperation) error

ExecuteWriteWithConfig executes a transaction with custom configuration

type TransactionOperation

type TransactionOperation struct {
	Type             OperationType
	Item             any
	Key              map[string]any
	UpdateExpression string
	Condition        string
	Values           []any
	TableName        string
}

TransactionOperation represents a single operation within a transaction

type TxOperations

type TxOperations interface {
	Put(item any) error
	Delete(item any) error
	Update(item any) error
	ConditionCheck(tableName string, key map[string]any, condition string, values ...any) error
}

TxOperations defines the operations that can be performed in a transaction

Directories

Path Synopsis
Package batch provides efficient batch processing capabilities for DynamoDB operations.
Package batch provides efficient batch processing capabilities for DynamoDB operations.
Package hooks provides lifecycle hook management for DynamORM model operations with cost tracking integration.
Package hooks provides lifecycle hook management for DynamORM model operations with cost tracking integration.
Package marshalers provides custom DynamoDB marshaling utilities with encryption support for sensitive data using DynamORM.
Package marshalers provides custom DynamoDB marshaling utilities with encryption support for sensitive data using DynamORM.
Package migrations defines constants and status values for DynamORM database migration management.
Package migrations defines constants and status values for DynamORM database migration management.
Package patterns provides soft delete functionality and patterns for DynamORM model operations.
Package patterns provides soft delete functionality and patterns for DynamORM model operations.
Package repositories provides batch operation repositories with cost tracking for DynamORM operations.
Package repositories provides batch operation repositories with cost tracking for DynamORM operations.
testing
Package testing provides test utilities and helpers for DynamORM repository testing with mock support.
Package testing provides test utilities and helpers for DynamORM repository testing with mock support.
Package stream provides DynamoDB stream event handlers for real-time data processing with TableTheory.
Package stream provides DynamoDB stream event handlers for real-time data processing with TableTheory.
Package validation provides validation rules and utilities for DynamORM model data integrity.
Package validation provides validation rules and utilities for DynamORM model data integrity.

Jump to

Keyboard shortcuts

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