raiden

package module
v1.0.0-beta.50 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT Imports: 44 Imported by: 3

README

Raiden Framework

Build Status codecov Go Report Card OpenSSF Best Practices

Introduction

Raiden is a cutting-edge framework designed for seamless integration with Supabase, focusing on enhancing security, streamlining backend processes, and providing consistent schema management. It specifically addresses the need to avoid direct client-side calls to the database, ensuring more secure and efficient data handling.

Key Objectives

  • Enhanced Security: Prevent direct client-side database calls to bolster security.
  • Unified Backend Management: Introduce a unified layer for managing Remote Procedure Calls (RPC), Edge Functions, and standard APIs, simplifying backend complexity.
  • Consistent Schema Management: Provide tools for consistent and efficient management and persistence of database schemas.

Features

  • Secure Database Interaction: Ensures secure communication between client and database, mitigating risks associated with direct database access.
  • Unified Backend Layer: Streamlines the creation and management of RPCs, Edge Functions, and APIs, offering a centralized way to handle backend logic.
  • Schema Consistency: Tools to manage database schemas with ease, ensuring consistency across different stages of development.

Getting Started

Prerequisites
  • Go (version 1.21.6 or higher)
  • Supabase account and project setup
Installation

Download our binary, or build from your local.

Usage:
  raiden [command]

Available Commands:
  apply       Apply resource to supabase
  build       Build app binary
  completion  Generate the autocompletion script for the specified shell
  configure   Configure project
  generate    Generate application resource
  help        Help about any command
  imports     Import supabase resource
  init        Init golang app
  run         Run app server
  serve       Serve app binary
  start       Start new app
  version     Show application information

Flags:
      --debug   enable log with debug mode
  -h, --help    help for raiden
      --trace   enable log with trace mode

Use "raiden [command] --help" for more information about a command.

Documentation

For detailed documentation, including security practices and schema management, visit raiden.sev-2.com.

Contributing

Contributions are welcome! Please read our Contributing Guidelines for more information.

License

Raiden is open source and is licensed under the MIT License.

Contact

For support or queries, please contact us at admin@refactory.id.

Documentation

Index

Constants

View Source
const (
	DefaultRoleValidUntilLayout = "2006-01-02"
	DefaultRoleConnectionLimit  = 60
)
View Source
const (
	RpcBehaviorVolatile  RpcBehaviorType = "VOLATILE"
	RpcBehaviorStable    RpcBehaviorType = "STABLE"
	RpcBehaviorImmutable RpcBehaviorType = "IMMUTABLE"

	RpcSecurityTypeDefiner RpcSecurityType = "DEFINER"
	RpcSecurityTypeInvoker RpcSecurityType = "INVOKER"

	RpcTemplate = `` /* 166-byte string literal not displayed */
)
View Source
const (
	DefaultTypeSchema = "public"
)
View Source
const SubscriptionPrefixEndpoint = "pubsub-endpoint"

Variables

View Source
var (
	DefaultRpcParamPrefix = "in_"
	DefaultRpcSchema      = "public"
)
View Source
var ControllerLogger = logger.HcLog().Named("raiden.controller")
View Source
var MiddlewareLogger = logger.HcLog().Named("raiden.middleware")
View Source
var PubSubLogger = logger.HcLog().Named("raiden.pubsub")
View Source
var RouterLogger = logger.HcLog().Named("raiden.router")
View Source
var RpcLogger = logger.HcLog().Named("raiden.rpc")
View Source
var SchedulerLogger = logger.HcLog().Named("raiden.scheduler")
View Source
var ServerLogger = logger.HcLog().Named("raiden.server")

Functions

func AuthProxy

func AuthProxy(
	config *Config,
	chain Chain,
	requestInterceptor func(req *fasthttp.Request),
	responseInterceptor func(resp *fasthttp.Response) error,
) fasthttp.RequestHandler

func BuildRpc

func BuildRpc(rpc Rpc) (err error)

func ConvertRequestCtxToHTTPRequest

