container

package
v0.0.0-...-d23b9d2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyticsStorePackage

func AnalyticsStorePackage(i *do.Injector)

AnalyticsStorePackage provides the analytics store for persisting events.

func ConsumerGroupPackage

func ConsumerGroupPackage(i *do.Injector)

ConsumerGroupPackage provides the consumer group with all registered consumers.

func HTTPPackage

func HTTPPackage(i *do.Injector)

HTTPPackage provides the router, API, and registers routes.

func LoggerPackage

func LoggerPackage(i *do.Injector)

LoggerPackage provides the zap logger.

func PostgresPackage

func PostgresPackage(i *do.Injector)

PostgresPackage provides the PostgreSQL connection pool.

func PublisherGroupPackage

func PublisherGroupPackage(i *do.Injector)

PublisherGroupPackage provides the publisher group for event publishing.

func RateLimitPackage

func RateLimitPackage(i *do.Injector)

RateLimitPackage provides the rate limit store.

func RedisPackage

func RedisPackage(i *do.Injector)

RedisPackage provides the Redis client.

func RepositoryPackage

func RepositoryPackage(i *do.Injector)

RepositoryPackage provides the URL repository with Redis caching over PostgreSQL.

Types

type Options

type Options struct {
	Port             int           `default:"8888"           help:"Port to listen on" short:"p"`
	CodeLength       int           `default:"8"              help:"Short code length" short:"c"`
	RedisAddr        string        `default:"localhost:6379" help:"Redis address"     short:"r"`
	DatabaseURL      string        `env:"DATABASE_URL"       help:"PostgreSQL URL"    required:""`
	RateLimitStore   string        `default:"memory"         env:"RATE_LIMIT_STORE"   help:"memory or redis"`
	CacheSize        int           `default:"1000"           env:"CACHE_SIZE"         help:"LRU cache size (0=off)"`
	CacheTTL         time.Duration `default:"1h"             env:"CACHE_TTL"          help:"Redis cache TTL"`
	LogFormat        string        `default:"console"        env:"LOG_FORMAT"         help:"console or json"`
	TopicURLCreated  string        `default:"url.created"    env:"TOPIC_URL_CREATED"  help:"URL created topic"`
	TopicURLAccessed string        `default:"url.accessed"   env:"TOPIC_URL_ACCESSED" help:"URL accessed topic"`
	ConsumerGroup    string        `default:"analytics"      env:"CONSUMER_GROUP"     help:"Consumer group name"`

	// Rate limit configuration per scope
	RateLimitGlobalPerDay   int64 `default:"1000000" env:"RATE_LIMIT_GLOBAL_DAY"   help:"Global requests per day"`
	RateLimitReadPerMinute  int64 `default:"100000"  env:"RATE_LIMIT_READ_MINUTE"  help:"Read requests per minute"`
	RateLimitWritePerMinute int64 `default:"10"      env:"RATE_LIMIT_WRITE_MINUTE" help:"Write requests per minute"`
	RateLimitWritePerHour   int64 `default:"100"     env:"RATE_LIMIT_WRITE_HOUR"   help:"Write requests per hour"`
	RateLimitWritePerDay    int64 `default:"500"     env:"RATE_LIMIT_WRITE_DAY"    help:"Write requests per day"`
}

type PostgresPool

type PostgresPool struct {
	*pgxpool.Pool
}

PostgresPool wraps pgxpool.Pool to implement Shutdownable for do.Injector.

func (*PostgresPool) Shutdown

func (p *PostgresPool) Shutdown() error

Shutdown implements do.Shutdownable.

type RedisClient

type RedisClient struct {
	*redis.Client
}

RedisClient wraps redis.Client to implement Shutdownable for do.Injector.

func (*RedisClient) Shutdown

func (r *RedisClient) Shutdown() error

Shutdown implements do.Shutdownable.

Jump to

Keyboard shortcuts

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