mysql

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ER_DUP_ENTRY = 1062
)

Variables

View Source
var META_TABLE_FOREIGN_KEYS = []string{
	"ALTER TABLE feature ADD FOREIGN KEY (group_id) REFERENCES feature_group(id)",

	"ALTER TABLE feature_group ADD CONSTRAINT FK_feature_group_entity_id FOREIGN KEY (entity_id) REFERENCES entity(id)",
	"ALTER TABLE feature_group ADD CONSTRAINT FK_feature_group_online_revision_id FOREIGN KEY (online_revision_id) REFERENCES feature_group_revision(id)",
	"ALTER TABLE feature_group_revision ADD FOREIGN KEY (group_id) REFERENCES feature_group(id)",
}
View Source
var META_TABLE_SCHEMAS = map[string]string{
	"feature": `
		CREATE TABLE feature (
			id				INT 			NOT NULL AUTO_INCREMENT PRIMARY KEY,
			name          	VARCHAR(32) 	NOT	NULL,
			group_id      	INT         	NOT	NULL,
			value_type    	INT         	NOT	NULL COMMENT "data type of feature value",
			description   	VARCHAR(128)	DEFAULT '',
			create_time   	TIMESTAMP    	NOT	NULL DEFAULT CURRENT_TIMESTAMP,
			modify_time   	TIMESTAMP    	NOT	NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
			UNIQUE (group_id, name)
		);
		`,
	"feature_group": `
		CREATE TABLE feature_group (
			id					INT 			NOT	NULL AUTO_INCREMENT PRIMARY KEY,
			name               	VARCHAR(32) 	NOT	NULL,
			category           	VARCHAR(16) 	NOT	NULL COMMENT "group category: batch, stream",
			entity_id          	INT         	NOT	NULL,
			snapshot_interval  	INT		        DEFAULT 0,
			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 ON UPDATE CURRENT_TIMESTAMP,
			UNIQUE (name)
		);
		`,
	"entity": `
		CREATE TABLE entity (
			id				INT 			NOT	NULL AUTO_INCREMENT PRIMARY KEY,
			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 ON UPDATE CURRENT_TIMESTAMP,
			UNIQUE (name)
		);
		`,
	"feature_group_revision": `
		CREATE TABLE feature_group_revision (
			id				INT 		NOT	NULL AUTO_INCREMENT PRIMARY KEY,
			group_id    	INT         NOT	NULL,
			revision    	BIGINT      NOT	NULL COMMENT "group data point-in-time epoch seconds",
			snapshot_table  VARCHAR(64) NOT	NULL COMMENT "batch & streaming feature snapshot table name",
			cdc_table    	VARCHAR(64) NOT	NULL DEFAULT '' COMMENT "streaming feature cdc table name",
			anchored    	BOOLEAN     NOT	NULL,
			description 	VARCHAR(64) DEFAULT '',
			create_time 	TIMESTAMP   NOT	NULL DEFAULT CURRENT_TIMESTAMP,
			modify_time 	TIMESTAMP   NOT	NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
			UNIQUE (group_id, revision)
		);
		`,
}
View Source
var META_VIEW_SCHEMAS = map[string]string{}

Functions

func CreateDatabase

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

Types

type DB

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

func Open

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

func (*DB) Close

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

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, error)

func (*DB) GetEntity

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

func (*DB) GetEntityByName

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

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

func (*DB) GetGroup

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

func (*DB) GetGroupByName

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

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

func (db *DB) ListGroup(ctx context.Context, opt metadata.ListGroupOpt) (types.GroupList, error)

func (*DB) ListRevision

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

func (*DB) Ping

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

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

func (*DB) UpdateRevision

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

func (*DB) WithTransaction

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

type Tx

type Tx struct {
	*sqlx.Tx
}

func (*Tx) CreateEntity

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

func (*Tx) CreateFeature

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

func (*Tx) CreateGroup

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

func (*Tx) CreateRevision

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

func (*Tx) GetEntity

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

func (*Tx) GetEntityByName

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

func (*Tx) GetFeature

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

func (*Tx) GetFeatureByName

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

func (*Tx) GetGroup

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

func (*Tx) GetGroupByName

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

func (*Tx) GetRevision

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

func (*Tx) GetRevisionBy

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

func (*Tx) ListEntity

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

func (*Tx) ListFeature

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

func (*Tx) ListGroup

func (tx *Tx) ListGroup(ctx context.Context, opt metadata.ListGroupOpt) (types.GroupList, error)

func (*Tx) ListRevision

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

func (*Tx) UpdateEntity

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

func (*Tx) UpdateFeature

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

func (*Tx) UpdateGroup

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

func (*Tx) UpdateRevision

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

func (*Tx) WithTransaction

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

Jump to

Keyboard shortcuts

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