func ConvertRequestCtxToHTTPRequest(ctx *fasthttp.RequestCtx) (*http.Request, error)

func CorsMiddleware

func CorsMiddleware(config *Config) fasthttp.RequestHandler

func Debug

func Debug(message string, v ...any)

func Error

func Error(message string, v ...any)

func ExecuteRpc

func ExecuteRpc(ctx Context, rpc Rpc) (any, error)

----- Execute Rpc -----

func Fatal

func Fatal(message string, v ...any)

func GetLogLevel added in v1.0.0

func GetLogLevel() hclog.Level

func GetTableName

func GetTableName(model any) (tableName string)

func GetValidRpcReturnNameDecl

func GetValidRpcReturnNameDecl(pType RpcReturnDataType, returnAlias bool) (string, error)

func Info

func Info(message string, v ...any)

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

func NewGracefulListener(ln net.Listener, maxWaitTime time.Duration) net.Listener

NewGracefulListener wraps the given listener into 'graceful shutdown' listener.

func NewRouter

func NewRouter(config *Config) *router

func Panic

func Panic(message string)

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 RestProxy

func RestProxy(appCtx Context, TableName string) error

func RpcParamToGoType

func RpcParamToGoType(dataType RpcParamDataType) string

func RpcReturnToGoType

func RpcReturnToGoType(dataType RpcReturnDataType) string

func SetLogLevel

func SetLogLevel(level hclog.Level)

func StorageProxy

func StorageProxy(appCtx Context, bucketName string, routePath string) error

func Validate

func Validate(ctx context.Context, payload any, requestValidators ...ValidatorFunc) error

validate payload

func Warning

func Warning(message string, v ...any)

func WebSocketHandler

func WebSocketHandler(ctx *fasthttp.RequestCtx, u *url.URL)

Types

type Acl

type Acl struct {
	Roles []string
	Check *string
	Using string
}

type AclTag

type AclTag struct {
	Read  Acl
	Write Acl
}

func UnmarshalAclTag

func UnmarshalAclTag(tag string) AclTag

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 Bucket

type Bucket interface {
	Name() string
	Public() bool
	AllowedMimeTypes() []string
	FileSizeLimit() int
	AvifAutoDetection() bool
}

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(config *Config, tracer trace.Tracer, jobChan chan JobParams, pubSub PubSub, httpMethod string, routeType RouteType, fn Controller, 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

func UnmarshalColumnTag(tag string) ColumnTag

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"`
	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

func LoadConfig(path *string) (*Config, error)

The function `LoadConfig` loads a configuration file based on the provided path or uses default values if no path is provided.

func (*Config) GetBool

func (*Config) GetBool(key string) bool

func (*Config) GetFloat64

func (*Config) GetFloat64(key string) float64

func (*Config) GetInt

func (*Config) GetInt(key string) int

func (*Config) GetIntSlice

func (*Config) GetIntSlice(key string) []int

func (*Config) GetString

func (*Config) GetString(key string) string

func (*Config) GetStringSlice

func (*Config) GetStringSlice(key string) []string

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 NewCtx added in v1.0.0

func NewCtx(config *Config, tracer trace.Tracer, jobChan chan JobParams) Ctx

func (*Ctx) Config

func (c *Ctx) Config() *Config

func (*Ctx) Ctx

func (c *Ctx) Ctx() context.Context

func (*Ctx) ExecuteRpc

func (c *Ctx) ExecuteRpc(rpc Rpc) (any, error)

func (*Ctx) Get

func (c *Ctx) Get(key string) any

func (*Ctx) GetParam added in v1.0.0

func (c *Ctx) GetParam(key string) any

func (*Ctx) GetQuery added in v1.0.0

func (c *Ctx) GetQuery(key string) string

func (*Ctx) HttpRequest added in v1.0.0

func (c *Ctx) HttpRequest(method string, url string, body []byte, headers map[string]string, timeout time.Duration) (response *http.Response, err error)

func (*Ctx) HttpRequestAndBind added in v1.0.0

func (c *Ctx) HttpRequestAndBind(method string, url string, body []byte, headers map[string]string, timeout time.Duration, response any) error

func (*Ctx) NewJobCtx

func (c *Ctx) NewJobCtx() (JobContext, error)

func (*Ctx) Publish added in v1.0.0

func (c *Ctx) Publish(ctx context.Context, provider PubSubProviderType, topic string, message []byte) error

func (*Ctx) RegisterLibraries added in v1.0.0

func (c *Ctx) RegisterLibraries(key map[string]any)

func (*Ctx) RequestContext

func (c *Ctx) RequestContext() *fasthttp.RequestCtx

func (*Ctx) ResolveLibrary added in v1.0.0

func (c *Ctx) ResolveLibrary(key any) error

func (*Ctx) SendError

func (c *Ctx) SendError(message string) error

func (*Ctx) SendErrorWithCode

func (c *Ctx) SendErrorWithCode(statusCode int, err error) error

func (*Ctx) SendJson

func (c *Ctx) SendJson(data any) error

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) SendRpc

func (c *Ctx) SendRpc(rpc Rpc) error

func (*Ctx) Set

func (c *Ctx) Set(key string, value any)

func (*Ctx) SetCtx

func (c *Ctx) SetCtx(ctx context.Context)

func (*Ctx) SetJobChan added in v1.0.0

func (c *Ctx) SetJobChan(jobChan chan JobParams)

func (*Ctx) SetSpan

func (c *Ctx) SetSpan(span trace.Span)

func (*Ctx) Span

func (c *Ctx) Span() trace.Span

func (*Ctx) Tracer

func (c *Ctx) Tracer() trace.Tracer

func (*Ctx) Write

func (c *Ctx) Write(data []byte)

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

func (c *Ctx) WriteError(err error)

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 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
	Client google.PubSubClient
	Tracer trace.Tracer
}

func (*GooglePubSubProvider) CreateSubscription added in v1.0.0

func (s *GooglePubSubProvider) CreateSubscription(handler SubscriberHandler) error

func (*GooglePubSubProvider) Publish added in v1.0.0

func (s *GooglePubSubProvider) Publish(ctx context.Context, topic string, message []byte) error

func (*GooglePubSubProvider) StartListen added in v1.0.0

func (s *GooglePubSubProvider) StartListen(handler []SubscriberHandler) error

func (*GooglePubSubProvider) StopListen added in v1.0.0

func (s *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) After

func (j *JobBase) After(ctx JobContext, jobID uuid.UUID, jobName string)

func (*JobBase) AfterErr

func (j *JobBase) AfterErr(ctx JobContext, jobID uuid.UUID, jobName string, err error)

func (*JobBase) Before

func (j *JobBase) Before(ctx JobContext, jobID uuid.UUID, jobName string)

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 JobData

type JobData map[string]any

type JobDuration

type JobDuration = gocron.JobDefinition

----- Scheduler Base

type JobParams

type JobParams struct {
	Job     Job
	Data    JobData
	TraceId string
	SpanId  string
}

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

func UnmarshalJoinTag(tag string) JoinTag

type Library added in v1.0.0

type Library interface {
	IsLongRunning() bool
}

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 Mode added in v1.0.0

type Mode string
const (
	BffMode Mode = "bff"
	SvcMode Mode = "svc"
)

type ModelBase

type ModelBase struct {
}

type Module added in v1.0.0

type Module interface {
	Routes() []*Route
	Libs() []func(config *Config) any
}

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(handle SubscriberHandler) (fasthttp.RequestHandler, error)
	Handlers() []SubscriberHandler
}

----- Subscription Server -----

func NewPubsub added in v1.0.0

func NewPubsub(config *Config, tracer trace.Tracer) PubSub

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()

StartListen implements Subscriber.

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 Subscriber.

func (*PubSubManager) Serve added in v1.0.0

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
	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"
	PubSubProviderUnknown PubSubProviderType = "unknown"
)

type PushSubscriptionData added in v1.0.0

type PushSubscriptionData struct {
	Message      PushSubscriptionMessage `json:"message"`
	Subscription string                  `json:"subscription"`
}

