{"modulePath":"github.com/bitechdev/ResolveSpec","version":"v1.3.14","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package websocketspec\n\nPackage websocketspec provides a WebSocket-based API specification for real-time CRUD operations with bidirectional communication and subscription support.\n\n### Key Features {#hdr-Key_Features}\n\n  - Real-time bidirectional communication over WebSocket\n  - CRUD operations (Create, Read, Update, Delete)\n  - Real-time subscriptions with filtering\n  - Lifecycle hooks for all operations\n  - Database-agnostic: Works with GORM and Bun ORM through adapters\n  - Automatic change notifications to subscribers\n  - Connection and subscription management\n\n### Message Protocol {#hdr-Message_Protocol}\n\nWebSocketSpec uses JSON messages for communication:\n\n\t{\n\t  \"id\": \"unique-message-id\",\n\t  \"type\": \"request|response|notification|subscription\",\n\t  \"operation\": \"read|create|update|delete|subscribe|unsubscribe\",\n\t  \"schema\": \"public\",\n\t  \"entity\": \"users\",\n\t  \"data\": {...},\n\t  \"options\": {\n\t    \"filters\": [...],\n\t    \"columns\": [...],\n\t    \"preload\": [...],\n\t    \"sort\": [...],\n\t    \"limit\": 10\n\t  }\n\t}\n\n### Usage Example {#hdr-Usage_Example}\n\n\t// Create handler with GORM\n\thandler := websocketspec.NewHandlerWithGORM(db)\n\n\t// Register models\n\thandler.Registry.RegisterModel(\"public.users\", \u0026User{})\n\n\t// Setup WebSocket endpoint\n\thttp.HandleFunc(\"/ws\", handler.HandleWebSocket)\n\n\t// Start server\n\thttp.ListenAndServe(\":8080\", nil)\n\n### Client Example {#hdr-Client_Example}\n\n\t// Connect to WebSocket\n\tws := new WebSocket(\"ws://localhost:8080/ws\")\n\n\t// Send read request\n\tws.send(JSON.stringify({\n\t  id: \"msg-1\",\n\t  type: \"request\",\n\t  operation: \"read\",\n\t  entity: \"users\",\n\t  options: {\n\t    filters: [{column: \"status\", operator: \"eq\", value: \"active\"}],\n\t    limit: 10\n\t  }\n\t}))\n\n\t// Subscribe to changes\n\tws.send(JSON.stringify({\n\t  id: \"msg-2\",\n\t  type: \"subscription\",\n\t  operation: \"subscribe\",\n\t  entity: \"users\",\n\t  options: {\n\t    filters: [{column: \"status\", operator: \"eq\", value: \"active\"}]\n\t  }\n\t}))\n\n## Functions\n\n```go\nfunc ExampleAuthentication()\n```\nExampleAuthentication shows how to implement authentication\n\n```go\nfunc ExampleCRUDOperations()\n```\nExampleCRUDOperations shows basic CRUD operations\n\n```go\nfunc ExampleWithBun(bunDB *bun.DB)\n```\nExampleWithBun shows how to use WebSocketSpec with Bun ORM\n\n```go\nfunc ExampleWithGORM(db *gorm.DB)\n```\nExampleWithGORM shows how to use WebSocketSpec with GORM\n\n```go\nfunc ExampleWithHooks(db *gorm.DB)\n```\nExampleWithHooks shows how to use lifecycle hooks\n\n```go\nfunc ExampleWithSubscriptions()\n```\nExampleWithSubscriptions shows subscription usage\n\n```go\nfunc RegisterSecurityHooks(handler *Handler, securityList *security.SecurityList)\n```\nRegisterSecurityHooks registers all security-related hooks with the handler\n\n## Types\n\n```go\ntype BroadcastMessage struct {\n\t// Message is the message to broadcast\n\tMessage []byte\n\n\t// Filter is an optional function to filter which connections receive the message\n\tFilter func(*Connection) bool\n}\n```\nBroadcastMessage represents a message to broadcast to multiple connections\n\n```go\ntype Connection struct {\n\t// ID is a unique identifier for this connection\n\tID string\n\t// contains filtered or unexported fields\n}\n```\nConnection rvepresents a WebSocket connection with its state\n\n```go\nfunc NewConnection(id string, ws *websocket.Conn, handler *Handler) *Connection\n```\nNewConnection creates a new WebSocket connection\n\n```go\nfunc (c *Connection) AddSubscription(sub *Subscription)\n```\nAddSubscription adds a subscription to this connection\n\n```go\nfunc (c *Connection) Close()\n```\nClose closes the connection\n\n```go\nfunc (c *Connection) GetMetadata(key string) (interface{}, bool)\n```\nGetMetadata retrieves metadata for this connection\n\n```go\nfunc (c *Connection) GetSubscription(subID string) (*Subscription, bool)\n```\nGetSubscription retrieves a subscription by ID\n\n```go\nfunc (c *Connection) ReadPump()\n```\nReadPump reads messages from the WebSocket connection\n\n```go\nfunc (c *Connection) RemoveSubscription(subID string)\n```\nRemoveSubscription removes a subscription from this connection\n\n```go\nfunc (c *Connection) Send(message []byte) error\n```\nSend sends a message to this connection\n\n```go\nfunc (c *Connection) SendJSON(v interface{}) error\n```\nSendJSON sends a JSON-encoded message to this connection\n\n```go\nfunc (c *Connection) SetMetadata(key string, value interface{})\n```\nSetMetadata sets metadata for this connection\n\n```go\nfunc (c *Connection) WritePump()\n```\nWritePump writes messages to the WebSocket connection\n\n```go\ntype ConnectionManager struct {\n\t// contains filtered or unexported fields\n}\n```\nConnectionManager manages all active WebSocket connections\n\n```go\nfunc NewConnectionManager(ctx context.Context) *ConnectionManager\n```\nNewConnectionManager creates a new connection manager\n\n```go\nfunc (cm *ConnectionManager) Broadcast(message []byte, filter func(*Connection) bool)\n```\nBroadcast sends a message to all connections matching the filter\n\n```go\nfunc (cm *ConnectionManager) Count() int\n```\nCount returns the number of active connections\n\n```go\nfunc (cm *ConnectionManager) GetConnection(id string) (*Connection, bool)\n```\nGetConnection retrieves a connection by ID\n\n```go\nfunc (cm *ConnectionManager) Register(conn *Connection)\n```\nRegister registers a new connection\n\n```go\nfunc (cm *ConnectionManager) Run()\n```\nRun starts the connection manager event loop\n\n```go\nfunc (cm *ConnectionManager) Shutdown()\n```\nShutdown gracefully shuts down the connection manager\n\n```go\nfunc (cm *ConnectionManager) Unregister(conn *Connection)\n```\nUnregister removes a connection\n\n```go\ntype ErrorInfo struct {\n\t// Code is the error code\n\tCode string `json:\"code\"`\n\n\t// Message is a human-readable error message\n\tMessage string `json:\"message\"`\n\n\t// Details contains additional error context\n\tDetails map[string]interface{} `json:\"details,omitempty\"`\n\n\t// SQL is the query that caused the error, populated for database errors\n\tSQL string `json:\"sql,omitempty\"`\n}\n```\nErrorInfo contains error details\n\n```go\ntype Handler struct {\n\t// contains filtered or unexported fields\n}\n```\nHandler handles WebSocket connections and messages\n\n```go\nfunc NewHandler(db common.Database, registry common.ModelRegistry) *Handler\n```\nNewHandler creates a new WebSocket handler\n\n```go\nfunc NewHandlerWithBun(db *bun.DB) *Handler\n```\nNewHandlerWithBun creates a new Handler with Bun adapter\n\n```go\nfunc NewHandlerWithDatabase(db common.Database, registry common.ModelRegistry) *Handler\n```\nNewHandlerWithDatabase creates a new Handler with a custom database adapter\n\n```go\nfunc NewHandlerWithGORM(db *gorm.DB) *Handler\n```\nNewHandlerWithGORM creates a new Handler with GORM adapter\n\n```go\nfunc (h *Handler) BroadcastMessage(message interface{}, filter func(*Connection) bool) error\n```\nBroadcastMessage sends a message to all connections matching the filter\n\n```go\nfunc (h *Handler) FetchRowNumber(ctx context.Context, tableName string, pkName string, pkValue string, options *common.RequestOptions, model interface{}) (int64, error)\n```\nFetchRowNumber calculates the row number of a specific record based on sorting and filtering Returns the 1-based row number of the record with the given primary key value\n\n```go\nfunc (h *Handler) GetConnection(id string) (*Connection, bool)\n```\nGetConnection retrieves a connection by ID\n\n```go\nfunc (h *Handler) GetConnectionCount() int\n```\nGetConnectionCount returns the number of active connections\n\n```go\nfunc (h *Handler) GetDatabase() common.Database\n```\nGetDatabase returns the underlying database connection Implements common.SpecHandler interface\n\n```go\nfunc (h *Handler) GetRelationshipInfo(modelType reflect.Type, relationName string) *common.RelationshipInfo\n```\nGetRelationshipInfo implements the RelationshipInfoProvider interface This is a placeholder implementation - full relationship support can be added later\n\n```go\nfunc (h *Handler) GetSubscriptionCount() int\n```\nGetSubscriptionCount returns the number of active subscriptions\n\n```go\nfunc (h *Handler) HandleMessage(conn *Connection, msg *Message)\n```\nHandleMessage routes incoming messages to appropriate handlers\n\n```go\nfunc (h *Handler) HandleWebSocket(w http.ResponseWriter, r *http.Request)\n```\nHandleWebSocket upgrades HTTP connection to WebSocket\n\n```go\nfunc (h *Handler) Hooks() *HookRegistry\n```\nHooks returns the hook registry for this handler\n\n```go\nfunc (h *Handler) Registry() common.ModelRegistry\n```\nRegistry returns the model registry for this handler\n\n```go\nfunc (h *Handler) SetDisallowNulls(disallow bool)\n```\nSetDisallowNulls controls whether explicit null values in update payloads are ignored. By default a key present in the payload overwrites the stored value, including \"\" and null. When true, null values are skipped and the existing value is kept (\"\" still overwrites).\n\n```go\nfunc (h *Handler) Shutdown()\n```\nShutdown gracefully shuts down the handler\n\n```go\ntype HookContext struct {\n\t// Context is the request context\n\tContext context.Context\n\n\t// Handler provides access to the handler, database, and registry\n\tHandler *Handler\n\n\t// Connection is the WebSocket connection\n\tConnection *Connection\n\n\t// Message is the original message\n\tMessage *Message\n\n\t// Schema is the database schema\n\tSchema string\n\n\t// Entity is the table/model name\n\tEntity string\n\n\t// TableName is the actual database table name\n\tTableName string\n\n\t// Model is the registered model instance\n\tModel interface{}\n\n\t// ModelPtr is a pointer to the model for queries\n\tModelPtr interface{}\n\n\t// Options contains the parsed request options\n\tOptions *common.RequestOptions\n\n\t// Operation being dispatched (e.g. \"read\", \"create\", \"update\", \"delete\")\n\tOperation string\n\n\t// ID is the record ID for single-record operations\n\tID string\n\n\t// Data is the request data (for create/update operations)\n\tData interface{}\n\n\t// Result is the operation result (for after hooks)\n\tResult interface{}\n\n\t// Subscription is the subscription being created/removed\n\tSubscription *Subscription\n\n\t// Error is any error that occurred (for after hooks)\n\tError error\n\n\t// Allow hooks to abort the operation\n\tAbort        bool   // If set to true, the operation will be aborted\n\tAbortMessage string // Message to return if aborted\n\tAbortCode    int    // HTTP status code if aborted\n\n\t// Tx provides access to the database/transaction for executing additional SQL\n\tTx common.Database\n\n\t// Metadata is additional context data\n\tMetadata map[string]interface{}\n}\n```\nHookContext contains context information for hook execution\n\n```go\nfunc (c *HookContext) SetTx(tx common.Database)\n```\nSetTx points the context at the transaction in use (common.TxContext).\n\n```go\ntype HookFunc func(*HookContext) error\n```\nHookFunc is a function that processes a hook\n\n```go\ntype HookRegistry struct {\n\t// contains filtered or unexported fields\n}\n```\nHookRegistry manages lifecycle hooks\n\n```go\nfunc NewHookRegistry() *HookRegistry\n```\nNewHookRegistry creates a new hook registry\n\n```go\nfunc (hr *HookRegistry) Clear(hookType HookType)\n```\nClear removes all hooks of a specific type\n\n```go\nfunc (hr *HookRegistry) ClearAll()\n```\nClearAll removes all registered hooks\n\n```go\nfunc (hr *HookRegistry) Execute(hookType HookType, ctx *HookContext) error\n```\nExecute runs all hooks for a specific type\n\n```go\nfunc (hr *HookRegistry) ExecuteBeforeOp(hookType HookType, ctx *HookContext) error\n```\nExecuteBeforeOp executes the BeforeOp hook followed by the given SQL-operation hook (BeforeRead, BeforeCreate, BeforeUpdate, or BeforeDelete). BeforeOp always runs first so it can observe/veto every SQL operation regardless of type.\n\n```go\nfunc (hr *HookRegistry) HasHooks(hookType HookType) bool\n```\nHasHooks checks if any hooks are registered for a hook type\n\n```go\nfunc (hr *HookRegistry) Register(hookType HookType, fn HookFunc)\n```\nRegister registers a hook function for a specific hook type\n\n```go\nfunc (hr *HookRegistry) RegisterAfter(operation OperationType, fn HookFunc)\n```\nRegisterAfter registers a hook that runs after an operation Convenience method for AfterRead, AfterCreate, AfterUpdate, AfterDelete\n\n```go\nfunc (hr *HookRegistry) RegisterBefore(operation OperationType, fn HookFunc)\n```\nRegisterBefore registers a hook that runs before an operation Convenience method for BeforeRead, BeforeCreate, BeforeUpdate, BeforeDelete\n\n```go\ntype HookType string\n```\nHookType represents the type of lifecycle hook\n\n```go\nconst (\n\t// BeforeHandle fires after model resolution, before operation dispatch.\n\t// Use this for auth checks that need model rules and user context simultaneously.\n\tBeforeHandle HookType = \"before_handle\"\n\n\t// BeforeRead is called before a read operation\n\tBeforeRead HookType = \"before_read\"\n\t// AfterRead is called after a read operation\n\tAfterRead HookType = \"after_read\"\n\n\t// BeforeCreate is called before a create operation\n\tBeforeCreate HookType = \"before_create\"\n\t// AfterCreate is called after a create operation\n\tAfterCreate HookType = \"after_create\"\n\n\t// BeforeUpdate is called before an update operation\n\tBeforeUpdate HookType = \"before_update\"\n\t// AfterUpdate is called after an update operation\n\tAfterUpdate HookType = \"after_update\"\n\n\t// BeforeDelete is called before a delete operation\n\tBeforeDelete HookType = \"before_delete\"\n\t// AfterDelete is called after a delete operation\n\tAfterDelete HookType = \"after_delete\"\n\n\t// BeforeScan is called right before a read query is executed against the database,\n\t// after all filters/sort/pagination have been applied. Use this for row-level\n\t// security that needs to modify the query (stored in HookContext.Metadata[\"query\"]).\n\tBeforeScan HookType = \"before_scan\"\n\n\t// BeforeSubscribe is called before creating a subscription\n\tBeforeSubscribe HookType = \"before_subscribe\"\n\t// AfterSubscribe is called after creating a subscription\n\tAfterSubscribe HookType = \"after_subscribe\"\n\n\t// BeforeUnsubscribe is called before removing a subscription\n\tBeforeUnsubscribe HookType = \"before_unsubscribe\"\n\t// AfterUnsubscribe is called after removing a subscription\n\tAfterUnsubscribe HookType = \"after_unsubscribe\"\n\n\t// BeforeConnect is called when a new connection is established\n\tBeforeConnect HookType = \"before_connect\"\n\t// AfterConnect is called after a connection is established\n\tAfterConnect HookType = \"after_connect\"\n\n\t// BeforeDisconnect is called before a connection is closed\n\tBeforeDisconnect HookType = \"before_disconnect\"\n\t// AfterDisconnect is called after a connection is closed\n\tAfterDisconnect HookType = \"after_disconnect\"\n\n\t// BeforeOp fires immediately before every SQL operation (read, create, update, delete).\n\t// Unlike BeforeHandle, which fires once before operation dispatch, BeforeOp fires at each\n\t// individual SQL-operation hook point, so it runs once per statement executed.\n\tBeforeOp HookType = \"before_op\"\n\n\t// OnTxBegin fires once, first, inside every transaction the handler opens for a\n\t// read/create/update/delete message (including the second short transaction for\n\t// post-commit work). hookCtx.Tx is the transaction; use it to stamp\n\t// transaction-local state such as RLS settings. An error or abort rolls the\n\t// transaction back.\n\tOnTxBegin HookType = common.TxHookName\n)\n```\n\n```go\ntype Message struct {\n\t// ID is a unique identifier for request/response correlation\n\tID string `json:\"id,omitempty\"`\n\n\t// Type is the message type\n\tType MessageType `json:\"type\"`\n\n\t// Operation is the operation to perform\n\tOperation OperationType `json:\"operation,omitempty\"`\n\n\t// Schema is the database schema name\n\tSchema string `json:\"schema,omitempty\"`\n\n\t// Entity is the table/model name\n\tEntity string `json:\"entity,omitempty\"`\n\n\t// RecordID is the ID for single-record operations (update, delete, read by ID)\n\tRecordID string `json:\"record_id,omitempty\"`\n\n\t// Data contains the request/response payload\n\tData interface{} `json:\"data,omitempty\"`\n\n\t// Options contains query options (filters, sorting, pagination, etc.)\n\tOptions *common.RequestOptions `json:\"options,omitempty\"`\n\n\t// SubscriptionID is the subscription identifier\n\tSubscriptionID string `json:\"subscription_id,omitempty\"`\n\n\t// Success indicates if the operation was successful\n\tSuccess bool `json:\"success,omitempty\"`\n\n\t// Error contains error information\n\tError *ErrorInfo `json:\"error,omitempty\"`\n\n\t// Metadata contains additional response metadata\n\tMetadata map[string]interface{} `json:\"metadata,omitempty\"`\n\n\t// Timestamp is when the message was created\n\tTimestamp time.Time `json:\"timestamp,omitempty\"`\n}\n```\nMessage represents a WebSocket message\n\n```go\nfunc ParseMessage(data []byte) (*Message, error)\n```\nParseMessage parses a JSON message into a Message struct\n\n```go\nfunc (m *Message) IsValid() bool\n```\nIsValid checks if a message is valid\n\n```go\nfunc (m *Message) ToJSON() ([]byte, error)\n```\nToJSON converts a message to JSON bytes\n\n```go\ntype MessageType string\n```\nMessageType represents the type of WebSocket message\n\n```go\nconst (\n\t// MessageTypeRequest is a client request message\n\tMessageTypeRequest MessageType = \"request\"\n\t// MessageTypeResponse is a server response message\n\tMessageTypeResponse MessageType = \"response\"\n\t// MessageTypeNotification is a server-initiated notification\n\tMessageTypeNotification MessageType = \"notification\"\n\t// MessageTypeSubscription is a subscription control message\n\tMessageTypeSubscription MessageType = \"subscription\"\n\t// MessageTypeError is an error message\n\tMessageTypeError MessageType = \"error\"\n\t// MessageTypePing is a keepalive ping message\n\tMessageTypePing MessageType = \"ping\"\n\t// MessageTypePong is a keepalive pong response\n\tMessageTypePong MessageType = \"pong\"\n)\n```\n\n```go\ntype NotificationMessage struct {\n\tType           MessageType   `json:\"type\"`\n\tOperation      OperationType `json:\"operation\"`\n\tSubscriptionID string        `json:\"subscription_id\"`\n\tSchema         string        `json:\"schema\"`\n\tEntity         string        `json:\"entity\"`\n\tData           interface{}   `json:\"data\"`\n\tTimestamp      time.Time     `json:\"timestamp\"`\n}\n```\nNotificationMessage represents a server-initiated notification\n\n```go\nfunc NewNotificationMessage(subscriptionID string, operation OperationType, schema, entity string, data interface{}) *NotificationMessage\n```\nNewNotificationMessage creates a new notification message\n\n```go\nfunc (n *NotificationMessage) ToJSON() ([]byte, error)\n```\nToJSON converts a notification message to JSON bytes\n\n```go\ntype OperationType string\n```\nOperationType represents the operation to perform\n\n```go\nconst (\n\t// OperationRead retrieves records\n\tOperationRead OperationType = \"read\"\n\t// OperationCreate creates a new record\n\tOperationCreate OperationType = \"create\"\n\t// OperationUpdate updates an existing record\n\tOperationUpdate OperationType = \"update\"\n\t// OperationDelete deletes a record\n\tOperationDelete OperationType = \"delete\"\n\t// OperationSubscribe subscribes to entity changes\n\tOperationSubscribe OperationType = \"subscribe\"\n\t// OperationUnsubscribe unsubscribes from entity changes\n\tOperationUnsubscribe OperationType = \"unsubscribe\"\n\t// OperationMeta retrieves metadata about an entity\n\tOperationMeta OperationType = \"meta\"\n)\n```\n\n```go\ntype RequestMessage struct {\n\tID        string                 `json:\"id\"`\n\tType      MessageType            `json:\"type\"`\n\tOperation OperationType          `json:\"operation\"`\n\tSchema    string                 `json:\"schema,omitempty\"`\n\tEntity    string                 `json:\"entity\"`\n\tRecordID  string                 `json:\"record_id,omitempty\"`\n\tData      interface{}            `json:\"data,omitempty\"`\n\tOptions   *common.RequestOptions `json:\"options,omitempty\"`\n}\n```\nRequestMessage represents a client request\n\n```go\nfunc NewRequestMessage(id string, operation OperationType, schema, entity string) *RequestMessage\n```\nNewRequestMessage creates a new request message\n\n```go\ntype ResponseMessage struct {\n\tID        string                 `json:\"id\"`\n\tType      MessageType            `json:\"type\"`\n\tSuccess   bool                   `json:\"success\"`\n\tData      interface{}            `json:\"data,omitempty\"`\n\tError     *ErrorInfo             `json:\"error,omitempty\"`\n\tMetadata  map[string]interface{} `json:\"metadata,omitempty\"`\n\tTimestamp time.Time              `json:\"timestamp\"`\n}\n```\nResponseMessage represents a server response\n\n```go\nfunc NewErrorResponse(id string, code, message string) *ResponseMessage\n```\nNewErrorResponse creates an error response message\n\n```go\nfunc NewResponseMessage(id string, success bool, data interface{}) *ResponseMessage\n```\nNewResponseMessage creates a new response message\n\n```go\nfunc (r *ResponseMessage) ToJSON() ([]byte, error)\n```\nToJSON converts a response message to JSON bytes\n\n```go\ntype Subscription struct {\n\t// ID is the unique subscription identifier\n\tID string\n\n\t// ConnectionID is the ID of the connection that owns this subscription\n\tConnectionID string\n\n\t// Schema is the database schema\n\tSchema string\n\n\t// Entity is the table/model name\n\tEntity string\n\n\t// Options contains filters and other query options\n\tOptions *common.RequestOptions\n\n\t// Active indicates if the subscription is active\n\tActive bool\n}\n```\nSubscription represents a subscription to entity changes\n\n```go\nfunc (s *Subscription) MatchesFilters(data interface{}) bool\n```\nMatchesFilters checks if data matches the subscription's filters\n\n```go\ntype SubscriptionManager struct {\n\t// contains filtered or unexported fields\n}\n```\nSubscriptionManager manages all subscriptions\n\n```go\nfunc NewSubscriptionManager() *SubscriptionManager\n```\nNewSubscriptionManager creates a new subscription manager\n\n```go\nfunc (sm *SubscriptionManager) Count() int\n```\nCount returns the total number of active subscriptions\n\n```go\nfunc (sm *SubscriptionManager) CountForEntity(schema, entity string) int\n```\nCountForEntity returns the number of subscriptions for a specific entity\n\n```go\nfunc (sm *SubscriptionManager) GetSubscription(subID string) (*Subscription, bool)\n```\nGetSubscription retrieves a subscription by ID\n\n```go\nfunc (sm *SubscriptionManager) GetSubscriptionsByConnection(connID string) []*Subscription\n```\nGetSubscriptionsByConnection retrieves all subscriptions for a connection\n\n```go\nfunc (sm *SubscriptionManager) GetSubscriptionsByEntity(schema, entity string) []*Subscription\n```\nGetSubscriptionsByEntity retrieves all subscriptions for an entity\n\n```go\nfunc (sm *SubscriptionManager) Subscribe(id, connID, schema, entity string, options *common.RequestOptions) *Subscription\n```\nSubscribe creates a new subscription\n\n```go\nfunc (sm *SubscriptionManager) Unsubscribe(subID string) bool\n```\nUnsubscribe removes a subscription\n\n```go\ntype SubscriptionMessage struct {\n\tID             string                 `json:\"id\"`\n\tType           MessageType            `json:\"type\"`\n\tOperation      OperationType          `json:\"operation\"` // subscribe or unsubscribe\n\tSchema         string                 `json:\"schema,omitempty\"`\n\tEntity         string                 `json:\"entity\"`\n\tOptions        *common.RequestOptions `json:\"options,omitempty\"`         // Filters for subscription\n\tSubscriptionID string                 `json:\"subscription_id,omitempty\"` // For unsubscribe\n}\n```\nSubscriptionMessage represents a subscription control message\n\n","path":"github.com/bitechdev/ResolveSpec/pkg/websocketspec","name":"websocketspec","synopsis":"Package websocketspec provides a WebSocket-based API specification for real-time CRUD operations with bidirectional communication and subscription support.","isRedistributable":true}
