platform

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLogger

func InitLogger()

InitLogger configures zerolog. When LOG_FORMAT=pretty (or LOG_PRETTY=true), uses colorized console output for development. Otherwise outputs JSON for production/log aggregation.

func IsDuplicateKey

func IsDuplicateKey(err error) bool

IsDuplicateKey returns true if err is a Postgres unique-violation (SQLSTATE 23505).

func Migrate

func Migrate(db *sql.DB) error

func MigrateDown

func MigrateDown(db *sql.DB) error

func MigrateStatus

func MigrateStatus(db *sql.DB) error

func NewPool

func NewPool(ctx context.Context, databaseURL string) (*pgxpool.Pool, error)

func OpenDB

func OpenDB(databaseURL string) (*sql.DB, error)

func RequestLogger

func RequestLogger(next http.Handler) http.Handler

RequestLogger is a Chi-compatible middleware that logs every request using zerolog. Logs method, path, status, duration, and remote IP.

func RunMigrations

func RunMigrations(ctx context.Context, pool *pgxpool.Pool) error

Types

type Config

type Config struct {
	DatabaseURL   string
	StoragePath   string
	ListenAddr    string
	DisableSignup bool
	GitHubToken   string
}

Config holds all runtime configuration for the skael server.

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig reads configuration from environment variables. DATABASE_URL is required; returns an error if absent. STORAGE_PATH defaults to "./data/skills" (or "s3://bucket/prefix" for S3); LISTEN_ADDR defaults to ":8080". DISABLE_SIGNUP=true prevents new registrations.

type LocalStorage added in v0.5.0

type LocalStorage struct {
	BasePath string
}

LocalStorage provides local filesystem storage for skill archive files.

func NewLocalStorage added in v0.5.0

func NewLocalStorage(basePath string) (*LocalStorage, error)

NewLocalStorage creates a LocalStorage rooted at basePath, creating the directory if it does not already exist.

func (*LocalStorage) Delete added in v0.5.0

func (s *LocalStorage) Delete(name string) error

Delete removes the file stored under name (relative to BasePath).

func (*LocalStorage) Read added in v0.5.0

func (s *LocalStorage) Read(name string) (io.ReadCloser, error)

Read opens the file stored under name (relative to BasePath) for reading. The caller is responsible for closing the returned ReadCloser.

func (*LocalStorage) Write added in v0.5.0

func (s *LocalStorage) Write(name string, r io.Reader) (string, error)

Write stores the content from r under name (relative to BasePath). It uses an atomic write: content is first written to a .tmp file which is then renamed to the final destination, ensuring no partial files are visible. Returns the full path of the written file.

type S3Storage added in v0.5.0

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

S3Storage stores archives in any S3-compatible object store.

func (*S3Storage) Delete added in v0.5.0

func (s *S3Storage) Delete(name string) error

func (*S3Storage) Read added in v0.5.0

func (s *S3Storage) Read(name string) (io.ReadCloser, error)

func (*S3Storage) Write added in v0.5.0

func (s *S3Storage) Write(name string, r io.Reader) (string, error)

type Storage

type Storage interface {
	// Write stores r under name and returns the stored key (name).
	Write(name string, r io.Reader) (string, error)
	// Read opens the blob stored under name; caller closes the ReadCloser.
	Read(name string) (io.ReadCloser, error)
	// Delete removes the blob stored under name.
	Delete(name string) error
}

Storage abstracts archive blob storage (local filesystem or object storage). Names are relative keys, e.g. "code-review/abc123.tar.gz".

func NewStorageFromConfig added in v0.5.0

func NewStorageFromConfig(cfg *Config) (Storage, error)

NewStorageFromConfig builds the Storage backend selected by STORAGE_PATH: "s3://bucket/prefix" → S3; anything else → local filesystem.

Jump to

Keyboard shortcuts

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