Documentation
¶
Index ¶
- func AppGetMySQL[T any](a *App, name string, tableName string) (*db.MySQLTable[T], error)
- func AppGetPool[T any](a *App, name string, tableName string) (*db.Table[T], error)
- func AppGetTurso[T any](a *App, name string, tableName string) (*db.TursoTable[T], error)
- type App
- type AuthConfig
- type CORSConf
- type ConsumerDef
- type ContentSecurityConf
- type CryptionConf
- type DBConfig
- type DefaultHooks
- func (DefaultHooks[T]) AfterCreate(ctx context.Context, entity *T) error
- func (DefaultHooks[T]) AfterDelete(ctx context.Context, id any) error
- func (DefaultHooks[T]) AfterUpdate(ctx context.Context, entity *T) error
- func (DefaultHooks[T]) BeforeCreate(ctx context.Context, req T) (T, error)
- func (DefaultHooks[T]) BeforeDelete(ctx context.Context, id any) error
- func (DefaultHooks[T]) BeforeUpdate(ctx context.Context, id any, patch map[string]any) (map[string]any, error)
- type EndpointConf
- type FilterDef
- type GatewayConf
- type Hooks
- type ListConfig
- type NATSConfig
- type OpenAPIConf
- type PaginatedResponse
- type PoolConfig
- type ProducerDef
- type RealtimeConfig
- type RedisConfig
- type RouteConf
- type RouteMap
- type SSEDef
- type SSEHandler
- type SecurityConf
- type ServerConf
- type Service
- func (s *Service[T]) App() *fiber.App
- func (s *Service[T]) BuildOpenAPI() (*openapi3.T, error)
- func (s *Service[T]) Consume(stream string, durable string, ...) error
- func (s *Service[T]) NATS() *events.Conn
- func (s *Service[T]) Pool() *pgxpool.Pool
- func (s *Service[T]) Run() error
- func (s *Service[T]) RunWithContext(ctx context.Context) error
- func (s *Service[T]) Table() *db.Table[T]
- func (s *Service[T]) WithCustomRoutes(fn func(app *fiber.App)) *Service[T]
- func (s *Service[T]) WithHandlers(h map[string]func(ctx context.Context, data []byte) (events.AckAction, error)) *Service[T]
- func (s *Service[T]) WithHooks(hooks Hooks[T]) *Service[T]
- func (s *Service[T]) WithSSEHandlers(h map[string]SSEHandler) *Service[T]
- func (s *Service[T]) WithWSHandlers(h map[string]WSHandler) *Service[T]
- type ServiceConfig
- type ServiceDef
- type StaticDef
- type StreamDef
- type TelemetryConf
- type UpstreamDef
- type WSHandler
- type WebSocketDef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppGetMySQL ¶ added in v0.1.1
func AppGetPool ¶ added in v0.1.1
func AppGetTurso ¶ added in v0.1.1
Types ¶
type App ¶ added in v0.1.1
type App struct {
DB map[string]any
NATS map[string]*events.Conn
// contains filtered or unexported fields
}
type AuthConfig ¶ added in v0.1.1
type ConsumerDef ¶ added in v0.1.1
type ConsumerDef struct {
Stream string `json:"stream"`
Subject string `json:"subject,optional"`
Durable string `json:"durable"`
QueueGroup string `json:"queue_group,optional"`
Handler string `json:"handler"`
DeliverPolicy string `json:"deliver_policy,default=all"`
MaxDeliver int `json:"max_deliver,default=5"`
AckWait string `json:"ack_wait,default=30s"`
BackOff []string `json:"backoff,optional"`
PullBatch int `json:"pull_batch,default=10"`
PullMaxWait string `json:"pull_max_wait,default=5s"`
NakDelay string `json:"nak_delay,default=5s"`
}
type ContentSecurityConf ¶ added in v0.1.1
type CryptionConf ¶ added in v0.1.1
type DBConfig ¶
type DBConfig struct {
Name string `json:"name,optional"`
Driver string `json:"driver,optional"`
URL string `json:"url"`
Table string `json:"table,optional"`
Resource string `json:"resource,optional"`
Pool PoolConfig `json:"pool,optional"`
}
func (DBConfig) DriverDefaults ¶ added in v0.1.1
func (d DBConfig) DriverDefaults()
type DefaultHooks ¶
type DefaultHooks[T any] struct{}
func (DefaultHooks[T]) AfterCreate ¶
func (DefaultHooks[T]) AfterCreate(ctx context.Context, entity *T) error
func (DefaultHooks[T]) AfterDelete ¶
func (DefaultHooks[T]) AfterDelete(ctx context.Context, id any) error
func (DefaultHooks[T]) AfterUpdate ¶
func (DefaultHooks[T]) AfterUpdate(ctx context.Context, entity *T) error
func (DefaultHooks[T]) BeforeCreate ¶
func (DefaultHooks[T]) BeforeCreate(ctx context.Context, req T) (T, error)
func (DefaultHooks[T]) BeforeDelete ¶
func (DefaultHooks[T]) BeforeDelete(ctx context.Context, id any) error
type EndpointConf ¶ added in v0.1.1
type EndpointConf struct {
List ListConfig `json:"list,optional"`
}
type GatewayConf ¶ added in v0.1.1
type GatewayConf struct {
Enabled bool `json:"enabled"`
Port int `json:"port,optional"`
Upstreams []UpstreamDef `json:"upstreams,optional"`
}
type Hooks ¶ added in v0.1.1
type Hooks[T any] interface { BeforeCreate(ctx context.Context, req T) (T, error) AfterCreate(ctx context.Context, entity *T) error BeforeUpdate(ctx context.Context, id any, patch map[string]any) (map[string]any, error) AfterUpdate(ctx context.Context, entity *T) error BeforeDelete(ctx context.Context, id any) error AfterDelete(ctx context.Context, id any) error }
type ListConfig ¶ added in v0.1.1
type ListConfig struct {
PageSize int `json:"page_size,default=10"`
MaxPage int `json:"max_page_size,default=100"`
Sortable []string `json:"sortable,optional"`
Filterable []FilterDef `json:"filterable,optional"`
}
func (ListConfig) EffectivePageSize ¶ added in v0.1.1
func (l ListConfig) EffectivePageSize(size int) int
func (ListConfig) IsFilterable ¶ added in v0.1.1
func (l ListConfig) IsFilterable(col string) bool
func (ListConfig) IsSortable ¶ added in v0.1.1
func (l ListConfig) IsSortable(col string) bool
type NATSConfig ¶ added in v0.1.1
type NATSConfig struct {
Name string `json:"name,optional"`
URL string `json:"url"`
MaxReconnects int `json:"max_reconnects,default=10"`
ReconnectWait string `json:"reconnect_wait,default=2s"`
Timeout string `json:"timeout,default=5s"`
RetryOnFail bool `json:"retry_on_fail,default=true"`
Streams []StreamDef `json:"streams,optional"`
Consumers []ConsumerDef `json:"consumers,optional"`
Producers []ProducerDef `json:"producers,optional"`
}
type OpenAPIConf ¶
type PaginatedResponse ¶
type PoolConfig ¶ added in v0.1.1
type PoolConfig struct {
MaxConns int32 `json:"max_conns,default=10"`
MinConns int32 `json:"min_conns,default=2"`
MaxConnLifetime string `json:"max_conn_lifetime,optional"`
MaxConnIdleTime string `json:"max_conn_idle_time,optional"`
HealthCheckPeriod string `json:"health_check_period,default=1m"`
ReservedConns int32 `json:"reserved_conns,default=10"`
}
type ProducerDef ¶ added in v0.1.1
type RealtimeConfig ¶ added in v0.1.1
type RealtimeConfig struct {
SSE []SSEDef `json:"sse,optional"`
WebSocket []WebSocketDef `json:"websocket,optional"`
}
type RedisConfig ¶ added in v0.1.1
type SecurityConf ¶ added in v0.1.1
type SecurityConf struct {
ContentSecurity *ContentSecurityConf `json:"content_security,optional"`
Cryption *CryptionConf `json:"cryption,optional"`
}
type ServerConf ¶
type ServerConf struct {
Static []StaticDef `json:"static,optional"`
Host string `json:"host,default=0.0.0.0"`
Prefork bool `json:"prefork,optional"`
BodyLimit int `json:"body_limit,default=4194304"`
Timeout string `json:"timeout,default=30s"`
MaxConns int `json:"max_conns,default=1000"`
MaxBytes int `json:"max_bytes,default=4194304"`
MetricsPath string `json:"metrics_path,default=/metrics"`
HealthPath string `json:"health_path,default=/health"`
ShutdownTimeout string `json:"shutdown_timeout,default=10s"`
RecoverStack bool `json:"recover_stack,default=true"`
APIPrefix string `json:"api_prefix,default=/api/v1"`
CORS *CORSConf `json:"cors,optional"`
Routes []RouteConf `json:"routes,optional"`
}
type Service ¶
type Service[T any] struct { // contains filtered or unexported fields }
func (*Service[T]) BuildOpenAPI ¶ added in v0.1.1
func (*Service[T]) WithCustomRoutes ¶ added in v0.1.1
func (*Service[T]) WithHandlers ¶
func (*Service[T]) WithSSEHandlers ¶ added in v0.1.1
func (s *Service[T]) WithSSEHandlers(h map[string]SSEHandler) *Service[T]
type ServiceConfig ¶
type ServiceConfig struct {
Name string `json:"name"`
Port int `json:"port,default=8080"`
Health bool `json:"health,optional"`
DB DBConfig `json:"database,optional"`
NATS NATSConfig `json:"nats,optional"`
Auth AuthConfig `json:"auth,optional"`
Endpoints EndpointConf `json:"endpoints,optional"`
Realtime RealtimeConfig `json:"realtime,optional"`
Server ServerConf `json:"server,optional"`
Telemetry TelemetryConf `json:"telemetry,optional"`
Security SecurityConf `json:"security,optional"`
Gateway GatewayConf `json:"gateway,optional"`
OpenAPI OpenAPIConf `json:"openapi,optional"`
MultiDB []DBConfig `json:"databases,optional"`
MultiNATS []NATSConfig `json:"nats_list,optional"`
MultiRedis []RedisConfig `json:"redis,optional"`
Services []ServiceDef `json:"services,optional"`
}
func LoadConfig ¶
func LoadConfig(path string) (*ServiceConfig, error)
func (*ServiceConfig) Validate ¶ added in v0.1.1
func (c *ServiceConfig) Validate() error
type ServiceDef ¶ added in v0.1.1
type TelemetryConf ¶ added in v0.1.1
type UpstreamDef ¶ added in v0.1.1
type WebSocketDef ¶ added in v0.1.1
Click to show internal directories.
Click to hide internal directories.