type PushSubscriptionMessage added in v1.0.0

type PushSubscriptionMessage struct {
	Data         string `json:"data"`
	MessageId    string `json:"message_id"`
	Publish_time string `json:"publish_time"`
}

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. Subtle: this method shadows the method (Controller).Head of RestController.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
	InheritRole() bool

	// 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 (r *RoleBase) CanBypassRls() bool

func (*RoleBase) CanCreateDB

func (r *RoleBase) CanCreateDB() bool

func (*RoleBase) CanCreateRole

func (r *RoleBase) CanCreateRole() bool

func (*RoleBase) CanLogin

func (r *RoleBase) CanLogin() bool

func (*RoleBase) ConnectionLimit

func (r *RoleBase) ConnectionLimit() int

----- Base Role Default Func -----

func (*RoleBase) InheritRole

func (r *RoleBase) InheritRole() bool

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

type RouteHandlerFn func(ctx Context) error

----- 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 RouteType

type RouteType string

----- define route type, constant and variable -----

const (
	RouteTypeCustom   RouteType = "custom"
	RouteTypeFunction RouteType = "function"
	RouteTypeRest     RouteType = "rest"
	RouteTypeRpc      RouteType = "rpc"
	RouteTypeRealtime RouteType = "realtime"
	RouteTypeStorage  RouteType = "storage"
)

type Rpc

type Rpc interface {
	BindModels()
	BindModel(model any, alias string) Rpc
	GetModels() map[string]RpcModel
	SetName(name string)
	GetName() 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
}

----- Define type, variable and constant -----

func (*RpcBase) BindModel

func (r *RpcBase) BindModel(model any, alias string) Rpc

func (*RpcBase) BindModels

func (r *RpcBase) BindModels()

func (*RpcBase) GetBehavior

func (r *RpcBase) GetBehavior() RpcBehaviorType

func (*RpcBase) GetCompleteStmt

func (r *RpcBase) GetCompleteStmt() string

func (*RpcBase) GetModels

func (r *RpcBase) GetModels() map[string]RpcModel

func (*RpcBase) GetName

func (r *RpcBase) GetName() string

func (*RpcBase) GetParams

func (r *RpcBase) GetParams() []RpcParam

func (*RpcBase) GetRawDefinition

func (r *RpcBase) GetRawDefinition() (d string)

func (*RpcBase) GetReturnType

func (r *RpcBase) GetReturnType() (rt RpcReturnDataType)

func (*RpcBase) GetReturnTypeStmt

func (r *RpcBase) GetReturnTypeStmt() string

func (*RpcBase) GetSchema

func (r *RpcBase) GetSchema() string

func (*RpcBase) GetSecurity

func (r *RpcBase) GetSecurity() RpcSecurityType

func (*RpcBase) SetBehavior

func (r *RpcBase) SetBehavior(behavior RpcBehaviorType)

func (*RpcBase) SetCompleteStmt

func (r *RpcBase) SetCompleteStmt(stmt string)

func (*RpcBase) SetName

func (r *RpcBase) SetName(name string)

func (*RpcBase) SetParams

func (r *RpcBase) SetParams(params []RpcParam)

func (*RpcBase) SetRawDefinition

func (r *RpcBase) SetRawDefinition(definition string)

func (*RpcBase) SetReturnType

func (r *RpcBase) SetReturnType(returnType RpcReturnDataType)

func (*RpcBase) SetReturnTypeStmt

func (r *RpcBase) SetReturnTypeStmt(returnTypeStmt string)

func (*RpcBase) SetSchema

func (r *RpcBase) SetSchema(schema string)

func (*RpcBase) SetSecurity

func (r *RpcBase) SetSecurity(security RpcSecurityType)

func (*RpcBase) UseParamPrefix

func (r *RpcBase) UseParamPrefix() bool

type RpcBehaviorType

type RpcBehaviorType string

----- Define type, variable and constant -----

type RpcModel

type RpcModel struct {
	Alias string
	Model any
}

----- Define type, variable and constant -----

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"
)

