Documentation
¶
Index ¶
- type Event
- func NewCollectionCreateEvent(instanceID string, collectionName string, schemaData map[string]any) *Event
- func NewCollectionDeleteEvent(instanceID string, collectionName string) *Event
- func NewCollectionUpdateEvent(instanceID string, collectionName string, schemaData map[string]any) *Event
- func NewCreateEvent(instanceID string, collection string, recordID string, ...) *Event
- func NewDeleteEvent(instanceID string, collection string, recordID string) *Event
- func NewRealtimeHeartbeatEvent(instanceID string, resourceID string, activeConnections int, ...) *Event
- func NewRealtimeSubscribeEvent(instanceID string, resourceID string, activeConnections int, ...) *Event
- func NewRealtimeUnsubscribeEvent(instanceID string, resourceID string) *Event
- func NewRepublishedEvent(originalEvent *Event) *Event
- func NewUpdateEvent(instanceID string, collection string, recordID string, ...) *Event
- type EventSource
- type EventType
- type Processor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Type EventType `json:"type"`
InstanceID string `json:"instanceID"`
Source EventSource `json:"source"` // Where this event originated
Timestamp time.Time `json:"timestamp"`
Collection string `json:"collection"`
RecordID string `json:"recordID,omitempty"`
RecordData map[string]any `json:"recordData,omitempty"` // For create/update
SchemaData map[string]any `json:"schemaData,omitempty"` // For collection create/update
RealtimeData map[string]any `json:"realtimeData,omitempty"` // For realtime events (resourceID, etc.)
}
Event represents a database change event
func NewCollectionCreateEvent ¶
func NewCollectionCreateEvent(instanceID string, collectionName string, schemaData map[string]any) *Event
NewCollectionCreateEvent creates a new collection creation event
func NewCollectionDeleteEvent ¶
NewCollectionDeleteEvent creates a new collection deletion event
func NewCollectionUpdateEvent ¶
func NewCollectionUpdateEvent(instanceID string, collectionName string, schemaData map[string]any) *Event
NewCollectionUpdateEvent creates a new collection update event
func NewCreateEvent ¶
func NewCreateEvent(instanceID string, collection string, recordID string, recordData map[string]any) *Event
NewCreateEvent creates a new record creation event
func NewDeleteEvent ¶
NewDeleteEvent creates a new record deletion event
func NewRealtimeHeartbeatEvent ¶
func NewRealtimeHeartbeatEvent(instanceID string, resourceID string, activeConnections int, leaseExpires time.Time) *Event
NewRealtimeHeartbeatEvent creates a new realtime heartbeat event
func NewRealtimeSubscribeEvent ¶
func NewRealtimeSubscribeEvent(instanceID string, resourceID string, activeConnections int, leaseExpires time.Time) *Event
NewRealtimeSubscribeEvent creates a new realtime subscription event
func NewRealtimeUnsubscribeEvent ¶
NewRealtimeUnsubscribeEvent creates a new realtime unsubscription event
func NewRepublishedEvent ¶
NewRepublishedEvent creates a republished version of an existing event
func NewUpdateEvent ¶
func NewUpdateEvent(instanceID string, collection string, recordID string, recordData map[string]any) *Event
NewUpdateEvent creates a new record update event
func (*Event) MarkAsRemote ¶
MarkAsRemote marks an event as coming from a remote instance
type EventSource ¶
type EventSource string
EventSource represents where the event originated
const ( EventSourceLocal EventSource = "local" // Event originated from this instance EventSourceRemote EventSource = "remote" // Event originated from another instance EventSourceRepublished EventSource = "republished" // Event is being republished by this instance )
type EventType ¶
type EventType string
EventType represents the type of database operation
const ( EventTypeCreate EventType = "create" EventTypeUpdate EventType = "update" EventTypeDelete EventType = "delete" EventTypeCollectionCreate EventType = "collection_create" EventTypeCollectionUpdate EventType = "collection_update" EventTypeCollectionDelete EventType = "collection_delete" EventTypeRealtimeSubscribe EventType = "realtime_subscribe" EventTypeRealtimeUnsubscribe EventType = "realtime_unsubscribe" EventTypeRealtimeHeartbeat EventType = "realtime_heartbeat" )
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor handles processing incoming events and applying changes
func NewProcessor ¶
func NewProcessor(app *pocketsync.PocketBase, instanceID string) *Processor
NewProcessor creates a new event processor
func (*Processor) ApplyEvent ¶
ApplyEvent applies an event to the local PocketBase instance using the SDK This is a public method that can be called directly to avoid recursion in handlers