postgres

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB_FUNCTIONS = []string{
	`
	CREATE OR REPLACE FUNCTION update_modify_time() RETURNS trigger AS $$
		BEGIN
			NEW.modify_time = NOW();
			RETURN NEW;
		END;
	$$ LANGUAGE plpgsql;
	`,
}
View Source
var META_TABLE_FOREIGN_KEYS = map[string]string{
	"feature": `
		ALTER TABLE feature
		ADD CONSTRAINT fk_group
			FOREIGN KEY(group_id)
			REFERENCES feature_group(id)
	`,
	"feature_group": `
		ALTER TABLE feature_group
		ADD CONSTRAINT fk_entity
				FOREIGN KEY(entity_id)
				REFERENCES entity(id),
		ADD CONSTRAINT fk_online_revision
				FOREIGN KEY(online_revision_id)
				REFERENCES feature_group_revision(id)
	`,
	"feature_group_revision": `
		ALTER TABLE feature_group_revision
		ADD CONSTRAINT fk_group
			FOREIGN KEY(group_id)
			REFERENCES feature_group(id)
	`,
}
View Source
var META_TABLE_SCHEMAS = map[string]string{
	"feature": `
		CREATE TABLE feature (
			id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
			name        	VARCHAR(32)  	NOT NULL,
			full_name   	VARCHAR(65)		NOT NULL,
			group_id    	INT          	NOT NULL,
			value_type  	INT  		   	NOT NULL,
			description 	VARCHAR(128) 	DEFAULT '',
			create_time   	TIMESTAMP    	NOT NULL DEFAULT CURRENT_TIMESTAMP,
			modify_time   	TIMESTAMP    	NOT NULL DEFAULT CURRENT_TIMESTAMP,
			UNIQUE (group_id, name),
			UNIQUE (full_name)
		);
		COMMENT ON COLUMN feature.value_type    IS 'data type of feature value';
		COMMENT ON COLUMN feature.full_name		IS '<group_name>:<feature_name>';
		`,
	"feature_group": `
		CREATE TABLE feature_group (
			id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
			name               VARCHAR(32) NOT     NULL,
			category           VARCHAR(16) NOT     NULL,
			entity_id          INT         NOT     NULL,
			online_revision_id INT         DEFAULT NULL,
			description        VARCHAR(64) DEFAULT '',
			create_time        TIMESTAMP   NOT     NULL DEFAULT CURRENT_TIMESTAMP,
			modify_time        TIMESTAMP   NOT     NULL DEFAULT CURRENT_TIMESTAMP,
			UNIQUE (name)
		);
		COMMENT ON COLUMN feature_group.category IS 'group category: batch, stream ...';
		`,
	"entity": `
		CREATE TABLE entity (
			id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
			name        VARCHAR(32) NOT     NULL,
			description VARCHAR(64) DEFAULT '',
			create_time TIMESTAMP   NOT     NULL DEFAULT CURRENT_TIMESTAMP,
			modify_time TIMESTAMP   NOT     NULL DEFAULT CURRENT_TIMESTAMP,
			UNIQUE (name)
		);
		`,
	"feature_group_revision": `
		CREATE TABLE feature_group_revision (
			id    	    	INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
			group_id    	INT         NOT NULL,
			revision    	BIGINT      NOT NULL,
			snapshot_table  VARCHAR(64) NOT	NULL,
			cdc_table    	VARCHAR(64) NOT	NULL DEFAULT '',
			anchored    	BOOLEAN     NOT NULL,
			description 	VARCHAR(64) DEFAULT '',
			create_time 	TIMESTAMP   NOT NULL DEFAULT CURRENT_TIMESTAMP,
			modify_time 	TIMESTAMP   NOT NULL DEFAULT CURRENT_TIMESTAMP,
			UNIQUE (group_id, revision)
		);
		COMMENT ON COLUMN feature_group_revision.revision   IS 'group data point-in-time epoch seconds';
		COMMENT ON COLUMN feature_group_revision.snapshot_table IS 'batch & streaming feature snapshot table name';
		COMMENT ON COLUMN feature_group_revision.cdc_table IS 'streaming feature cdc table name';
		`,
}
View Source
var META_VIEW_SCHEMAS = map[string]string{}
View Source
var TRIGGER_TEMPLATE = `` /* 139-byte string literal not displayed */

Functions

func CreateDatabase

func CreateDatabase(ctx context.Context, opt *types.PostgresOpt) (err error)

Types

type DB

type DB struct {
	*sqlx.DB
	*informer.Informer
}

func Open

func Open(ctx context.Context, option *types.PostgresOpt) (*DB, error)

func (*DB) Close added in v0.0.2

func (db *DB) Close() error

func (*DB) CreateEntity

func (db *DB) CreateEntity(ctx context.Context, opt metadata.CreateEntityOpt) (int, error)

func (*DB) CreateFeature

func (db *DB) CreateFeature(ctx context.Context, opt metadata.CreateFeatureOpt) (int, error)

func (*DB) CreateGroup added in v0.0.3

func (db *DB) CreateGroup(ctx context.Context, opt metadata.CreateGroupOpt) (int, error)

func (*DB) CreateRevision

func (db *DB) CreateRevision(ctx context.Context, opt metadata.CreateRevisionOpt) (int, string, error)

func (*DB) GetEntity

func (db *DB) GetEntity(ctx context.Context, id int) (*types.Entity, error)

func (*DB) GetEntityByName added in v0.0.4

func (db *DB) GetEntityByName(ctx context.Context, name string) (*types.Entity, error)

func (*DB) GetFeature

func (db *DB) GetFeature(ctx context.Context, id int) (*types.Feature, error)

