storage

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxOpenConns    int           // Maximum number of open connections (default: 50)
	MaxIdleConns    int           // Maximum number of idle connections (default: 10)
	ConnMaxLifetime time.Duration // Maximum connection lifetime (default: 1 hour)
}

Config holds database connection pool configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default database configuration

type Writer

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

Writer handles writing events to PostgreSQL using pgx connection pool

func NewWriter

func NewWriter(connStr string) (*Writer, error)

NewWriter creates a new PostgreSQL writer with default configuration

func NewWriterWithConfig

func NewWriterWithConfig(connStr string, config *Config) (*Writer, error)

NewWriterWithConfig creates a new PostgreSQL writer with custom configuration

func (*Writer) Close

func (w *Writer) Close() error

Close closes the database connection pool

func (*Writer) GetPool

func (w *Writer) GetPool() *pgxpool.Pool

GetPool returns the underlying connection pool for advanced operations (e.g., partition management, custom queries)

func (*Writer) WriteAddedToCart

func (w *Writer) WriteAddedToCart(event *models.AddedToCart) error

WriteAddedToCart writes a added_to_cart event to the database

func (*Writer) WriteAddedToCartBatch

func (w *Writer) WriteAddedToCartBatch(events []*models.AddedToCart) error

WriteAddedToCartBatch writes multiple added_to_cart events to the database using COPY protocol

func (*Writer) WriteArticleShared

func (w *Writer) WriteArticleShared(event *models.ArticleShared) error

WriteArticleShared writes a article_shared event to the database

func (*Writer) WriteArticleSharedBatch

func (w *Writer) WriteArticleSharedBatch(events []*models.ArticleShared) error

WriteArticleSharedBatch writes multiple article_shared events to the database using COPY protocol

func (*Writer) WriteArticleViewed

func (w *Writer) WriteArticleViewed(event *models.ArticleViewed) error

WriteArticleViewed writes a article_viewed event to the database

func (*Writer) WriteArticleViewedBatch

func (w *Writer) WriteArticleViewedBatch(events []*models.ArticleViewed) error

WriteArticleViewedBatch writes multiple article_viewed events to the database using COPY protocol

func (*Writer) WriteCheckoutStarted

func (w *Writer) WriteCheckoutStarted(event *models.CheckoutStarted) error

WriteCheckoutStarted writes a checkout_started event to the database

func (*Writer) WriteCheckoutStartedBatch

func (w *Writer) WriteCheckoutStartedBatch(events []*models.CheckoutStarted) error

WriteCheckoutStartedBatch writes multiple checkout_started events to the database using COPY protocol

func (*Writer) WriteCommentPosted

func (w *Writer) WriteCommentPosted(event *models.CommentPosted) error

WriteCommentPosted writes a comment_posted event to the database

func (*Writer) WriteCommentPostedBatch

func (w *Writer) WriteCommentPostedBatch(events []*models.CommentPosted) error

WriteCommentPostedBatch writes multiple comment_posted events to the database using COPY protocol

func (*Writer) WriteNewsletterSubscribed

func (w *Writer) WriteNewsletterSubscribed(event *models.NewsletterSubscribed) error

WriteNewsletterSubscribed writes a newsletter_subscribed event to the database

func (*Writer) WriteNewsletterSubscribedBatch

func (w *Writer) WriteNewsletterSubscribedBatch(events []*models.NewsletterSubscribed) error

WriteNewsletterSubscribedBatch writes multiple newsletter_subscribed events to the database using COPY protocol

func (*Writer) WriteOrderCompleted

func (w *Writer) WriteOrderCompleted(event *models.OrderCompleted) error

WriteOrderCompleted writes a order_completed event to the database

func (*Writer) WriteOrderCompletedBatch

func (w *Writer) WriteOrderCompletedBatch(events []*models.OrderCompleted) error

WriteOrderCompletedBatch writes multiple order_completed events to the database using COPY protocol

func (*Writer) WritePageView

func (w *Writer) WritePageView(event *models.PageView) error

WritePageView writes a page_view event to the database

func (*Writer) WritePageViewBatch

func (w *Writer) WritePageViewBatch(events []*models.PageView) error

WritePageViewBatch writes multiple page_view events to the database using COPY protocol

func (*Writer) WriteProductViewed

func (w *Writer) WriteProductViewed(event *models.ProductViewed) error

WriteProductViewed writes a product_viewed event to the database

func (*Writer) WriteProductViewedBatch

func (w *Writer) WriteProductViewedBatch(events []*models.ProductViewed) error

WriteProductViewedBatch writes multiple product_viewed events to the database using COPY protocol

func (*Writer) WritePurchase

func (w *Writer) WritePurchase(event *models.Purchase) error

WritePurchase writes a purchase event to the database

func (*Writer) WritePurchaseBatch

func (w *Writer) WritePurchaseBatch(events []*models.Purchase) error

WritePurchaseBatch writes multiple purchase events to the database using COPY protocol

func (*Writer) WriteSearchPerformed

func (w *Writer) WriteSearchPerformed(event *models.SearchPerformed) error

WriteSearchPerformed writes a search_performed event to the database

func (*Writer) WriteSearchPerformedBatch

func (w *Writer) WriteSearchPerformedBatch(events []*models.SearchPerformed) error

WriteSearchPerformedBatch writes multiple search_performed events to the database using COPY protocol

func (*Writer) WriteUserSignup

func (w *Writer) WriteUserSignup(event *models.UserSignup) error

WriteUserSignup writes a user_signup event to the database

func (*Writer) WriteUserSignupBatch

func (w *Writer) WriteUserSignupBatch(events []*models.UserSignup) error

WriteUserSignupBatch writes multiple user_signup events to the database using COPY protocol

Jump to

Keyboard shortcuts

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