Define constants for rpc input data type

func GetValidRpcParamType

func GetValidRpcParamType(pType string, returnAlias bool) (RpcParamDataType, error)

type RpcParamTag

type RpcParamTag struct {
	Name         string
	Type         string
	DefaultValue string
}

----- Define type, variable and constant -----

func UnmarshalRpcParamTag

func UnmarshalRpcParamTag(tag string) (RpcParamTag, error)

type RpcParams

type RpcParams []RpcParam

----- Define type, variable and constant -----

func (RpcParams) ToQuery

func (p RpcParams) ToQuery(userPrefix bool) (string, error)

----- Rpc Param Functionality -----

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"
)

Define constants for rpc return data type

func GetValidRpcReturnType

func GetValidRpcReturnType(pType string, returnAlias bool) (RpcReturnDataType, error)

type RpcSecurityType

type RpcSecurityType string

----- Define type, variable and constant -----

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()

func (SchedulerServer) Stop

func (s SchedulerServer) Stop(ctx context.Context) error

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 NewServer

func NewServer(config *Config) *Server

func (*Server) ConfigureLogLevel added in v1.0.0

func (s *Server) ConfigureLogLevel()

func (*Server) RegisterJobs

func (s *Server) RegisterJobs(jobs ...Job)

func (*Server) RegisterLibs added in v1.0.0

func (s *Server) RegisterLibs(libs ...func(config *Config) any)

func (*Server) RegisterModules added in v1.0.0

func (s *Server) RegisterModules(module Module)

func (*Server) RegisterRoute

func (s *Server) RegisterRoute(routes []*Route)

func (*Server) RegisterSubscribers added in v1.0.0

func (s *Server) RegisterSubscribers(ss ...SubscriberHandler)

func (*Server) Run

func (s *Server) Run()

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

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) Consume added in v1.0.0

func (s *SubscriberBase) Consume(ctx SubscriberContext, message any) error

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) 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) 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 any) error
	Provider() PubSubProviderType
	PushEndpoint() string
	Subscription() string
	SubscriptionType() SubscriptionType
	Topic() string
}

----- Subscription Handler -----

type SubscriptionType added in v1.0.0

type SubscriptionType string
const (
	SubscriptionTypePull SubscriptionType = "pull"
	SubscriptionTypePush SubscriptionType = "push"
)

type TokenType added in v1.0.0

type TokenType string
const (
	TokenTypeBasic  TokenType = "basic"
	TokenTypeBearer TokenType = "bearer"
)

type Type added in v1.0.0

type Type interface {
	Name() string
	Schema() string
	Format() string
	Enums() []string
	Attributes() []objects.TypeAttribute
	Comment() *string
}

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) Comment added in v1.0.0

func (*TypeBase) Comment() *string

func (*TypeBase) Enums added in v1.0.0

func (*TypeBase) Enums() []string

func (*TypeBase) Format added in v1.0.0

func (*TypeBase) Format() string

func (*TypeBase) GetValue added in v1.0.0

func (t *TypeBase) GetValue() any

func (TypeBase) MarshalJSON added in v1.0.0

func (t TypeBase) MarshalJSON() ([]byte, error)

Implement custom JSON marshaling

func (*TypeBase) Name added in v1.0.0

func (*TypeBase) Name() string

func (*TypeBase) Schema added in v1.0.0

func (*TypeBase) Schema() string

func (*TypeBase) SetValue added in v1.0.0

func (t *TypeBase) SetValue(v any)

func (*TypeBase) String added in v1.0.0

func (t *TypeBase) String() string

String returns the enum as a string

func (*TypeBase) UnmarshalJSON added in v1.0.0

func (t *TypeBase) UnmarshalJSON(data []byte) error

Implement custom JSON unmarshaling

type ValidatorFunc

type ValidatorFunc struct {
	Name      string
	Validator validator.Func
}

custom struct for validation function

type WithValidator

type WithValidator func(name string, validateFn validator.Func) ValidatorFunc

custom type for custom validation function

Jump to

Keyboard shortcuts

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