func (*DB) GetFeatureByName added in v0.0.4

func (db *DB) GetFeatureByName(ctx context.Context, name string) (*types.Feature, error)

func (*DB) GetGroup added in v0.0.4

func (db *DB) GetGroup(ctx context.Context, id int) (*types.Group, error)

func (*DB) GetGroupByName added in v0.0.4

func (db *DB) GetGroupByName(ctx context.Context, name string) (*types.Group, error)

func (*DB) GetRevision

func (db *DB) GetRevision(ctx context.Context, id int) (*types.Revision, error)

func (*DB) GetRevisionBy added in v0.0.4

func (db *DB) GetRevisionBy(ctx context.Context, groupID int, revision int64) (*types.Revision, error)

func (*DB) ListEntity

func (db *DB) ListEntity(ctx context.Context, entityIDs *[]int) (types.EntityList, error)

func (*DB) ListFeature

func (db *DB) ListFeature(ctx context.Context, opt metadata.ListFeatureOpt) (types.FeatureList, error)

func (*DB) ListGroup added in v0.0.4

func (db *DB) ListGroup(ctx context.Context, entityID *int, groupIDs *[]int) (types.GroupList, error)

func (*DB) ListRevision

func (db *DB) ListRevision(ctx context.Context, groupID *int) (types.RevisionList, error)

func (*DB) Ping added in v0.0.4

func (db *DB) Ping(ctx context.Context) error

func (*DB) UpdateEntity

func (db *DB) UpdateEntity(ctx context.Context, opt metadata.UpdateEntityOpt) error

func (*DB) UpdateFeature

func (db *DB) UpdateFeature(ctx context.Context, opt metadata.UpdateFeatureOpt) error

func (*DB) UpdateGroup added in v0.0.3

func (db *DB) UpdateGroup(ctx context.Context, opt metadata.UpdateGroupOpt) error

func (*DB) UpdateRevision added in v0.0.2

func (db *DB) UpdateRevision(ctx context.Context, opt metadata.UpdateRevisionOpt) error

func (*DB) WithTransaction added in v0.0.2

func (db *DB) WithTransaction(ctx context.Context, fn func(context.Context, metadata.DBStore) error) (err error)

type Tx added in v0.0.2

type Tx struct {
	*sqlx.Tx
}

func (*Tx) CreateEntity added in v0.0.2

func (tx *Tx) CreateEntity(ctx context.Context, opt metadata.CreateEntityOpt) (int, error)

func (*Tx) CreateFeature added in v0.0.2

func (tx *Tx) CreateFeature(ctx context.Context, opt metadata.CreateFeatureOpt) (int, error)

func (*Tx) CreateGroup added in v0.0.3

func (tx *Tx) CreateGroup(ctx context.Context, opt metadata.CreateGroupOpt) (int, error)

func (*Tx) CreateRevision added in v0.0.2

func (tx *Tx) CreateRevision(ctx context.Context, opt metadata.CreateRevisionOpt) (int, string, error)

func (*Tx) GetEntity added in v0.0.4

func (tx *Tx) GetEntity(ctx context.Context, id int) (*types.Entity, error)

func (*Tx) GetEntityByName added in v0.0.4

func (tx *Tx) GetEntityByName(ctx context.Context, name string) (*types.Entity, error)

func (*Tx) GetFeature added in v0.0.4

func (tx *Tx) GetFeature(ctx context.Context, id int) (*types.Feature, error)

func (*Tx) GetFeatureByName added in v0.0.4

func (tx *Tx) GetFeatureByName(ctx context.Context, name string) (*types.Feature, error)

func (*Tx) GetGroup added in v0.0.4

func (tx *Tx) GetGroup(ctx context.Context, id int) (*types.Group, error)

func (*Tx) GetGroupByName added in v0.0.4

func (tx *Tx) GetGroupByName(ctx context.Context, name string) (*types.Group, error)

func (*Tx) GetRevision added in v0.0.4

func (tx *Tx) GetRevision(ctx context.Context, id int) (*types.Revision, error)

func (*Tx) GetRevisionBy added in v0.0.4

func (tx *Tx) GetRevisionBy(ctx context.Context, groupID int, revision int64) (*types.Revision, error)

func (*Tx) ListEntity added in v0.0.4

func (tx *Tx) ListEntity(ctx context.Context, entityIDs *[]int) (types.EntityList, error)

func (*Tx) ListFeature added in v0.0.4

func (tx *Tx) ListFeature(ctx context.Context, opt metadata.ListFeatureOpt) (types.FeatureList, error)

func (*Tx) ListGroup added in v0.0.4

func (tx *Tx) ListGroup(ctx context.Context, entityID *int, groupIDs *[]int) (types.GroupList, error)

func (*Tx) ListRevision added in v0.0.4

func (tx *Tx) ListRevision(ctx context.Context, groupID *int) (types.RevisionList, error)

func (*Tx) UpdateEntity added in v0.0.2

func (tx *Tx) UpdateEntity(ctx context.Context, opt metadata.UpdateEntityOpt) error

func (*Tx) UpdateFeature added in v0.0.2

func (tx *Tx) UpdateFeature(ctx context.Context, opt metadata.UpdateFeatureOpt) error

func (*Tx) UpdateGroup added in v0.0.3

func (tx *Tx) UpdateGroup(ctx context.Context, opt metadata.UpdateGroupOpt) error

func (*Tx) UpdateRevision added in v0.0.2

func (tx *Tx) UpdateRevision(ctx context.Context, opt metadata.UpdateRevisionOpt) error

func (*Tx) WithTransaction added in v0.0.2

func (tx *Tx) WithTransaction(ctx context.Context, fn func(context.Context, metadata.DBStore) error) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL