Documentation
¶
Index ¶
- func ExtractModelAttributes(model any) map[string]any
- type Dispatcher
- func (d *Dispatcher) Dispatch(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchCreated(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchCreating(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchDeleted(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchDeleting(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchForceDeleted(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchForceDeleting(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchRestored(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchRestoring(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchRetrieved(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchSaved(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchSaving(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchUpdated(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- func (d *Dispatcher) DispatchUpdating(ctx context.Context, model any, observers []contractsorm.ModelToObserver, ...) error
- type Event
- func (e *Event) Context() context.Context
- func (e *Event) EventType() contractsorm.EventType
- func (e *Event) GetAttribute(key string) any
- func (e *Event) GetOriginal(key string, def ...any) any
- func (e *Event) IsClean(columns ...string) bool
- func (e *Event) IsDirty(columns ...string) bool
- func (e *Event) Model() any
- func (e *Event) Query() contractsorm.Query
- func (e *Event) SetAttribute(key string, value any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractModelAttributes ¶
ExtractModelAttributes extracts attributes from a model using reflection.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher handles event dispatching for model lifecycle events.
func NewDispatcher ¶
func NewDispatcher(log log.Log) *Dispatcher
NewDispatcher creates a new Dispatcher instance.
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, eventType contractsorm.EventType, ) error
Dispatch dispatches an event to all registered observers for the given model.
func (*Dispatcher) DispatchCreated ¶
func (d *Dispatcher) DispatchCreated( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchCreated dispatches the created event.
func (*Dispatcher) DispatchCreating ¶
func (d *Dispatcher) DispatchCreating( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchCreating dispatches the creating event.
func (*Dispatcher) DispatchDeleted ¶
func (d *Dispatcher) DispatchDeleted( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchDeleted dispatches the deleted event.
func (*Dispatcher) DispatchDeleting ¶
func (d *Dispatcher) DispatchDeleting( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchDeleting dispatches the deleting event.
func (*Dispatcher) DispatchForceDeleted ¶
func (d *Dispatcher) DispatchForceDeleted( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchForceDeleted dispatches the force deleted event.
func (*Dispatcher) DispatchForceDeleting ¶
func (d *Dispatcher) DispatchForceDeleting( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchForceDeleting dispatches the force deleting event.
func (*Dispatcher) DispatchRestored ¶
func (d *Dispatcher) DispatchRestored( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchRestored dispatches the restored event.
func (*Dispatcher) DispatchRestoring ¶
func (d *Dispatcher) DispatchRestoring( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchRestoring dispatches the restoring event.
func (*Dispatcher) DispatchRetrieved ¶
func (d *Dispatcher) DispatchRetrieved( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchRetrieved dispatches the retrieved event.
func (*Dispatcher) DispatchSaved ¶
func (d *Dispatcher) DispatchSaved( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchSaved dispatches the saved event.
func (*Dispatcher) DispatchSaving ¶
func (d *Dispatcher) DispatchSaving( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchSaving dispatches the saving event.
func (*Dispatcher) DispatchUpdated ¶
func (d *Dispatcher) DispatchUpdated( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchUpdated dispatches the updated event.
func (*Dispatcher) DispatchUpdating ¶
func (d *Dispatcher) DispatchUpdating( ctx context.Context, model any, observers []contractsorm.ModelToObserver, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, ) error
DispatchUpdating dispatches the updating event.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event implements the Event interface for model lifecycle events.
func NewEvent ¶
func NewEvent( ctx context.Context, model any, original map[string]any, attributes map[string]any, dirty map[string]bool, query contractsorm.Query, eventType contractsorm.EventType, ) *Event
NewEvent creates a new Event instance.
func (*Event) EventType ¶
func (e *Event) EventType() contractsorm.EventType
EventType returns the event type.
func (*Event) GetAttribute ¶
GetAttribute returns the attribute value for the given key.
func (*Event) GetOriginal ¶
GetOriginal returns the original attribute value for the given key.
func (*Event) SetAttribute ¶
SetAttribute sets the attribute value for the given key.