Documentation ¶
Index ¶
- func Open(ctx context.Context, connURL string) (storage.Driver, error)
- type Bind
- func (b *Bind) Del(ctx context.Context, ectx keypattern.ExecContext) error
- func (b *Bind) Get(ctx context.Context, ectx keypattern.ExecContext) (Record, error)
- func (b *Bind) List(ctx context.Context, ectx keypattern.ExecContext) ([]Record, error)
- func (b *Bind) Upsert(ctx context.Context, ectx keypattern.ExecContext, value []byte) error
- type DataFields
- type Driver
- func (pg *Driver) Bind(ctx context.Context, conf *storage.BindConfig) error
- func (pg *Driver) Close() error
- func (pg *Driver) Del(ctx context.Context, dbnum int, key string) error
- func (pg *Driver) Get(ctx context.Context, dbnum int, key string) ([]byte, error)
- func (pg *Driver) Keys(ctx context.Context, dbnum int, pattern string) ([]string, error)
- func (pg *Driver) List(ctx context.Context, dbnum int, pattern string) ([]byte, error)
- func (pg *Driver) ListenUpdateNotifies(ctx context.Context, chanelName string, ...) error
- func (pg *Driver) Set(ctx context.Context, dbnum int, key string, value []byte) error
- type Notification
- type Record
- type Syntax
- type WhereStmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bind ¶
type Bind struct { sql.BindAbstract // contains filtered or unexported fields }
func NewBind ¶
func NewBind( conn pgpoolIface, dbnum int, syntax Syntax, pattern, getQuery, listQuery, upsertQuery, delQuery string, datatypesMapping []storage.DatatypeMapper, ) *Bind
NewBind create new sql bind instance for the specified database
func NewBindFromTableName ¶
func NewBindFromTableName( conn pgpoolIface, dbnum int, syntax Syntax, pattern, tableName, whereExt string, datatypesMapping []storage.DatatypeMapper, readonly bool, ) *Bind
NewBindFromTableName create new sql bind instance for the specified database
func (*Bind) Del ¶
func (b *Bind) Del(ctx context.Context, ectx keypattern.ExecContext) error
func (*Bind) Get ¶
func (b *Bind) Get(ctx context.Context, ectx keypattern.ExecContext) (Record, error)
func (*Bind) List ¶
func (b *Bind) List(ctx context.Context, ectx keypattern.ExecContext) ([]Record, error)
func (*Bind) Upsert ¶
func (b *Bind) Upsert(ctx context.Context, ectx keypattern.ExecContext, value []byte) error
type DataFields ¶
type DataFields = sql.DataFields
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
func (*Driver) ListenUpdateNotifies ¶
func (pg *Driver) ListenUpdateNotifies(ctx context.Context, chanelName string, notifyFnk func(ctx context.Context, key string)) error
SQL Example: CREATE OR REPLACE FUNCTION notify_event() RETURNS TRIGGER AS $$
DECLARE data json; notification json; BEGIN -- Convert the old or new row to JSON, based on the kind of action. -- Action = DELETE? -> OLD row -- Action = INSERT or UPDATE? -> NEW row IF (TG_OP = 'DELETE') THEN data = row_to_json(OLD); ELSE data = row_to_json(NEW); END IF; -- Contruct the notification as a JSON string. notification = json_build_object( 'table',TG_TABLE_NAME, 'action', TG_OP, 'data', data); -- Execute pg_notify(channel, notification) PERFORM pg_notify('redify_update', notification::text); -- Result is ignored since this is an AFTER trigger RETURN NULL; END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER products_notify_event AFTER INSERT OR UPDATE OR DELETE ON products
FOR EACH ROW EXECUTE PROCEDURE notify_event();
type Notification ¶
type Notification struct { Table string `json:"table"` Data json.RawMessage `json:"data"` }
Click to show internal directories.
Click to hide internal directories.