Documentation
¶
Overview ¶
Package gin provides a wrapper around the Gin web framework This package exposes commonly used Gin functionality through a clean interface while maintaining compatibility with the underlying gin.Engine and gin.Context
Index ¶
- Variables
- func CORS() backends.MiddlewareFunc
- func CORSWithConfig(config backends.CORSConfig) backends.MiddlewareFunc
- func CreateEngine() backends.Engine
- func CreateEngineWithDefaults() backends.Engine
- func CreateEventHandler(relayServer *cluster.RelayServer) backends.RealtimeEventHandler
- func CreateProcessSubscription(wsConn *websocket.Conn, wsMsgType int, processID string, executorType string, ...) *backends.RealtimeSubscription
- func CreateProcessesSubscription(wsConn *websocket.Conn, wsMsgType int, executorType string, timeout int, ...) *backends.RealtimeSubscription
- func CreateSubscription(wsConn *websocket.Conn, wsMsgType int, processID string, executorType string, ...) *backends.RealtimeSubscription
- func CreateTestableEventHandler(relayServer *cluster.RelayServer) backends.TestableRealtimeEventHandler
- func IsDebugging() bool
- func Mode() string
- func NewBackendServer(port int, engine backends.Engine) backends.Server
- func NewBackendServerWithAddr(addr string, engine backends.Engine) backends.Server
- func NewContextAdapter(ginContext *ginframework.Context) backends.Context
- func NewEngineAdapter(ginEngine *Engine) backends.Engine
- func NewFactory() backends.RealtimeBackend
- func NewServerAdapter(ginServer *Server) backends.Server
- func NewSubscriptionController(eventHandler backends.RealtimeEventHandler) backends.RealtimeSubscriptionController
- func NewWebSocketConnection(conn *websocket.Conn) backends.RealtimeConnection
- func SetMode(value string)
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithStatus(code int)
- func (c *Context) AbortWithStatusJSON(code int, jsonObj interface{})
- func (c *Context) Bind(obj interface{}) error
- func (c *Context) BindJSON(obj interface{}) error
- func (c *Context) Data(code int, contentType string, data []byte)
- func (c *Context) DefaultPostForm(key, defaultValue string) string
- func (c *Context) DefaultQuery(key, defaultValue string) string
- func (c *Context) Get(key string) (value interface{}, exists bool)
- func (c *Context) GetBool(key string) (b bool)
- func (c *Context) GetFloat64(key string) (f64 float64)
- func (c *Context) GetHeader(key string) string
- func (c *Context) GetInt(key string) (i int)
- func (c *Context) GetInt64(key string) (i64 int64)
- func (c *Context) GetString(key string) (s string)
- func (c *Context) GinContext() *gin.Context
- func (c *Context) Header(key, value string)
- func (c *Context) IsAborted() bool
- func (c *Context) JSON(code int, obj interface{})
- func (c *Context) Next()
- func (c *Context) Param(key string) string
- func (c *Context) PostForm(key string) string
- func (c *Context) Query(key string) string
- func (c *Context) ReadBody() ([]byte, error)
- func (c *Context) Request() *http.Request
- func (c *Context) Set(key string, value interface{})
- func (c *Context) ShouldBind(obj interface{}) error
- func (c *Context) ShouldBindJSON(obj interface{}) error
- func (c *Context) Status(code int)
- func (c *Context) String(code int, format string, values ...interface{})
- func (c *Context) Writer() gin.ResponseWriter
- func (c *Context) XML(code int, obj interface{})
- type ContextAdapter
- func (g *ContextAdapter) Abort()
- func (g *ContextAdapter) AbortWithStatus(code int)
- func (g *ContextAdapter) AbortWithStatusJSON(code int, jsonObj interface{})
- func (g *ContextAdapter) Bind(obj interface{}) error
- func (g *ContextAdapter) BindJSON(obj interface{}) error
- func (g *ContextAdapter) Data(code int, contentType string, data []byte)
- func (g *ContextAdapter) DefaultPostForm(key, defaultValue string) string
- func (g *ContextAdapter) DefaultQuery(key, defaultValue string) string
- func (g *ContextAdapter) Get(key string) (value interface{}, exists bool)
- func (g *ContextAdapter) GetBool(key string) bool
- func (g *ContextAdapter) GetFloat64(key string) float64
- func (g *ContextAdapter) GetHeader(key string) string
- func (g *ContextAdapter) GetInt(key string) int
- func (g *ContextAdapter) GetInt64(key string) int64
- func (g *ContextAdapter) GetString(key string) string
- func (g *ContextAdapter) GinContext() *ginframework.Context
- func (g *ContextAdapter) Header(key, value string)
- func (g *ContextAdapter) IsAborted() bool
- func (g *ContextAdapter) JSON(code int, obj interface{})
- func (g *ContextAdapter) Next()
- func (g *ContextAdapter) Param(key string) string
- func (g *ContextAdapter) PostForm(key string) string
- func (g *ContextAdapter) Query(key string) string
- func (g *ContextAdapter) ReadBody() ([]byte, error)
- func (g *ContextAdapter) Request() *http.Request
- func (g *ContextAdapter) Set(key string, value interface{})
- func (g *ContextAdapter) ShouldBind(obj interface{}) error
- func (g *ContextAdapter) ShouldBindJSON(obj interface{}) error
- func (g *ContextAdapter) Status(code int)
- func (g *ContextAdapter) String(code int, format string, values ...interface{})
- func (g *ContextAdapter) XML(code int, obj interface{})
- type DefaultEventHandler
- func (handler *DefaultEventHandler) HasStopped() bool
- func (handler *DefaultEventHandler) NumberOfListeners(executorType string, state int, location string) (int, int, int)
- func (handler *DefaultEventHandler) Signal(process *core.Process)
- func (handler *DefaultEventHandler) Stop()
- func (handler *DefaultEventHandler) Subscribe(executorType string, state int, processID string, location string, ...) (chan *core.Process, chan error)
- func (handler *DefaultEventHandler) WaitForProcess(executorType string, state int, processID string, location string, ...) (*core.Process, error)
- type Engine
- func (e *Engine) DELETE(relativePath string, handlers ...HandlerFunc)
- func (e *Engine) GET(relativePath string, handlers ...HandlerFunc)
- func (e *Engine) GinEngine() *gin.Engine
- func (e *Engine) Handler() http.Handler
- func (e *Engine) PATCH(relativePath string, handlers ...HandlerFunc)
- func (e *Engine) POST(relativePath string, handlers ...HandlerFunc)
- func (e *Engine) PUT(relativePath string, handlers ...HandlerFunc)
- func (e *Engine) Use(middleware ...HandlerFunc)
- func (e *Engine) UseCORS()
- func (e *Engine) UseCORSWithConfig(config cors.Config)
- type EngineAdapter
- func (g *EngineAdapter) DELETE(relativePath string, handlers ...backends.HandlerFunc)
- func (g *EngineAdapter) GET(relativePath string, handlers ...backends.HandlerFunc)
- func (g *EngineAdapter) Handler() http.Handler
- func (g *EngineAdapter) PATCH(relativePath string, handlers ...backends.HandlerFunc)
- func (g *EngineAdapter) POST(relativePath string, handlers ...backends.HandlerFunc)
- func (g *EngineAdapter) PUT(relativePath string, handlers ...backends.HandlerFunc)
- func (g *EngineAdapter) Use(middleware ...backends.HandlerFunc)
- type Factory
- func (f *Factory) CreateConnection(rawConn interface{}) (backends.RealtimeConnection, error)
- func (f *Factory) CreateEventHandler(relayServer interface{}) backends.RealtimeEventHandler
- func (f *Factory) CreateSubscriptionController(eventHandler backends.RealtimeEventHandler) backends.RealtimeSubscriptionController
- func (f *Factory) CreateTestableEventHandler(relayServer interface{}) backends.TestableRealtimeEventHandler
- type HandlerFunc
- type MiddlewareFunc
- type RealtimeHandler
- type RealtimeServer
- type Server
- func (s *Server) Engine() *Engine
- func (s *Server) GetAddr() string
- func (s *Server) HTTPServer() *http.Server
- func (s *Server) ListenAndServe() error
- func (s *Server) ListenAndServeTLS(certFile, keyFile string) error
- func (s *Server) SetAddr(addr string)
- func (s *Server) SetIdleTimeout(timeout time.Duration)
- func (s *Server) SetReadHeaderTimeout(timeout time.Duration)
- func (s *Server) SetReadTimeout(timeout time.Duration)
- func (s *Server) SetWriteTimeout(timeout time.Duration)
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) ShutdownWithTimeout(timeout time.Duration) error
- type ServerAdapter
- func (g *ServerAdapter) Engine() backends.Engine
- func (g *ServerAdapter) GetAddr() string
- func (g *ServerAdapter) HTTPServer() *http.Server
- func (g *ServerAdapter) ListenAndServe() error
- func (g *ServerAdapter) ListenAndServeTLS(certFile, keyFile string) error
- func (g *ServerAdapter) SetAddr(addr string)
- func (g *ServerAdapter) SetIdleTimeout(timeout time.Duration)
- func (g *ServerAdapter) SetReadHeaderTimeout(timeout time.Duration)
- func (g *ServerAdapter) SetReadTimeout(timeout time.Duration)
- func (g *ServerAdapter) SetWriteTimeout(timeout time.Duration)
- func (g *ServerAdapter) Shutdown(ctx context.Context) error
- func (g *ServerAdapter) ShutdownWithTimeout(timeout time.Duration) error
- type ServerHelpers
- func (h *ServerHelpers) ExtractGinContext(c backends.Context) (*gin.Context, bool)
- func (h *ServerHelpers) HandleContextUnion(c interface{}) (backends.Context, *gin.Context, bool)
- func (h *ServerHelpers) HandleHTTPErrorContext(c backends.Context, err error, errorCode int) bool
- func (h *ServerHelpers) HandleHTTPErrorGin(c *gin.Context, err error, errorCode int) bool
- func (h *ServerHelpers) SendEmptyHTTPReplyGin(c *gin.Context, payloadType string)
- func (h *ServerHelpers) SendHTTPReplyGin(c *gin.Context, payloadType string, jsonString string)
- type SubscriptionController
- type WSController
- type WebSocketConnection
Constants ¶
This section is empty.
Variables ¶
var ( ErrConnectionClosed = errors.New("websocket connection is closed") ErrInvalidConnType = errors.New("invalid connection type for websocket implementation") )
Functions ¶
func CORS ¶ added in v1.9.6
func CORS() backends.MiddlewareFunc
CORS returns the default CORS middleware
func CORSWithConfig ¶ added in v1.9.6
func CORSWithConfig(config backends.CORSConfig) backends.MiddlewareFunc
CORSWithConfig returns CORS middleware with custom configuration
func CreateEngine ¶ added in v1.9.6
CreateEngine creates a new blank Engine without middleware, wrapped as backends.Engine
func CreateEngineWithDefaults ¶ added in v1.9.6
CreateEngineWithDefaults creates a new Engine with default middleware, wrapped as backends.Engine
func CreateEventHandler ¶
func CreateEventHandler(relayServer *cluster.RelayServer) backends.RealtimeEventHandler
CreateEventHandler creates a new DefaultEventHandler
func CreateSubscription ¶
func CreateSubscription(wsConn *websocket.Conn, wsMsgType int, processID string, executorType string, state int, timeout int) *backends.RealtimeSubscription
Utility functions for backward compatibility with existing websocket code
func CreateTestableEventHandler ¶
func CreateTestableEventHandler(relayServer *cluster.RelayServer) backends.TestableRealtimeEventHandler
CreateTestableEventHandler creates a new DefaultEventHandler that implements TestableRealtimeEventHandler for testing
func IsDebugging ¶
func IsDebugging() bool
IsDebugging returns true if the framework is running in debug mode
func NewBackendServer ¶ added in v1.9.6
NewBackendServer creates a new Server from a backends.Engine, wrapped as backends.Server
func NewBackendServerWithAddr ¶ added in v1.9.6
NewBackendServerWithAddr creates a new Server with address from a backends.Engine
func NewContextAdapter ¶
func NewContextAdapter(ginContext *ginframework.Context) backends.Context
NewContextAdapter creates a new adapter for gin.Context
func NewEngineAdapter ¶
NewEngineAdapter creates a new adapter for gin.Engine
func NewFactory ¶
func NewFactory() backends.RealtimeBackend
NewFactory creates a new WebSocket factory
func NewServerAdapter ¶
NewServerAdapter creates a new adapter for gin.Server
func NewSubscriptionController ¶
func NewSubscriptionController(eventHandler backends.RealtimeEventHandler) backends.RealtimeSubscriptionController
NewSubscriptionController creates a new WebSocket subscription controller
func NewWebSocketConnection ¶
func NewWebSocketConnection(conn *websocket.Conn) backends.RealtimeConnection
NewWebSocketConnection creates a new WebSocketConnection
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context wraps gin.Context with additional functionality
func NewContext ¶
NewContext creates a new Context wrapper
func (*Context) AbortWithStatus ¶
AbortWithStatus calls Abort() and writes the headers with the specified status code
func (*Context) AbortWithStatusJSON ¶
AbortWithStatusJSON calls Abort() and then JSON() internally
func (*Context) DefaultPostForm ¶
DefaultPostForm returns the specified key from a POST urlencoded form or multipart form, otherwise returns the default value
func (*Context) DefaultQuery ¶
DefaultQuery returns the keyed url query value if it exists, otherwise returns the default value
func (*Context) GetFloat64 ¶
GetFloat64 returns the value associated with the key as a float64
func (*Context) GinContext ¶
GinContext returns the underlying gin.Context
func (*Context) PostForm ¶
PostForm returns the specified key from a POST urlencoded form or multipart form
func (*Context) ShouldBind ¶
ShouldBind checks the Content-Type to select a binding engine automatically
func (*Context) ShouldBindJSON ¶
ShouldBindJSON is a shortcut for c.ShouldBind(obj) with binding.JSON
func (*Context) Writer ¶
func (c *Context) Writer() gin.ResponseWriter
Writer returns the response writer
type ContextAdapter ¶
type ContextAdapter struct {
// contains filtered or unexported fields
}
ContextAdapter adapts gin.Context to the generic Context interface
func (*ContextAdapter) Abort ¶
func (g *ContextAdapter) Abort()
func (*ContextAdapter) AbortWithStatus ¶
func (g *ContextAdapter) AbortWithStatus(code int)
func (*ContextAdapter) AbortWithStatusJSON ¶
func (g *ContextAdapter) AbortWithStatusJSON(code int, jsonObj interface{})
func (*ContextAdapter) Bind ¶
func (g *ContextAdapter) Bind(obj interface{}) error
func (*ContextAdapter) BindJSON ¶
func (g *ContextAdapter) BindJSON(obj interface{}) error
func (*ContextAdapter) Data ¶
func (g *ContextAdapter) Data(code int, contentType string, data []byte)
func (*ContextAdapter) DefaultPostForm ¶
func (g *ContextAdapter) DefaultPostForm(key, defaultValue string) string
func (*ContextAdapter) DefaultQuery ¶
func (g *ContextAdapter) DefaultQuery(key, defaultValue string) string
func (*ContextAdapter) Get ¶
func (g *ContextAdapter) Get(key string) (value interface{}, exists bool)
func (*ContextAdapter) GetBool ¶
func (g *ContextAdapter) GetBool(key string) bool
func (*ContextAdapter) GetFloat64 ¶
func (g *ContextAdapter) GetFloat64(key string) float64
func (*ContextAdapter) GetHeader ¶
func (g *ContextAdapter) GetHeader(key string) string
func (*ContextAdapter) GetInt ¶
func (g *ContextAdapter) GetInt(key string) int
func (*ContextAdapter) GetInt64 ¶
func (g *ContextAdapter) GetInt64(key string) int64
func (*ContextAdapter) GetString ¶
func (g *ContextAdapter) GetString(key string) string
func (*ContextAdapter) GinContext ¶
func (g *ContextAdapter) GinContext() *ginframework.Context
GinContext returns the underlying raw gin.Context - needed for realtime handler
func (*ContextAdapter) Header ¶
func (g *ContextAdapter) Header(key, value string)
func (*ContextAdapter) IsAborted ¶
func (g *ContextAdapter) IsAborted() bool
func (*ContextAdapter) JSON ¶
func (g *ContextAdapter) JSON(code int, obj interface{})
func (*ContextAdapter) Next ¶
func (g *ContextAdapter) Next()
func (*ContextAdapter) Param ¶
func (g *ContextAdapter) Param(key string) string
func (*ContextAdapter) PostForm ¶
func (g *ContextAdapter) PostForm(key string) string
func (*ContextAdapter) Query ¶
func (g *ContextAdapter) Query(key string) string
func (*ContextAdapter) ReadBody ¶
func (g *ContextAdapter) ReadBody() ([]byte, error)
func (*ContextAdapter) Request ¶
func (g *ContextAdapter) Request() *http.Request
func (*ContextAdapter) Set ¶
func (g *ContextAdapter) Set(key string, value interface{})
func (*ContextAdapter) ShouldBind ¶
func (g *ContextAdapter) ShouldBind(obj interface{}) error
func (*ContextAdapter) ShouldBindJSON ¶
func (g *ContextAdapter) ShouldBindJSON(obj interface{}) error
func (*ContextAdapter) Status ¶
func (g *ContextAdapter) Status(code int)
func (*ContextAdapter) String ¶
func (g *ContextAdapter) String(code int, format string, values ...interface{})
func (*ContextAdapter) XML ¶
func (g *ContextAdapter) XML(code int, obj interface{})
type DefaultEventHandler ¶
type DefaultEventHandler struct {
// contains filtered or unexported fields
}
DefaultEventHandler implements the backends.RealtimeEventHandler interface.
Signal Distribution Strategy (Thundering Herd Prevention):
This event handler uses a two-pass signal distribution to prevent the "thundering herd" problem that can cause massive database load amplification.
The Problem: When a new process is submitted, executors waiting for work need to be notified. If ALL waiting executors wake up simultaneously (broadcast), they all call Assign() at once, creating a stampede of database operations. With 8 executors and buffered channels allowing rapid re-wake, this caused 1,840x amplification in production (19.7M database updates for 1,341 processes instead of ~10K expected).
The Solution - Two-Pass Distribution:
Pass 1 (Broadcast): Notify ALL listeners waiting for a SPECIFIC processID. This is used for state change notifications (e.g., process completed) where the caller needs to know about their specific process.
Pass 2 (Single Wake-up with Round-Robin): Wake exactly ONE general listener. General listeners are executors waiting for ANY process of their type. Only one executor should wake up per signal to attempt assignment. Round-robin ensures fair distribution across executors.
Round-Robin Load Balancing: The nextExecutor map tracks which executor should receive the next signal for each target (executorType+state combination). This ensures all executors get equal opportunity to receive work, preventing any single executor from being starved or overloaded.
func (*DefaultEventHandler) HasStopped ¶
func (handler *DefaultEventHandler) HasStopped() bool
func (*DefaultEventHandler) NumberOfListeners ¶
func (handler *DefaultEventHandler) NumberOfListeners(executorType string, state int, location string) (int, int, int)
Additional methods for testing (not part of interface)
func (*DefaultEventHandler) Signal ¶
func (handler *DefaultEventHandler) Signal(process *core.Process)
Signal implements EventHandler interface
func (*DefaultEventHandler) Stop ¶
func (handler *DefaultEventHandler) Stop()
Stop implements EventHandler interface
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine wraps gin.Engine with additional functionality
func Default ¶
func Default() *Engine
Default creates a new Engine instance with default middleware (Logger and Recovery)
func NewEngineWithGin ¶
NewEngineWithGin creates a new Engine wrapper with an existing gin.Engine
func (*Engine) DELETE ¶
func (e *Engine) DELETE(relativePath string, handlers ...HandlerFunc)
DELETE adds a DELETE route handler
func (*Engine) GET ¶
func (e *Engine) GET(relativePath string, handlers ...HandlerFunc)
GET adds a GET route handler
func (*Engine) PATCH ¶
func (e *Engine) PATCH(relativePath string, handlers ...HandlerFunc)
PATCH adds a PATCH route handler
func (*Engine) POST ¶
func (e *Engine) POST(relativePath string, handlers ...HandlerFunc)
POST adds a POST route handler
func (*Engine) PUT ¶
func (e *Engine) PUT(relativePath string, handlers ...HandlerFunc)
PUT adds a PUT route handler
func (*Engine) Use ¶
func (e *Engine) Use(middleware ...HandlerFunc)
Use adds middleware to the engine
func (*Engine) UseCORS ¶
func (e *Engine) UseCORS()
UseCORS adds CORS middleware with default configuration
func (*Engine) UseCORSWithConfig ¶
UseCORSWithConfig adds CORS middleware with custom configuration
type EngineAdapter ¶
type EngineAdapter struct {
// contains filtered or unexported fields
}
EngineAdapter adapts gin.Engine to the generic Engine interface
func (*EngineAdapter) DELETE ¶
func (g *EngineAdapter) DELETE(relativePath string, handlers ...backends.HandlerFunc)
func (*EngineAdapter) GET ¶
func (g *EngineAdapter) GET(relativePath string, handlers ...backends.HandlerFunc)
func (*EngineAdapter) Handler ¶
func (g *EngineAdapter) Handler() http.Handler
func (*EngineAdapter) PATCH ¶
func (g *EngineAdapter) PATCH(relativePath string, handlers ...backends.HandlerFunc)
func (*EngineAdapter) POST ¶
func (g *EngineAdapter) POST(relativePath string, handlers ...backends.HandlerFunc)
func (*EngineAdapter) PUT ¶
func (g *EngineAdapter) PUT(relativePath string, handlers ...backends.HandlerFunc)
func (*EngineAdapter) Use ¶
func (g *EngineAdapter) Use(middleware ...backends.HandlerFunc)
type Factory ¶
type Factory struct{}
Factory implements the backends.RealtimeBackend interface for WebSocket
func (*Factory) CreateConnection ¶
func (f *Factory) CreateConnection(rawConn interface{}) (backends.RealtimeConnection, error)
CreateConnection creates a WebSocket connection from a raw websocket.Conn
func (*Factory) CreateEventHandler ¶
func (f *Factory) CreateEventHandler(relayServer interface{}) backends.RealtimeEventHandler
CreateEventHandler creates an event handler
func (*Factory) CreateSubscriptionController ¶
func (f *Factory) CreateSubscriptionController(eventHandler backends.RealtimeEventHandler) backends.RealtimeSubscriptionController
CreateSubscriptionController creates a subscription controller
func (*Factory) CreateTestableEventHandler ¶
func (f *Factory) CreateTestableEventHandler(relayServer interface{}) backends.TestableRealtimeEventHandler
CreateTestableEventHandler creates a testable event handler
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc defines the signature for route handlers in our wrapper
func BasicAuth ¶
func BasicAuth(accounts gin.Accounts) HandlerFunc
BasicAuth returns a Basic HTTP Authorization middleware
func LoggerWithFormatter ¶
func LoggerWithFormatter(f gin.LogFormatter) HandlerFunc
LoggerWithFormatter returns a gin.HandlerFunc for logging with custom formatter
func LoggerWithWriter ¶
func LoggerWithWriter(out gin.LogFormatter, notlogged ...string) HandlerFunc
LoggerWithWriter returns a gin.HandlerFunc for logging with custom writer
func Recovery ¶
func Recovery() HandlerFunc
Recovery middleware recovers from any panics and writes a 500 if there was one
type MiddlewareFunc ¶
type MiddlewareFunc = HandlerFunc
MiddlewareFunc is an alias for HandlerFunc to represent middleware
type RealtimeHandler ¶
type RealtimeHandler struct {
// contains filtered or unexported fields
}
RealtimeHandler handles WebSocket connections for gin backend
func NewRealtimeHandler ¶
func NewRealtimeHandler(server RealtimeServer) *RealtimeHandler
NewRealtimeHandler creates a new realtime handler for gin backend
func (*RealtimeHandler) HandleWSRequest ¶
func (h *RealtimeHandler) HandleWSRequest(c backends.Context)
HandleWSRequest handles WebSocket upgrade and message processing for Gin
type RealtimeServer ¶
type RealtimeServer interface {
HandleHTTPError(c backends.Context, err error, errorCode int) bool
ParseSignature(payload string, signature string) (string, error)
GenerateRPCErrorMsg(err error, errorCode int) (*rpc.RPCReplyMsg, error)
WSController() WSController
ChannelRouter() *channel.Router
ProcessDB() database.ProcessDatabase
Validator() security.Validator
}
RealtimeServer interface for servers that can handle realtime connections
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps http.Server with gin integration
func NewServerWithAddr ¶
NewServerWithAddr creates a new HTTP server with the given address and engine
func (*Server) HTTPServer ¶
HTTPServer returns the underlying http.Server
func (*Server) ListenAndServe ¶
ListenAndServe starts the server and blocks until an error occurs
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS starts the HTTPS server and blocks until an error occurs
func (*Server) SetIdleTimeout ¶
SetIdleTimeout sets the idle timeout for the HTTP server
func (*Server) SetReadHeaderTimeout ¶
SetReadHeaderTimeout sets the read header timeout for the HTTP server
func (*Server) SetReadTimeout ¶
SetReadTimeout sets the read timeout for the HTTP server
func (*Server) SetWriteTimeout ¶
SetWriteTimeout sets the write timeout for the HTTP server
type ServerAdapter ¶
type ServerAdapter struct {
// contains filtered or unexported fields
}
ServerAdapter adapts gin.Server to the generic Server interface
func (*ServerAdapter) Engine ¶
func (g *ServerAdapter) Engine() backends.Engine
func (*ServerAdapter) GetAddr ¶
func (g *ServerAdapter) GetAddr() string
func (*ServerAdapter) HTTPServer ¶
func (g *ServerAdapter) HTTPServer() *http.Server
func (*ServerAdapter) ListenAndServe ¶
func (g *ServerAdapter) ListenAndServe() error
func (*ServerAdapter) ListenAndServeTLS ¶
func (g *ServerAdapter) ListenAndServeTLS(certFile, keyFile string) error
func (*ServerAdapter) SetAddr ¶
func (g *ServerAdapter) SetAddr(addr string)
func (*ServerAdapter) SetIdleTimeout ¶
func (g *ServerAdapter) SetIdleTimeout(timeout time.Duration)
func (*ServerAdapter) SetReadHeaderTimeout ¶
func (g *ServerAdapter) SetReadHeaderTimeout(timeout time.Duration)
func (*ServerAdapter) SetReadTimeout ¶
func (g *ServerAdapter) SetReadTimeout(timeout time.Duration)
func (*ServerAdapter) SetWriteTimeout ¶
func (g *ServerAdapter) SetWriteTimeout(timeout time.Duration)
func (*ServerAdapter) ShutdownWithTimeout ¶
func (g *ServerAdapter) ShutdownWithTimeout(timeout time.Duration) error
type ServerHelpers ¶
type ServerHelpers struct{}
ServerHelpers provides gin-specific server helper functions
func NewServerHelpers ¶
func NewServerHelpers() *ServerHelpers
NewServerHelpers creates new gin server helpers
func (*ServerHelpers) ExtractGinContext ¶
ExtractGinContext extracts gin.Context from a generic Context
func (*ServerHelpers) HandleContextUnion ¶
HandleContextUnion handles both gin.Context and backends.Context types
func (*ServerHelpers) HandleHTTPErrorContext ¶
HandleHTTPErrorContext handles HTTP errors for generic contexts by checking if they're gin contexts
func (*ServerHelpers) HandleHTTPErrorGin ¶
HandleHTTPErrorGin handles HTTP errors for gin contexts
func (*ServerHelpers) SendEmptyHTTPReplyGin ¶
func (h *ServerHelpers) SendEmptyHTTPReplyGin(c *gin.Context, payloadType string)
SendEmptyHTTPReplyGin sends empty HTTP reply for gin contexts
func (*ServerHelpers) SendHTTPReplyGin ¶
func (h *ServerHelpers) SendHTTPReplyGin(c *gin.Context, payloadType string, jsonString string)
SendHTTPReplyGin sends HTTP reply for gin contexts
type SubscriptionController ¶
type SubscriptionController struct {
// contains filtered or unexported fields
}
SubscriptionController implements the backends.RealtimeSubscriptionController interface
func (*SubscriptionController) AddProcessSubscriber ¶
func (ctrl *SubscriptionController) AddProcessSubscriber(executorID string, process *core.Process, subscription *backends.RealtimeSubscription) error
AddProcessSubscriber implements backends.RealtimeSubscriptionController
func (*SubscriptionController) AddProcessesSubscriber ¶
func (ctrl *SubscriptionController) AddProcessesSubscriber(executorID string, subscription *backends.RealtimeSubscription) error
AddProcessesSubscriber implements backends.RealtimeSubscriptionController
type WSController ¶
type WSController interface {
SubscribeProcesses(executorID string, subscription *backends.RealtimeSubscription) error
SubscribeProcess(executorID string, subscription *backends.RealtimeSubscription) error
}
WSController interface for WebSocket handlers
type WebSocketConnection ¶
type WebSocketConnection struct {
// contains filtered or unexported fields
}
WebSocketConnection implements the backends.RealtimeConnection interface
func (*WebSocketConnection) Close ¶
func (w *WebSocketConnection) Close() error
Close implements backends.RealtimeConnection
func (*WebSocketConnection) IsOpen ¶
func (w *WebSocketConnection) IsOpen() bool
IsOpen implements backends.RealtimeConnection
func (*WebSocketConnection) WriteMessage ¶
func (w *WebSocketConnection) WriteMessage(msgType int, data []byte) error
WriteMessage implements backends.RealtimeConnection