Documentation
¶
Index ¶
- Constants
- Variables
- func AuthProxy(config *Config, chain Chain, requestInterceptor func(req *fasthttp.Request), ...) fasthttp.RequestHandler
- func BuildRpc(rpc Rpc) (err error)
- func ConvertRequestCtxToHTTPRequest(ctx *fasthttp.RequestCtx) (*http.Request, error)
- func CorsMiddleware(config *Config) fasthttp.RequestHandler
- func Debug(message string, v ...any)
- func Error(message string, v ...any)
- func ExecuteRpc(ctx Context, rpc Rpc) (any, error)
- func Fatal(message string, v ...any)
- func GetLogLevel() hclog.Level
- func GetTableName(model any) (tableName string)
- func GetValidRpcReturnNameDecl(pType RpcReturnDataType, returnAlias bool) (string, error)
- func Info(message string, v ...any)
- func MarshalRpcParamTag(paramTag *RpcParamTag) (string, error)
- func MarshallAndValidate(ctx *fasthttp.RequestCtx, controller any) error
- func NewGracefulListener(ln net.Listener, maxWaitTime time.Duration) net.Listener
- func NewRouter(config *Config) *router
- func Panic(message string)
- func RealtimeBroadcastHandler(ctx *fasthttp.RequestCtx, u *url.URL)
- func RequiredForMethodValidator(ctx context.Context, fl validator.FieldLevel) bool
- func RestProxy(appCtx Context, TableName string) error
- func RpcParamToGoType(dataType RpcParamDataType) string
- func RpcReturnToGoType(dataType RpcReturnDataType) string
- func Rule(name string) *rule
- func SetLogLevel(level hclog.Level)
- func SetRestProxyDoTimeout(...) func()
- func StorageProxy(appCtx Context, bucketName string, routePath string) error
- func Validate(ctx context.Context, payload any, requestValidators ...ValidatorFunc) error
- func Warning(message string, v ...any)
- func WebSocketHandler(ctx *fasthttp.RequestCtx, u *url.URL)
- type Acl
- func (a *Acl) BuildPolicies(schema, table string) (policies objects.Policies, err error)
- func (a *Acl) BuildStoragePolicies(bucketName string) (objects.Policies, error)
- func (a *Acl) Define(rr ...*rule) *Acl
- func (a *Acl) Enable() *Acl
- func (a *Acl) Forced() *Acl
- func (a *Acl) InitOnce(fn func())
- func (a *Acl) IsEnable() bool
- func (a *Acl) IsForced() bool
- type AclMode
- type BaseLibrary
- type BaseModule
- type Bucket
- type BucketBase
- type Chain
- type ColumnTag
- type Command
- type Config
- type Context
- type ContextKey
- type Controller
- type ControllerBase
- func (*ControllerBase) AfterAll(ctx Context) error
- func (*ControllerBase) AfterDelete(ctx Context) error
- func (*ControllerBase) AfterGet(ctx Context) error
- func (*ControllerBase) AfterHead(ctx Context) error
- func (*ControllerBase) AfterOptions(ctx Context) error
- func (*ControllerBase) AfterPatch(ctx Context) error
- func (*ControllerBase) AfterPost(ctx Context) error
- func (*ControllerBase) AfterPut(ctx Context) error
- func (*ControllerBase) BeforeAll(ctx Context) error
- func (*ControllerBase) BeforeDelete(ctx Context) error
- func (*ControllerBase) BeforeGet(ctx Context) error
- func (*ControllerBase) BeforeHead(ctx Context) error
- func (*ControllerBase) BeforeOptions(ctx Context) error
- func (*ControllerBase) BeforePatch(ctx Context) error
- func (*ControllerBase) BeforePost(ctx Context) error
- func (*ControllerBase) BeforePut(ctx Context) error
- func (*ControllerBase) Delete(ctx Context) error
- func (*ControllerBase) Get(ctx Context) error
- func (*ControllerBase) Head(ctx Context) error
- func (*ControllerBase) Options(ctx Context) error
- func (*ControllerBase) Patch(ctx Context) error
- func (*ControllerBase) Post(ctx Context) error
- func (*ControllerBase) Put(ctx Context) error
- type CorsOptions
- type Ctx
- func (c *Ctx) Config() *Config
- func (c *Ctx) Ctx() context.Context
- func (c *Ctx) ExecuteRpc(rpc Rpc) (any, error)
- func (c *Ctx) Get(key string) any
- func (c *Ctx) GetParam(key string) any
- func (c *Ctx) GetQuery(key string) string
- func (c *Ctx) HttpRequest(method string, url string, body []byte, headers map[string]string, ...) (response *http.Response, err error)
- func (c *Ctx) HttpRequestAndBind(method string, url string, body []byte, headers map[string]string, ...) error
- func (c *Ctx) NewJobCtx() (JobContext, error)
- func (c *Ctx) Publish(ctx context.Context, provider PubSubProviderType, topic string, message []byte) error
- func (c *Ctx) RegisterLibraries(key map[string]any)
- func (c *Ctx) RequestContext() *fasthttp.RequestCtx
- func (c *Ctx) ResolveLibrary(key any) error
- func (c *Ctx) SendError(message string) error
- func (c *Ctx) SendErrorWithCode(statusCode int, err error) error
- func (c *Ctx) SendJson(data any) error
- func (c *Ctx) SendRpc(rpc Rpc) error
- func (c *Ctx) Set(key string, value any)
- func (c *Ctx) SetCtx(ctx context.Context)
- func (c *Ctx) SetJobChan(jobChan chan JobParams)
- func (c *Ctx) SetSpan(span trace.Span)
- func (c *Ctx) Span() trace.Span
- func (c *Ctx) Tracer() trace.Tracer
- func (c *Ctx) Write(data []byte)
- func (c *Ctx) WriteError(err error)
- type DefaultWebSocketDialer
- type DeploymentTarget
- type ErrorResponse
- type GooglePubSubProvider
- func (a *GooglePubSubProvider) CreateSubscription(handler SubscriberHandler) error
- func (a *GooglePubSubProvider) Publish(ctx context.Context, topic string, message []byte) error
- func (a *GooglePubSubProvider) Serve(config *Config, handler SubscriberHandler) (fasthttp.RequestHandler, error)
- func (a *GooglePubSubProvider) StartListen(handlers []SubscriberHandler) error
- func (a *GooglePubSubProvider) StopListen() error
- type GracefulListener
- type HealthController
- type HealthRequest
- type HealthResponse
- type Job
- type JobBase
- func (j *JobBase) After(ctx JobContext, jobID uuid.UUID, jobName string)
- func (j *JobBase) AfterErr(ctx JobContext, jobID uuid.UUID, jobName string, err error)
- func (j *JobBase) Before(ctx JobContext, jobID uuid.UUID, jobName string)
- func (j *JobBase) Duration() JobDuration
- func (j *JobBase) Task(ctx JobContext) error
- type JobContext
- type JobData
- type JobDuration
- type JobParams
- type JoinTag
- type LegacySubscriberConsumer
- type Library
- type MiddlewareFn
- type Mode
- type ModelBase
- type Module
- type PubSub
- type PubSubManager
- func (s *PubSubManager) GetHandlerCount() int
- func (s *PubSubManager) Handlers() []SubscriberHandler
- func (s *PubSubManager) Listen()
- func (s *PubSubManager) Publish(ctx context.Context, provider PubSubProviderType, topic string, message []byte) error
- func (s *PubSubManager) Register(handler SubscriberHandler)
- func (s *PubSubManager) Serve(handler SubscriberHandler) (fasthttp.RequestHandler, error)
- func (s *PubSubManager) SetConfig(cfg *Config)
- func (s *PubSubManager) SetProvider(providerType PubSubProviderType, provider PubSubProvider)
- type PubSubProvider
- type PubSubProviderType
- type PushSubscriptionDatadeprecated
- type PushSubscriptionMessage
- type RealtimeChannelType
- type RelationType
- type RestController
- func (rc RestController) AfterAll(ctx Context) error
- func (rc RestController) AfterDelete(ctx Context) error
- func (rc RestController) AfterGet(ctx Context) error
- func (rc RestController) AfterHead(ctx Context) error
- func (rc RestController) AfterOptions(ctx Context) error
- func (rc RestController) AfterPatch(ctx Context) error
- func (rc RestController) AfterPost(ctx Context) error
- func (rc RestController) AfterPut(ctx Context) error
- func (rc RestController) BeforeAll(ctx Context) error
- func (rc RestController) BeforeDelete(ctx Context) error
- func (rc RestController) BeforeGet(ctx Context) error
- func (rc RestController) BeforeHead(ctx Context) error
- func (rc RestController) BeforeOptions(ctx Context) error
- func (rc RestController) BeforePatch(ctx Context) error
- func (rc RestController) BeforePost(ctx Context) error
- func (rc RestController) BeforePut(ctx Context) error
- func (rc RestController) Delete(ctx Context) error
- func (rc RestController) Get(ctx Context) error
- func (rc RestController) Head(ctx Context) error
- func (rc RestController) Options(ctx Context) error
- func (rc RestController) Patch(ctx Context) error
- func (rc RestController) Post(ctx Context) error
- func (rc RestController) Put(ctx Context) error
- type Role
- type RoleBase
- func (r *RoleBase) CanBypassRls() bool
- func (r *RoleBase) CanCreateDB() bool
- func (r *RoleBase) CanCreateRole() bool
- func (r *RoleBase) CanLogin() bool
- func (r *RoleBase) ConnectionLimit() int
- func (r *RoleBase) InheritRoles() []Role
- func (r *RoleBase) IsInheritRole() bool
- func (r *RoleBase) ValidUntil() *objects.SupabaseTime
- type Route
- type RouteHandlerFn
- type RouteType
- type Rpc
- type RpcBase
- func (r *RpcBase) BindModel(model any, alias string) Rpc
- func (r *RpcBase) BindModels()
- func (r *RpcBase) GetBehavior() RpcBehaviorType
- func (r *RpcBase) GetCompleteStmt() string
- func (r *RpcBase) GetLanguage() string
- func (r *RpcBase) GetModels() map[string]RpcModel
- func (r *RpcBase) GetName() string
- func (r *RpcBase) GetParams() []RpcParam
- func (r *RpcBase) GetRawDefinition() (d string)
- func (r *RpcBase) GetReturnType() (rt RpcReturnDataType)
- func (r *RpcBase) GetReturnTypeStmt() string
- func (r *RpcBase) GetSchema() string
- func (r *RpcBase) GetSecurity() RpcSecurityType
- func (r *RpcBase) SetBehavior(behavior RpcBehaviorType)
- func (r *RpcBase) SetCompleteStmt(stmt string)
- func (r *RpcBase) SetLanguage(language string)
- func (r *RpcBase) SetName(name string)
- func (r *RpcBase) SetParams(params []RpcParam)
- func (r *RpcBase) SetRawDefinition(definition string)
- func (r *RpcBase) SetReturnType(returnType RpcReturnDataType)
- func (r *RpcBase) SetReturnTypeStmt(returnTypeStmt string)
- func (r *RpcBase) SetSchema(schema string)
- func (r *RpcBase) SetSecurity(security RpcSecurityType)
- func (r *RpcBase) UseParamPrefix() bool
- type RpcBehaviorType
- type RpcModel
- type RpcParam
- type RpcParamDataType
- type RpcParamKV
- type RpcParamMap
- type RpcParamTag
- type RpcParams
- type RpcReturnDataType
- type RpcSecurityType
- type ScheduleStatus
- type Scheduler
- type SchedulerServer
- type Server
- func (s *Server) ConfigureLogLevel()
- func (s *Server) RegisterJobs(jobs ...Job)
- func (s *Server) RegisterLibs(libs ...func(config *Config) any)
- func (s *Server) RegisterModules(module Module)
- func (s *Server) RegisterRoute(routes []*Route)
- func (s *Server) RegisterSubscribers(ss ...SubscriberHandler)
- func (s *Server) Run()
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Use(middleware MiddlewareFn)
- type StorageController
- func (rc StorageController) AfterAll(ctx Context) error
- func (rc StorageController) AfterDelete(ctx Context) error
- func (rc StorageController) AfterGet(ctx Context) error
- func (rc StorageController) AfterHead(ctx Context) error
- func (rc StorageController) AfterOptions(ctx Context) error
- func (rc StorageController) AfterPatch(ctx Context) error
- func (rc StorageController) AfterPost(ctx Context) error
- func (rc StorageController) AfterPut(ctx Context) error
- func (rc StorageController) BeforeAll(ctx Context) error
- func (rc StorageController) BeforeDelete(ctx Context) error
- func (rc StorageController) BeforeGet(ctx Context) error
- func (rc StorageController) BeforeHead(ctx Context) error
- func (rc StorageController) BeforeOptions(ctx Context) error
- func (rc StorageController) BeforePatch(ctx Context) error
- func (rc StorageController) BeforePost(ctx Context) error
- func (rc StorageController) BeforePut(ctx Context) error
- func (rc StorageController) Delete(ctx Context) error
- func (rc StorageController) Get(ctx Context) error
- func (rc StorageController) Head(ctx Context) error
- func (rc StorageController) Options(ctx Context) error
- func (rc StorageController) Patch(ctx Context) error
- func (rc StorageController) Post(ctx Context) error
- func (rc StorageController) Put(ctx Context) error
- type SubscriberBase
- func (s *SubscriberBase) AutoAck() bool
- func (s *SubscriberBase) ChannelType() RealtimeChannelType
- func (s *SubscriberBase) Consume(ctx SubscriberContext, message SubscriberMessage) error
- func (s *SubscriberBase) EventFilter() string
- func (s *SubscriberBase) Name() string
- func (s *SubscriberBase) Provider() PubSubProviderType
- func (s *SubscriberBase) PushEndpoint() string
- func (s *SubscriberBase) Schema() string
- func (s *SubscriberBase) Subscription() string
- func (s *SubscriberBase) SubscriptionType() SubscriptionType
- func (s *SubscriberBase) Table() string
- func (s *SubscriberBase) Topic() string
- type SubscriberContext
- type SubscriberHandler
- type SubscriberMessage
- type SubscriptionType
- type SupabaseRealtimeProvider
- func (a *SupabaseRealtimeProvider) CreateSubscription(handler SubscriberHandler) error
- func (a *SupabaseRealtimeProvider) Publish(ctx context.Context, topic string, message []byte) error
- func (a *SupabaseRealtimeProvider) Serve(config *Config, handler SubscriberHandler) (fasthttp.RequestHandler, error)
- func (a *SupabaseRealtimeProvider) StartListen(handlers []SubscriberHandler) error
- func (a *SupabaseRealtimeProvider) StopListen() error
- type TokenType
- type Type
- type TypeBase
- func (*TypeBase) Attributes() []objects.TypeAttribute
- func (*TypeBase) Comment() *string
- func (*TypeBase) Enums() []string
- func (*TypeBase) Format() string
- func (t *TypeBase) GetValue() any
- func (t TypeBase) MarshalJSON() ([]byte, error)
- func (*TypeBase) Name() string
- func (*TypeBase) Schema() string
- func (t *TypeBase) SetValue(v any)
- func (t *TypeBase) String() string
- func (t *TypeBase) UnmarshalJSON(data []byte) error
- type ValidatorFunc
- type WithValidator
Constants ¶
const ( DefaultRoleValidUntilLayout = "2006-01-02" DefaultRoleConnectionLimit = 60 )
const ( RpcBehaviorVolatile RpcBehaviorType = "VOLATILE" RpcBehaviorStable RpcBehaviorType = "STABLE" RpcBehaviorImmutable RpcBehaviorType = "IMMUTABLE" RpcSecurityTypeDefiner RpcSecurityType = "DEFINER" RpcSecurityTypeInvoker RpcSecurityType = "INVOKER" RpcTemplate = `` /* 178-byte string literal not displayed */ )
const (
DefaultTypeSchema = "public"
)
const SubscriptionPrefixEndpoint = "pubsub-endpoint"
Variables ¶
var ( DefaultRpcParamPrefix = "in_" DefaultRpcSchema = "public" )
var ControllerLogger = logger.HcLog().Named("raiden.controller")
var MiddlewareLogger = logger.HcLog().Named("raiden.middleware")
var PubSubLogger = logger.HcLog().Named("raiden.pubsub")
var RouterLogger = logger.HcLog().Named("raiden.router")
var RpcLogger = logger.HcLog().Named("raiden.rpc")
var SchedulerLogger = logger.HcLog().Named("raiden.scheduler")
var ServerLogger = logger.HcLog().Named("raiden.server")
Functions ¶
func ConvertRequestCtxToHTTPRequest ¶
func ConvertRequestCtxToHTTPRequest(ctx *fasthttp.RequestCtx) (*http.Request, error)
func CorsMiddleware ¶
func CorsMiddleware(config *Config) fasthttp.RequestHandler
func GetLogLevel ¶ added in v1.0.0
func GetTableName ¶
func GetValidRpcReturnNameDecl ¶
func GetValidRpcReturnNameDecl(pType RpcReturnDataType, returnAlias bool) (string, error)
func MarshalRpcParamTag ¶
func MarshalRpcParamTag(paramTag *RpcParamTag) (string, error)
func MarshallAndValidate ¶
func MarshallAndValidate(ctx *fasthttp.RequestCtx, controller any) error
Marshall request data (path param, query and body data) to Payload data in actual controller
Example :
type Request {
Search string `query:"q"`
Resource string `path:"resource" validate:"required"`
}
Controller {
raiden.ControllerBase
Payload *Request
}
Example Request : GET /hello/{resource}?q="some-resource"
base on example above this code will auto marshall data from fasthttp.Request to Request struct and validate all data is appropriate base on validate tag
func NewGracefulListener ¶
NewGracefulListener wraps the given listener into 'graceful shutdown' listener.
func RealtimeBroadcastHandler ¶
func RealtimeBroadcastHandler(ctx *fasthttp.RequestCtx, u *url.URL)
func RequiredForMethodValidator ¶ added in v1.0.0
func RequiredForMethodValidator(ctx context.Context, fl validator.FieldLevel) bool
func RpcParamToGoType ¶
func RpcParamToGoType(dataType RpcParamDataType) string
func RpcReturnToGoType ¶
func RpcReturnToGoType(dataType RpcReturnDataType) string
func SetLogLevel ¶
func SetRestProxyDoTimeout ¶ added in v1.0.0
func SetRestProxyDoTimeout(fn func(req *fasthttp.Request, resp *fasthttp.Response, timeout time.Duration) error) func()
SetRestProxyDoTimeout overrides the default request executor; returns a restore function.
func Validate ¶
func Validate(ctx context.Context, payload any, requestValidators ...ValidatorFunc) error
validate payload
func WebSocketHandler ¶
func WebSocketHandler(ctx *fasthttp.RequestCtx, u *url.URL)
Types ¶
type Acl ¶
type Acl struct {
// New Handle Acl
Schema string
Table string
// contains filtered or unexported fields
}
func (*Acl) BuildPolicies ¶ added in v1.0.0
func (*Acl) BuildStoragePolicies ¶ added in v1.0.0
type BaseLibrary ¶ added in v1.0.0
type BaseLibrary struct{}
func (*BaseLibrary) IsLongRunning ¶ added in v1.0.0
func (b *BaseLibrary) IsLongRunning() bool
type BaseModule ¶ added in v1.0.0
type BaseModule struct{}
type BucketBase ¶
type BucketBase struct{}
func (*BucketBase) AllowedMimeTypes ¶
func (b *BucketBase) AllowedMimeTypes() []string
func (*BucketBase) AvifAutoDetection ¶
func (b *BucketBase) AvifAutoDetection() bool
func (*BucketBase) FileSizeLimit ¶
func (b *BucketBase) FileSizeLimit() int
func (*BucketBase) Public ¶
func (b *BucketBase) Public() bool
type Chain ¶
type Chain interface {
Append(middlewares ...MiddlewareFn) Chain
Prepend(middlewares ...MiddlewareFn) Chain
Then(route *Route, config *Config, tracer trace.Tracer, jobChan chan JobParams, pubSub PubSub, httpMethod string, lib map[string]any) fasthttp.RequestHandler
ServeFsHandle(cfg *Config, fsHandle fasthttp.RequestHandler) fasthttp.RequestHandler
}
Chain defines a chain of middleware.
func NewChain ¶
func NewChain(middlewares ...MiddlewareFn) Chain
This is a modified version of https://github.com/zeromicro/go-zero/blob/master/rest/chain/chain.go New creates a new Chain, memorizing the given list of middleware middlewares. New serves no other function, middlewares are only called upon a call to Then() or ThenFunc().
type ColumnTag ¶
type ColumnTag struct {
Name string
Type string
PrimaryKey bool
AutoIncrement bool
Nullable bool
Default any
Unique bool
Index bool
}
definition of column tag, example : column:"name:id;type:bigint;primaryKey;autoIncrement;nullable:false;unique;default:now()"
func UnmarshalColumnTag ¶
type Command ¶ added in v1.0.0
type Command string
func (Command) ToSupabaseCommand ¶ added in v1.0.0
func (m Command) ToSupabaseCommand() objects.PolicyCommand
type Config ¶
type Config struct {
AccessToken string `mapstructure:"ACCESS_TOKEN"`
AnonKey string `mapstructure:"ANON_KEY"`
AllowedTables string `mapstructure:"ALLOWED_TABLES"`
BreakerEnable bool `mapstructure:"BREAKER_ENABLE"`
CorsAllowedOrigins string `mapstructure:"CORS_ALLOWED_ORIGINS"`
CorsAllowedMethods string `mapstructure:"CORS_ALLOWED_METHODS"`
CorsAllowedHeaders string `mapstructure:"CORS_ALLOWED_HEADERS"`
CorsAllowCredentials bool `mapstructure:"CORS_ALLOWED_CREDENTIALS"`
DeploymentTarget DeploymentTarget `mapstructure:"DEPLOYMENT_TARGET"`
Environment string `mapstructure:"ENVIRONMENT"`
GoogleProjectId string `mapstructure:"GOOGLE_PROJECT_ID"`
GoogleSaPath string `mapstructure:"GOOGLE_SA_PATH"`
JwtToken string `mapstructure:"JWT_TOKEN"`
JwtSecret string `mapstructure:"JWT_SECRET"`
LogLevel string `mapstructure:"LOG_LEVEL"`
MaxServerRequestBodySize int `mapstructure:"MAX_SERVER_REQUEST_BODY_SIZE"`
Mode Mode `mapstructure:"MODE"`
PgMetaUrl string `mapstructure:"PG_META_URL"`
PostgRestUrl string `mapstructure:"POSTGREST_URL"`
ProjectId string `mapstructure:"PROJECT_ID"`
ProjectName string `mapstructure:"PROJECT_NAME"`
ServiceKey string `mapstructure:"SERVICE_KEY"`
ServerHost string `mapstructure:"SERVER_HOST"`
ServerPort string `mapstructure:"SERVER_PORT"`
ServerDns string `mapstructure:"SERVER_DNS"`
SupabaseApiUrl string `mapstructure:"SUPABASE_API_URL"`
SupabaseApiBasePath string `mapstructure:"SUPABASE_API_BASE_PATH"`
SupabaseApiToken string `mapstructure:"SUPABASE_API_TOKEN"`
SupabaseApiTokenType string `mapstructure:"SUPABASE_API_TOKEN_TYPE"`
SupabasePublicUrl string `mapstructure:"SUPABASE_PUBLIC_URL"`
ScheduleStatus ScheduleStatus `mapstructure:"SCHEDULE_STATUS"`
TraceEnable bool `mapstructure:"TRACE_ENABLE"`
TraceCollector string `mapstructure:"TRACE_COLLECTOR"`
TraceCollectorEndpoint string `mapstructure:"TRACE_COLLECTOR_ENDPOINT"`
Version string `mapstructure:"VERSION"`
}
func LoadConfig ¶
The function `LoadConfig` loads a configuration file based on the provided path or uses default values if no path is provided.
func (*Config) GetFloat64 ¶
func (*Config) GetIntSlice ¶
func (*Config) GetStringSlice ¶
type Context ¶
type Context interface {
Ctx() context.Context
SetCtx(ctx context.Context)
Config() *Config
SendRpc(Rpc) error
ExecuteRpc(Rpc) (any, error)
SendJson(data any) error
SendError(message string) error
SendErrorWithCode(statusCode int, err error) error
RequestContext() *fasthttp.RequestCtx
Span() trace.Span
SetSpan(span trace.Span)
Tracer() trace.Tracer
NewJobCtx() (JobContext, error)
Write(data []byte)
WriteError(err error)
Set(key string, value any)
Get(key string) any
GetParam(key string) any
GetQuery(key string) string
Publish(ctx context.Context, provider PubSubProviderType, topic string, message []byte) error
HttpRequest(method string, url string, body []byte, headers map[string]string, timeout time.Duration) (*http.Response, error)
HttpRequestAndBind(method string, url string, body []byte, headers map[string]string, timeout time.Duration, response any) error
ResolveLibrary(key any) error
RegisterLibraries(key map[string]any)
}
The `Context` interface defines a set of methods that can be implemented by a struct to provide a context for handling HTTP requests in the Raiden framework.
type ContextKey ¶ added in v1.0.0
type ContextKey string
const MethodContextKey ContextKey = "method"
type Controller ¶
type Controller interface {
BeforeAll(ctx Context) error
AfterAll(ctx Context) error
AfterGet(ctx Context) error
BeforeGet(ctx Context) error
Get(ctx Context) error
AfterPost(ctx Context) error
BeforePost(ctx Context) error
Post(ctx Context) error
AfterPut(ctx Context) error
BeforePut(ctx Context) error
Put(ctx Context) error
AfterPatch(ctx Context) error
BeforePatch(ctx Context) error
Patch(ctx Context) error
AfterDelete(ctx Context) error
BeforeDelete(ctx Context) error
Delete(ctx Context) error
AfterOptions(ctx Context) error
BeforeOptions(ctx Context) error
Options(ctx Context) error
AfterHead(ctx Context) error
BeforeHead(ctx Context) error
Head(ctx Context) error
}
The `Controller` interface defines a set of methods that a controller in the Raiden framework should implement. These methods correspond to different HTTP methods (GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD) and are used to handle incoming requests and generate responses. Each method has a "Before" and "After" counterpart, which can be used to perform pre-processing and post-processing tasks respectively.
type ControllerBase ¶
type ControllerBase struct{}
The `ControllerBase` struct is a base struct that implements the `Controller` interface. It provides default implementations for all the methods defined in the interface. These default implementations return a `NotImplemented` error, indicating that the corresponding handler method is not implemented in the actual controller. The actual controller can embed the `ControllerBase` struct and override the methods as needed.
func (*ControllerBase) AfterAll ¶
func (*ControllerBase) AfterAll(ctx Context) error
func (*ControllerBase) AfterDelete ¶
func (*ControllerBase) AfterDelete(ctx Context) error
func (*ControllerBase) AfterGet ¶
func (*ControllerBase) AfterGet(ctx Context) error
func (*ControllerBase) AfterHead ¶
func (*ControllerBase) AfterHead(ctx Context) error
func (*ControllerBase) AfterOptions ¶
func (*ControllerBase) AfterOptions(ctx Context) error
func (*ControllerBase) AfterPatch ¶
func (*ControllerBase) AfterPatch(ctx Context) error
func (*ControllerBase) AfterPost ¶
func (*ControllerBase) AfterPost(ctx Context) error
func (*ControllerBase) AfterPut ¶
func (*ControllerBase) AfterPut(ctx Context) error
func (*ControllerBase) BeforeAll ¶
func (*ControllerBase) BeforeAll(ctx Context) error
func (*ControllerBase) BeforeDelete ¶
func (*ControllerBase) BeforeDelete(ctx Context) error
func (*ControllerBase) BeforeGet ¶
func (*ControllerBase) BeforeGet(ctx Context) error
func (*ControllerBase) BeforeHead ¶
func (*ControllerBase) BeforeHead(ctx Context) error
func (*ControllerBase) BeforeOptions ¶
func (*ControllerBase) BeforeOptions(ctx Context) error
func (*ControllerBase) BeforePatch ¶
func (*ControllerBase) BeforePatch(ctx Context) error
func (*ControllerBase) BeforePost ¶
func (*ControllerBase) BeforePost(ctx Context) error
func (*ControllerBase) BeforePut ¶
func (*ControllerBase) BeforePut(ctx Context) error
func (*ControllerBase) Delete ¶
func (*ControllerBase) Delete(ctx Context) error
func (*ControllerBase) Get ¶
func (*ControllerBase) Get(ctx Context) error
func (*ControllerBase) Head ¶
func (*ControllerBase) Head(ctx Context) error
func (*ControllerBase) Options ¶
func (*ControllerBase) Options(ctx Context) error
func (*ControllerBase) Patch ¶
func (*ControllerBase) Patch(ctx Context) error
func (*ControllerBase) Post ¶
func (*ControllerBase) Post(ctx Context) error
func (*ControllerBase) Put ¶
func (*ControllerBase) Put(ctx Context) error
type CorsOptions ¶
type CorsOptions struct {
AllowedOrigins []string
AllowedMethods []string
AllowedHeaders []string
AllowCredentials bool
OptionsPassthrough bool
}
Handle cors
type Ctx ¶
type Ctx struct {
context.Context
*fasthttp.RequestCtx
// contains filtered or unexported fields
}
The `Ctx` struct is a struct that implements the `Context` interface in the Raiden framework. It embeds the `context.Context` and `*fasthttp.RequestCtx` types, which provide the context and request information for handling HTTP requests. Additionally, it has fields for storing the configuration (`config`), span (`span`), and tracer (`tracer`) for tracing and monitoring purposes.
func (*Ctx) HttpRequest ¶ added in v1.0.0
func (*Ctx) HttpRequestAndBind ¶ added in v1.0.0
func (*Ctx) NewJobCtx ¶
func (c *Ctx) NewJobCtx() (JobContext, error)
func (*Ctx) RegisterLibraries ¶ added in v1.0.0
func (*Ctx) RequestContext ¶
func (c *Ctx) RequestContext() *fasthttp.RequestCtx
func (*Ctx) ResolveLibrary ¶ added in v1.0.0
func (*Ctx) SendJson ¶
The `SendJson` function is a method of the `Ctx` struct in the Raiden framework. It is responsible for sending a JSON response to the client.
func (*Ctx) SetJobChan ¶ added in v1.0.0
func (*Ctx) Write ¶
The `Write` function is a method of the `Ctx` struct in the Raiden framework. It is responsible for writing the response body to the HTTP response.
func (*Ctx) WriteError ¶
The `WriteError` function is a method of the `Ctx` struct in the Raiden framework. It is responsible for writing an error response to the HTTP response body.
type DefaultWebSocketDialer ¶ added in v1.0.0
type DefaultWebSocketDialer struct{}
DefaultWebSocketDialer wraps github.com/fasthttp/websocket for production use.
func (*DefaultWebSocketDialer) Dial ¶ added in v1.0.0
func (d *DefaultWebSocketDialer) Dial(wsUrl string) (supabasepubsub.WebSocketConn, error)
type DeploymentTarget ¶
type DeploymentTarget string
const ( DeploymentTargetCloud DeploymentTarget = "cloud" DeploymentTargetSelfHosted DeploymentTarget = "self_hosted" )
type ErrorResponse ¶
type ErrorResponse struct {
StatusCode int `json:"-"`
Code string `json:"code,omitempty"`
Details any `json:"details,omitempty"`
Hint string `json:"hint,omitempty"`
Message string `json:"message"`
}
func (*ErrorResponse) Error ¶
func (err *ErrorResponse) Error() string
type GooglePubSubProvider ¶ added in v1.0.0
type GooglePubSubProvider struct {
Config *Config
Provider *googlepubsub.Provider
}
----- Google Provider Adapter ----- GooglePubSubProvider adapts google.Provider to the PubSubProvider interface.
func (*GooglePubSubProvider) CreateSubscription ¶ added in v1.0.0
func (a *GooglePubSubProvider) CreateSubscription(handler SubscriberHandler) error
func (*GooglePubSubProvider) Serve ¶ added in v1.0.0
func (a *GooglePubSubProvider) Serve(config *Config, handler SubscriberHandler) (fasthttp.RequestHandler, error)
func (*GooglePubSubProvider) StartListen ¶ added in v1.0.0
func (a *GooglePubSubProvider) StartListen(handlers []SubscriberHandler) error
func (*GooglePubSubProvider) StopListen ¶ added in v1.0.0
func (a *GooglePubSubProvider) StopListen() error
type GracefulListener ¶
type GracefulListener struct {
// contains filtered or unexported fields
}
--- graceful shutdown listener ----
func (*GracefulListener) Accept ¶
func (ln *GracefulListener) Accept() (net.Conn, error)
Accept creates a conn
func (*GracefulListener) Addr ¶
func (ln *GracefulListener) Addr() net.Addr
Addr returns the listen address
func (*GracefulListener) Close ¶
func (ln *GracefulListener) Close() error
Close closes the inner listener and waits until all the pending open connections are closed before returning.
type HealthController ¶
type HealthController struct {
ControllerBase
Payload *HealthRequest
Result HealthResponse
}
func (*HealthController) Get ¶
func (c *HealthController) Get(ctx Context) error
type HealthRequest ¶
type HealthRequest struct{}
type HealthResponse ¶
type HealthResponse struct {
Message string `json:"message"`
}
type Job ¶
type Job interface {
Name() string
Duration() JobDuration
After(ctx JobContext, jobID uuid.UUID, jobName string)
AfterErr(ctx JobContext, jobID uuid.UUID, jobName string, err error)
Before(ctx JobContext, jobID uuid.UUID, jobName string)
Task(ctx JobContext) error
}
type JobBase ¶
type JobBase struct{}
func (*JobBase) Duration ¶
func (j *JobBase) Duration() JobDuration
func (*JobBase) Task ¶
func (j *JobBase) Task(ctx JobContext) error
type JobContext ¶
type JobContext interface {
context.Context
SetContext(c context.Context)
Config() *Config
RunJob(JobParams)
Get(key string) any
Set(key string, value any)
IsDataExist(key string) bool
Span() trace.Span
SetSpan(span trace.Span)
Publish(ctx context.Context, provider PubSubProviderType, topic string, message []byte) error
}
---- Scheduler context
type JoinTag ¶
type JoinTag struct {
JoinType RelationType
PrimaryKey string
ForeignKey string
Through string
SourcePrimaryKey string
SourceForeignKey string
TargetPrimaryKey string
TargetForeignKey string
}
definition of join tag, example: - join:"joinType:hasOne;primaryKey:id;foreignKey:candidate_id" - join:"joinType:hasMany;primaryKey:id;foreignKey:scouter_id" - join:"joinType:manyToMany;through:submission;sourcePrimaryKey:id;sourceForeignKey:candidate_id;targetPrimaryKey:id;targetForeign:candidate_id"
func UnmarshalJoinTag ¶
type LegacySubscriberConsumer ¶ added in v1.0.0
type LegacySubscriberConsumer interface {
AutoAck() bool
Name() string
// Consume receives the raw provider message (e.g. *pubsub.Message).
// Deprecated: implement SubscriberHandler.Consume(ctx, SubscriberMessage) instead.
Consume(ctx SubscriberContext, message any) error
Provider() PubSubProviderType
PushEndpoint() string
Subscription() string
SubscriptionType() SubscriptionType
Topic() string
}
LegacySubscriberConsumer allows old subscribers with Consume(ctx, message any) to be wrapped as a SubscriberHandler via WrapLegacySubscriber.
type MiddlewareFn ¶
type MiddlewareFn func(next RouteHandlerFn) RouteHandlerFn
--- define type and constant ----
func BreakerMiddleware ¶
func BreakerMiddleware(path string) MiddlewareFn
Handler open / close circuit breaker base on request error throttle
type PubSub ¶ added in v1.0.0
type PubSub interface {
Register(handler SubscriberHandler)
Publish(ctx context.Context, provider PubSubProviderType, topic string, message []byte) error
Listen()
Serve(handler SubscriberHandler) (fasthttp.RequestHandler, error)
Handlers() []SubscriberHandler
}
----- Subscription Server -----
type PubSubManager ¶ added in v1.0.0
type PubSubManager struct {
// contains filtered or unexported fields
}
func (*PubSubManager) GetHandlerCount ¶ added in v1.0.0
func (s *PubSubManager) GetHandlerCount() int
func (*PubSubManager) Handlers ¶ added in v1.0.0
func (s *PubSubManager) Handlers() []SubscriberHandler
func (*PubSubManager) Listen ¶ added in v1.0.0
func (s *PubSubManager) Listen()
Listen starts pull-subscription listeners for all registered providers.
func (*PubSubManager) Publish ¶ added in v1.0.0
func (s *PubSubManager) Publish(ctx context.Context, provider PubSubProviderType, topic string, message []byte) error
func (*PubSubManager) Register ¶ added in v1.0.0
func (s *PubSubManager) Register(handler SubscriberHandler)
Register implements PubSub.
func (*PubSubManager) Serve ¶ added in v1.0.0
func (s *PubSubManager) Serve(handler SubscriberHandler) (fasthttp.RequestHandler, error)
func (*PubSubManager) SetConfig ¶ added in v1.0.0
func (s *PubSubManager) SetConfig(cfg *Config)
func (*PubSubManager) SetProvider ¶ added in v1.0.0
func (s *PubSubManager) SetProvider(providerType PubSubProviderType, provider PubSubProvider)
type PubSubProvider ¶ added in v1.0.0
type PubSubProvider interface {
Publish(ctx context.Context, topic string, message []byte) error
CreateSubscription(SubscriberHandler) error
Serve(config *Config, handler SubscriberHandler) (fasthttp.RequestHandler, error)
StartListen(handler []SubscriberHandler) error
StopListen() error
}
----- Pub Sub Provider -----
type PubSubProviderType ¶ added in v1.0.0
type PubSubProviderType string
----- Type Definition -----
const ( PubSubProviderGoogle PubSubProviderType = "google" PubSubProviderSupabase PubSubProviderType = "supabase" PubSubProviderUnknown PubSubProviderType = "unknown" )
type PushSubscriptionData
deprecated
added in
v1.0.0
type PushSubscriptionData = googlePushData
Deprecated: PushSubscriptionData is an alias for backward compatibility. Use SubscriberMessage instead.
type PushSubscriptionMessage ¶ added in v1.0.0
type PushSubscriptionMessage = googlePushMessage
----- Backward Compatibility ----- Deprecated: PushSubscriptionMessage is an alias for backward compatibility. Use SubscriberMessage instead.
type RealtimeChannelType ¶ added in v1.0.0
type RealtimeChannelType string
const ( RealtimeChannelBroadcast RealtimeChannelType = "broadcast" RealtimeChannelPresence RealtimeChannelType = "presence" RealtimeChannelPostgresChanges RealtimeChannelType = "postgres_changes" )
type RelationType ¶
type RelationType string
var ( RelationTypeHasOne RelationType = "hasOne" RelationTypeHasMany RelationType = "hasMany" RelationTypeManyToMany RelationType = "manyToMany" )
type RestController ¶
type RestController struct {
Controller
Model any
TableName string
}
----- Rest Controller -----
func (RestController) AfterAll ¶
func (rc RestController) AfterAll(ctx Context) error
AfterAll implements Controller. Subtle: this method shadows the method (Controller).AfterAll of RestController.Controller.
func (RestController) AfterDelete ¶
func (rc RestController) AfterDelete(ctx Context) error
AfterDelete implements Controller. Subtle: this method shadows the method (Controller).AfterDelete of RestController.Controller.
func (RestController) AfterGet ¶
func (rc RestController) AfterGet(ctx Context) error
AfterGet implements Controller. Subtle: this method shadows the method (Controller).AfterGet of RestController.Controller.
func (RestController) AfterHead ¶
func (rc RestController) AfterHead(ctx Context) error
AfterHead implements Controller. Subtle: this method shadows the method (Controller).AfterHead of RestController.Controller.
func (RestController) AfterOptions ¶
func (rc RestController) AfterOptions(ctx Context) error
AfterOptions implements Controller. Subtle: this method shadows the method (Controller).AfterOptions of RestController.Controller.
func (RestController) AfterPatch ¶
func (rc RestController) AfterPatch(ctx Context) error
AfterPatch implements Controller. Subtle: this method shadows the method (Controller).AfterPatch of RestController.Controller.
func (RestController) AfterPost ¶
func (rc RestController) AfterPost(ctx Context) error
AfterPost implements Controller. Subtle: this method shadows the method (Controller).AfterPost of RestController.Controller.
func (RestController) AfterPut ¶
func (rc RestController) AfterPut(ctx Context) error
AfterPut implements Controller. Subtle: this method shadows the method (Controller).AfterPut of RestController.Controller.
func (RestController) BeforeAll ¶
func (rc RestController) BeforeAll(ctx Context) error
BeforeAll implements Controller.
func (RestController) BeforeDelete ¶
func (rc RestController) BeforeDelete(ctx Context) error
BeforeDelete implements Controller. Subtle: this method shadows the method (Controller).BeforeDelete of RestController.Controller.
func (RestController) BeforeGet ¶
func (rc RestController) BeforeGet(ctx Context) error
BeforeGet implements Controller. Subtle: this method shadows the method (Controller).BeforeGet of RestController.Controller.
func (RestController) BeforeHead ¶
func (rc RestController) BeforeHead(ctx Context) error
BeforeHead implements Controller. Subtle: this method shadows the method (Controller).BeforeHead of RestController.Controller.
func (RestController) BeforeOptions ¶
func (rc RestController) BeforeOptions(ctx Context) error
BeforeOptions implements Controller. Subtle: this method shadows the method (Controller).BeforeOptions of RestController.Controller.
func (RestController) BeforePatch ¶
func (rc RestController) BeforePatch(ctx Context) error
BeforePatch implements Controller. Subtle: this method shadows the method (Controller).BeforePatch of RestController.Controller.
func (RestController) BeforePost ¶
func (rc RestController) BeforePost(ctx Context) error
BeforePost implements Controller. Subtle: this method shadows the method (Controller).BeforePost of RestController.Controller.
func (RestController) BeforePut ¶
func (rc RestController) BeforePut(ctx Context) error
BeforePut implements Controller. Subtle: this method shadows the method (Controller).BeforePut of RestController.Controller.
func (RestController) Delete ¶
func (rc RestController) Delete(ctx Context) error
Delete implements Controller.
func (RestController) Get ¶
func (rc RestController) Get(ctx Context) error
Get implements Controller.
func (RestController) Head ¶
func (rc RestController) Head(ctx Context) error
Head implements Controller.
func (RestController) Options ¶
func (rc RestController) Options(ctx Context) error
Options implements Controller. Subtle: this method shadows the method (Controller).Options of RestController.Controller.
func (RestController) Patch ¶
func (rc RestController) Patch(ctx Context) error
Patch implements Controller.
func (RestController) Post ¶
func (rc RestController) Post(ctx Context) error
Post implements Controller.
func (RestController) Put ¶
func (rc RestController) Put(ctx Context) error
Put implements Controller.
type Role ¶
type Role interface {
// name
Name() string
// default 60
ConnectionLimit() int
// default true
IsInheritRole() bool
InheritRoles() []Role
// default false
CanBypassRls() bool
// default false
CanCreateDB() bool
// default false
CanCreateRole() bool
// default false
CanLogin() bool
// default nil
ValidUntil() *objects.SupabaseTime
}
TODO : support organizational unit roles
type RoleBase ¶
type RoleBase struct {
}
TODO : support organizational unit roles
func (*RoleBase) CanBypassRls ¶
func (*RoleBase) CanCreateDB ¶
func (*RoleBase) CanCreateRole ¶
func (*RoleBase) ConnectionLimit ¶
----- Base Role Default Func -----
func (*RoleBase) InheritRoles ¶ added in v1.0.0
func (*RoleBase) IsInheritRole ¶ added in v1.0.0
func (*RoleBase) ValidUntil ¶
func (r *RoleBase) ValidUntil() *objects.SupabaseTime
type Route ¶
type Route struct {
Type RouteType
Methods []string
Path string
Controller Controller
Model any
Storage Bucket
}
----- define route type, constant and variable -----
func NewRouteFromController ¶ added in v1.0.0
func NewRouteFromController(controller Controller, methods []string) *Route
type RouteHandlerFn ¶
----- define route type, constant and variable -----
func TraceMiddleware ¶
func TraceMiddleware(next RouteHandlerFn) RouteHandlerFn
extract trace id and span id from incoming request and create new trace context and span context, inject trace and span context to request context, and set span status
type Rpc ¶
type Rpc interface {
BindModels()
BindModel(model any, alias string) Rpc
GetModels() map[string]RpcModel
SetName(name string)
GetName() string
SetLanguage(language string)
GetLanguage() string
SetParams(params []RpcParam)
GetParams() []RpcParam
UseParamPrefix() bool
SetSchema(schema string)
GetSchema() string
SetSecurity(security RpcSecurityType)
GetSecurity() RpcSecurityType
SetBehavior(behavior RpcBehaviorType)
GetBehavior() RpcBehaviorType
SetReturnType(returnType RpcReturnDataType)
GetReturnType() RpcReturnDataType
SetReturnTypeStmt(returnTypeStmt string)
GetReturnTypeStmt() string
SetRawDefinition(definition string)
GetRawDefinition() string
SetCompleteStmt(stmt string)
GetCompleteStmt() string
}
----- Define type, variable and constant -----
type RpcBase ¶
type RpcBase struct {
Name string
Schema string
Params []RpcParam
Definition string
SecurityType RpcSecurityType
ReturnType RpcReturnDataType
ReturnTypeStmt string
Behavior RpcBehaviorType
CompleteStatement string
Models map[string]RpcModel
Language string
}
----- Define type, variable and constant -----
func (*RpcBase) BindModels ¶
func (r *RpcBase) BindModels()
func (*RpcBase) GetBehavior ¶
func (r *RpcBase) GetBehavior() RpcBehaviorType
func (*RpcBase) GetCompleteStmt ¶
func (*RpcBase) GetLanguage ¶ added in v1.0.0
func (*RpcBase) GetRawDefinition ¶
func (*RpcBase) GetReturnType ¶
func (r *RpcBase) GetReturnType() (rt RpcReturnDataType)
func (*RpcBase) GetReturnTypeStmt ¶
func (*RpcBase) GetSecurity ¶
func (r *RpcBase) GetSecurity() RpcSecurityType
func (*RpcBase) SetBehavior ¶
func (r *RpcBase) SetBehavior(behavior RpcBehaviorType)
func (*RpcBase) SetCompleteStmt ¶
func (*RpcBase) SetLanguage ¶ added in v1.0.0
func (*RpcBase) SetRawDefinition ¶
func (*RpcBase) SetReturnType ¶
func (r *RpcBase) SetReturnType(returnType RpcReturnDataType)
func (*RpcBase) SetReturnTypeStmt ¶
func (*RpcBase) SetSecurity ¶
func (r *RpcBase) SetSecurity(security RpcSecurityType)
func (*RpcBase) UseParamPrefix ¶
type RpcParam ¶
type RpcParam struct {
Name string
Type RpcParamDataType
Default *string
Value any
}
----- Define type, variable and constant -----
type RpcParamDataType ¶
type RpcParamDataType string
---- Define rpc data type -----
const ( RpcParamDataTypeInteger RpcParamDataType = "INTEGER" RpcParamDataTypeNumeric RpcParamDataType = "NUMERIC" RpcParamDataTypeBigInt RpcParamDataType = "BIGINT" RpcParamDataTypeReal RpcParamDataType = "REAL" RpcParamDataTypeDoublePreci RpcParamDataType = "DOUBLE PRECISION" RpcParamDataTypeText RpcParamDataType = "TEXT" RpcParamDataTypeVarchar RpcParamDataType = "CHARACTER VARYING" RpcParamDataTypeVarcharAlias RpcParamDataType = "VARCHAR" RpcParamDataTypeBoolean RpcParamDataType = "BOOLEAN" RpcParamDataTypeBytea RpcParamDataType = "BYTEA" RpcParamDataTypeTimestamp RpcParamDataType = "TIMESTAMP WITHOUT TIME ZONE" RpcParamDataTypeTimestampAlias RpcParamDataType = "TIMESTAMP" RpcParamDataTypeTimestampTZ RpcParamDataType = "TIMESTAMP WITH TIME ZONE" RpcParamDataTypeTimestampTZAlias RpcParamDataType = "TIMESTAMPZ" RpcParamDataTypeJSON RpcParamDataType = "JSON" RpcParamDataTypeJSONB RpcParamDataType = "JSONB" RpcParamDataTypeUuid RpcParamDataType = "UUID" RpcParamDataTypeDate RpcParamDataType = "DATE" RpcParamDataTypePoint RpcParamDataType = "POINT" RpcParamDataTypeArrayOfUuid RpcParamDataType = "UUID[]" RpcParamDataTypeArrayOfInteger RpcParamDataType = "INTEGER[]" RpcParamDataTypeArrayOfNumeric RpcParamDataType = "NUMERIC[]" RpcParamDataTypeArrayOfBigInt RpcParamDataType = "BIGINT[]" RpcParamDataTypeArrayOfReal RpcParamDataType = "REAL[]" RpcParamDataTypeArrayOfDoublePreci RpcParamDataType = "DOUBLE PRECISION[]" RpcParamDataTypeArrayOfText RpcParamDataType = "TEXT[]" RpcParamDataTypeArrayOfVarchar RpcParamDataType = "CHARACTER VARYING[]" RpcParamDataTypeArrayOfVarcharAlias RpcParamDataType = "VARCHAR[]" )
Define constants for rpc input data type
func GetValidRpcParamType ¶
func GetValidRpcParamType(pType string, returnAlias bool) (RpcParamDataType, error)
type RpcParamKV ¶ added in v1.0.0
type RpcParamMap ¶ added in v1.0.0
type RpcParamMap struct {
// contains filtered or unexported fields
}
func (*RpcParamMap) Get ¶ added in v1.0.0
func (om *RpcParamMap) Get(key string) (any, bool)
Get retrieves a value by key
func (RpcParamMap) MarshalJSON ¶ added in v1.0.0
func (om RpcParamMap) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface to preserve order
func (*RpcParamMap) Set ¶ added in v1.0.0
func (om *RpcParamMap) Set(key string, value any)
Set adds or updates a key-value pair
type RpcParamTag ¶
----- Define type, variable and constant -----
func UnmarshalRpcParamTag ¶
func UnmarshalRpcParamTag(tag string) (RpcParamTag, error)
type RpcReturnDataType ¶
type RpcReturnDataType string
const ( RpcReturnDataTypeInteger RpcReturnDataType = "INTEGER" RpcReturnDataTypeBigInt RpcReturnDataType = "BIGINT" RpcReturnDataTypeReal RpcReturnDataType = "REAL" RpcReturnDataTypeDoublePreci RpcReturnDataType = "DOUBLE PRECISION" RpcReturnDataTypeText RpcReturnDataType = "TEXT" RpcReturnDataTypeVarchar RpcReturnDataType = "CHARACTER VARYING" RpcReturnDataTypeVarcharAlias RpcReturnDataType = "VARCHAR" RpcReturnDataTypeBoolean RpcReturnDataType = "BOOLEAN" RpcReturnDataTypeBytea RpcReturnDataType = "BYTEA" RpcReturnDataTypeTimestamp RpcReturnDataType = "TIMESTAMP WITHOUT TIME ZONE" RpcReturnDataTypeTimestampAlias RpcReturnDataType = "TIMESTAMP" RpcReturnDataTypeTimestampTZ RpcReturnDataType = "TIMESTAMP WITH TIME ZONE" RpcReturnDataTypeTimestampTZAlias RpcReturnDataType = "TIMESTAMPZ" RpcReturnDataTypeJSON RpcReturnDataType = "JSON" RpcReturnDataTypeJSONB RpcReturnDataType = "JSONB" RpcReturnDataTypeRecord RpcReturnDataType = "RECORD" // like tuple RpcReturnDataTypeTable RpcReturnDataType = "TABLE" RpcReturnDataTypeSetOf RpcReturnDataType = "SETOF" RpcReturnDataTypeVoid RpcReturnDataType = "VOID" RpcReturnDataTypeTrigger RpcReturnDataType = "TRIGGER" RpcReturnDataTypeDate RpcReturnDataType = "DATE" RpcReturnDataTypePoint RpcReturnDataType = "POINT" RpcReturnDataTypeUUID RpcReturnDataType = "UUID" RpcReturnDataTypeArrayOfInteger RpcReturnDataType = "INTEGER[]" RpcReturnDataTypeArrayOfNumeric RpcReturnDataType = "NUMERIC[]" RpcReturnDataTypeArrayOfBigInt RpcReturnDataType = "BIGINT[]" RpcReturnDataTypeArrayOfReal RpcReturnDataType = "REAL[]" RpcReturnDataTypeArrayOfDoublePreci RpcReturnDataType = "DOUBLE PRECISION[]" RpcReturnDataTypeArrayOfText RpcReturnDataType = "TEXT[]" RpcReturnDataTypeArrayOfVarchar RpcReturnDataType = "CHARACTER VARYING[]" RpcReturnDataTypeArrayOfVarcharAlias RpcReturnDataType = "VARCHAR[]" )
Define constants for rpc return data type
func GetValidRpcReturnType ¶
func GetValidRpcReturnType(pType string, returnAlias bool) (RpcReturnDataType, error)
type ScheduleStatus ¶
type ScheduleStatus string
----- Custom Type
const ( ScheduleStatusOn ScheduleStatus = "on" ScheduleStatusOff ScheduleStatus = "off" )
type Scheduler ¶
type Scheduler interface {
RegisterJob(job Job) error
Start()
Stop(ctx context.Context) error
ListenJobChan()
SetTracer(tracer trace.Tracer)
}
----- Scheduler server
type SchedulerServer ¶
type SchedulerServer struct {
Config *Config
Server gocron.Scheduler
JobChan chan JobParams
// contains filtered or unexported fields
}
func NewSchedulerServer ¶
func NewSchedulerServer(config *Config, options ...gocron.SchedulerOption) (*SchedulerServer, error)
func (*SchedulerServer) ListenJobChan ¶
func (s *SchedulerServer) ListenJobChan()
func (*SchedulerServer) RegisterJob ¶
func (s *SchedulerServer) RegisterJob(job Job) error
func (*SchedulerServer) SetPubsub ¶ added in v1.0.0
func (s *SchedulerServer) SetPubsub(pubsub PubSub)
func (*SchedulerServer) SetTracer ¶
func (s *SchedulerServer) SetTracer(tracer trace.Tracer)
func (SchedulerServer) Start ¶
func (s SchedulerServer) Start()
type Server ¶
type Server struct {
Config *Config
Router *router
HttpServer *fasthttp.Server
SchedulerServer Scheduler
ShutdownFunc []func(ctx context.Context) error
// contains filtered or unexported fields
}
--- server configuration ----
func (*Server) ConfigureLogLevel ¶ added in v1.0.0
func (s *Server) ConfigureLogLevel()
func (*Server) RegisterJobs ¶
func (*Server) RegisterLibs ¶ added in v1.0.0
func (*Server) RegisterModules ¶ added in v1.0.0
func (*Server) RegisterRoute ¶
func (*Server) RegisterSubscribers ¶ added in v1.0.0
func (s *Server) RegisterSubscribers(ss ...SubscriberHandler)
func (*Server) Use ¶
func (s *Server) Use(middleware MiddlewareFn)
type StorageController ¶
type StorageController struct {
Controller
BucketName string
RoutePath string
}
----- Storage Controller -----
func (StorageController) AfterAll ¶
func (rc StorageController) AfterAll(ctx Context) error
AfterAll implements Controller. Subtle: this method shadows the method (Controller).AfterAll of RestController.Controller.
func (StorageController) AfterDelete ¶
func (rc StorageController) AfterDelete(ctx Context) error
AfterDelete implements Controller. Subtle: this method shadows the method (Controller).AfterDelete of StorageController.Controller.
func (StorageController) AfterGet ¶
func (rc StorageController) AfterGet(ctx Context) error
AfterGet implements Controller. Subtle: this method shadows the method (Controller).AfterGet of StorageController.Controller.
func (StorageController) AfterHead ¶
func (rc StorageController) AfterHead(ctx Context) error
AfterHead implements Controller. Subtle: this method shadows the method (Controller).AfterHead of StorageController.Controller.
func (StorageController) AfterOptions ¶
func (rc StorageController) AfterOptions(ctx Context) error
AfterOptions implements Controller. Subtle: this method shadows the method (Controller).AfterOptions of StorageController.Controller.
func (StorageController) AfterPatch ¶
func (rc StorageController) AfterPatch(ctx Context) error
AfterPatch implements Controller. Subtle: this method shadows the method (Controller).AfterPatch of StorageController.Controller.
func (StorageController) AfterPost ¶
func (rc StorageController) AfterPost(ctx Context) error
AfterPost implements Controller. Subtle: this method shadows the method (Controller).AfterPost of StorageController.Controller.
func (StorageController) AfterPut ¶
func (rc StorageController) AfterPut(ctx Context) error
AfterPut implements Controller. Subtle: this method shadows the method (Controller).AfterPut of StorageController.Controller.
func (StorageController) BeforeAll ¶
func (rc StorageController) BeforeAll(ctx Context) error
BeforeAll implements Controller.
func (StorageController) BeforeDelete ¶
func (rc StorageController) BeforeDelete(ctx Context) error
BeforeDelete implements Controller. Subtle: this method shadows the method (Controller).BeforeDelete of StorageController.Controller.
func (StorageController) BeforeGet ¶
func (rc StorageController) BeforeGet(ctx Context) error
BeforeGet implements Controller. Subtle: this method shadows the method (Controller).BeforeGet of StorageController.Controller.
func (StorageController) BeforeHead ¶
func (rc StorageController) BeforeHead(ctx Context) error
BeforeHead implements Controller. Subtle: this method shadows the method (Controller).BeforeHead of StorageController.Controller.
func (StorageController) BeforeOptions ¶
func (rc StorageController) BeforeOptions(ctx Context) error
BeforeOptions implements Controller. Subtle: this method shadows the method (Controller).BeforeOptions of StorageController.Controller.
func (StorageController) BeforePatch ¶
func (rc StorageController) BeforePatch(ctx Context) error
BeforePatch implements Controller. Subtle: this method shadows the method (Controller).BeforePatch of StorageController.Controller.
func (StorageController) BeforePost ¶
func (rc StorageController) BeforePost(ctx Context) error
BeforePost implements Controller. Subtle: this method shadows the method (Controller).BeforePost of StorageController.Controller.
func (StorageController) BeforePut ¶
func (rc StorageController) BeforePut(ctx Context) error
BeforePut implements Controller. Subtle: this method shadows the method (Controller).BeforePut of StorageController.Controller.
func (StorageController) Delete ¶
func (rc StorageController) Delete(ctx Context) error
Delete implements Controller.
func (StorageController) Get ¶
func (rc StorageController) Get(ctx Context) error
Get implements Controller.
func (StorageController) Head ¶
func (rc StorageController) Head(ctx Context) error
Head implements Controller. Subtle: this method shadows the method (Controller).Head of StorageController.Controller.
func (StorageController) Options ¶
func (rc StorageController) Options(ctx Context) error
Options implements Controller. Subtle: this method shadows the method (Controller).Options of StorageController.Controller.
func (StorageController) Patch ¶
func (rc StorageController) Patch(ctx Context) error
Patch implements Controller.
func (StorageController) Post ¶
func (rc StorageController) Post(ctx Context) error
Post implements Controller.
func (StorageController) Put ¶
func (rc StorageController) Put(ctx Context) error
Put implements Controller.
type SubscriberBase ¶ added in v1.0.0
type SubscriberBase struct{}
func (*SubscriberBase) AutoAck ¶ added in v1.0.0
func (s *SubscriberBase) AutoAck() bool
func (*SubscriberBase) ChannelType ¶ added in v1.0.0
func (s *SubscriberBase) ChannelType() RealtimeChannelType
func (*SubscriberBase) Consume ¶ added in v1.0.0
func (s *SubscriberBase) Consume(ctx SubscriberContext, message SubscriberMessage) error
func (*SubscriberBase) EventFilter ¶ added in v1.0.0
func (s *SubscriberBase) EventFilter() string
func (*SubscriberBase) Name ¶ added in v1.0.0
func (s *SubscriberBase) Name() string
func (*SubscriberBase) Provider ¶ added in v1.0.0
func (s *SubscriberBase) Provider() PubSubProviderType
func (*SubscriberBase) PushEndpoint ¶ added in v1.0.0
func (s *SubscriberBase) PushEndpoint() string
func (*SubscriberBase) Schema ¶ added in v1.0.0
func (s *SubscriberBase) Schema() string
func (*SubscriberBase) Subscription ¶ added in v1.0.0
func (s *SubscriberBase) Subscription() string
func (*SubscriberBase) SubscriptionType ¶ added in v1.0.0
func (s *SubscriberBase) SubscriptionType() SubscriptionType
func (*SubscriberBase) Table ¶ added in v1.0.0
func (s *SubscriberBase) Table() string
func (*SubscriberBase) Topic ¶ added in v1.0.0
func (s *SubscriberBase) Topic() string
type SubscriberContext ¶ added in v1.0.0
type SubscriberContext interface {
Config() *Config
Span() trace.Span
SetSpan(span trace.Span)
HttpRequest(method string, url string, body []byte, headers map[string]string, timeout time.Duration, response any) error
}
----- Subscription Context -----
type SubscriberHandler ¶ added in v1.0.0
type SubscriberHandler interface {
AutoAck() bool
Name() string
Consume(ctx SubscriberContext, message SubscriberMessage) error
ChannelType() RealtimeChannelType
EventFilter() string
Provider() PubSubProviderType
PushEndpoint() string
Schema() string
Subscription() string
SubscriptionType() SubscriptionType
Table() string
Topic() string
}
----- Subscription Handler -----
func WrapLegacySubscriber
deprecated
added in
v1.0.0
func WrapLegacySubscriber(s LegacySubscriberConsumer) SubscriberHandler
WrapLegacySubscriber wraps a subscriber that uses the old Consume(ctx, message any) signature so it satisfies the current SubscriberHandler interface.
Deprecated: migrate to SubscriberHandler.Consume(ctx, SubscriberMessage) directly. The Raw field of SubscriberMessage contains the original provider message.
type SubscriberMessage ¶ added in v1.0.0
type SubscriberMessage struct {
Data []byte
Attributes map[string]string
// Raw holds the original provider-specific message (e.g., *pubsub.Message).
Raw any
}
SubscriberMessage is a provider-agnostic message wrapper.
type SubscriptionType ¶ added in v1.0.0
type SubscriptionType string
const ( SubscriptionTypePull SubscriptionType = "pull" SubscriptionTypePush SubscriptionType = "push" )
type SupabaseRealtimeProvider ¶ added in v1.0.0
type SupabaseRealtimeProvider struct {
Config *Config
Provider *supabasepubsub.Provider
}
----- Supabase Realtime Provider Adapter ----- SupabaseRealtimeProvider adapts supabase.Provider to the PubSubProvider interface.
func (*SupabaseRealtimeProvider) CreateSubscription ¶ added in v1.0.0
func (a *SupabaseRealtimeProvider) CreateSubscription(handler SubscriberHandler) error
func (*SupabaseRealtimeProvider) Serve ¶ added in v1.0.0
func (a *SupabaseRealtimeProvider) Serve(config *Config, handler SubscriberHandler) (fasthttp.RequestHandler, error)
Serve returns an error for Supabase Realtime — it uses WebSocket, not HTTP push.
func (*SupabaseRealtimeProvider) StartListen ¶ added in v1.0.0
func (a *SupabaseRealtimeProvider) StartListen(handlers []SubscriberHandler) error
func (*SupabaseRealtimeProvider) StopListen ¶ added in v1.0.0
func (a *SupabaseRealtimeProvider) StopListen() error
type TypeBase ¶ added in v1.0.0
type TypeBase struct {
Value any
}
----- base type default function -----
func (*TypeBase) Attributes ¶ added in v1.0.0
func (*TypeBase) Attributes() []objects.TypeAttribute
func (TypeBase) MarshalJSON ¶ added in v1.0.0
Implement custom JSON marshaling
func (*TypeBase) UnmarshalJSON ¶ added in v1.0.0
Implement custom JSON unmarshaling
type ValidatorFunc ¶
custom struct for validation function
type WithValidator ¶
type WithValidator func(name string, validateFn validator.Func) ValidatorFunc
custom type for custom validation function