services

package
v0.0.0-...-29cff14 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 18 Imported by: 14

Documentation

Index

Constants

View Source
const (
	CmdMigrate MigrationCommand = "migrate"
	CmdNumber  MigrationCommand = "number"
	CmdMode    MigrationCommand = "mode"

	OptionUp   MigrationOption = "up"
	OptionDown MigrationOption = "down"

	FileTagMigrate     Tag = "-- migrate %s"
	FileTagMigrateUp   Tag = "-- migrate up"
	FileTagMigrateDown Tag = "-- migrate down"

	FileTagCustom     Tag = "-- %s %s"
	FileTagCustomUp   Tag = "-- %s up"
	FileTagCustomDown Tag = "-- %s down"
)
View Source
const (
	DefaultURL = "http://localhost:8001"

	CREATE_MIGRATION_TABLES = `` /* 469-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func Exists

func Exists(file string) bool

func GetEnv

func GetEnv() string

func MigrationHandler

func MigrationHandler(option MigrationOption, conn Executor, data string) error

func ReadFile

func ReadFile(file string, obj interface{}) ([]byte, error)

func ReadFileLines

func ReadFileLines(file string) ([]string, error)

func WriteFile

func WriteFile(file string, obj interface{}) error

Types

type AppConfig

type AppConfig struct {
	Migration *MigrationConfig `json:"migration"`
}

AppConfig ...

func NewConfig

func NewConfig() (*AppConfig, manager.IConfig, error)

NewConfig ...

type CmdService

type CmdService struct {
	// contains filtered or unexported fields
}

func NewCmdService

func NewCmdService(options ...CmdServiceOption) (*CmdService, error)

func (*CmdService) AddTag

func (service *CmdService) AddTag(name string, handler Handler) error

func (*CmdService) Execute

func (service *CmdService) Execute(option MigrationOption, number int, mode ExecutorMode) (int, error)

execute ...

func (*CmdService) Reconfigure

func (service *CmdService) Reconfigure(options ...CmdServiceOption)

Reconfigure ...

func (*CmdService) Start

func (m *CmdService) Start() error

Start ...

func (*CmdService) Stop

func (m *CmdService) Stop() error

Stop ...

type CmdServiceOption

type CmdServiceOption func(client *CmdService)

CmdServiceOption ...

func WithCmdConfiguration

func WithCmdConfiguration(config *MigrationConfig) CmdServiceOption

WithCmdConfiguration ...

func WithCmdLogLevel

func WithCmdLogLevel(level logger.Level) CmdServiceOption

WithCmdLogLevel ...

func WithCmdLogger

func WithCmdLogger(logger logger.ILogger) CmdServiceOption

WithCmdLogger ...

func WithCmdManager

func WithCmdManager(mgr *manager.Manager) CmdServiceOption

WithCmdManager ...

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(logger logger.ILogger, interactor *Interactor) *Controller

func (*Controller) CreateMigrationHandler

func (controller *Controller) CreateMigrationHandler(ctx echo.Context) error

func (*Controller) DeleteMigrationHandler

func (controller *Controller) DeleteMigrationHandler(ctx echo.Context) error

func (*Controller) DeleteMigrationsHandler

func (controller *Controller) DeleteMigrationsHandler(ctx echo.Context) error

func (*Controller) GetMigrationHandler

func (controller *Controller) GetMigrationHandler(ctx echo.Context) error

func (*Controller) GetMigrationsHandler

func (controller *Controller) GetMigrationsHandler(ctx echo.Context) error

func (*Controller) RegisterRoutes

func (controller *Controller) RegisterRoutes(web manager.IWeb) error

type CreateMigrationRequest

type CreateMigrationRequest struct {
	Body struct {
		IdMigration string `json:"id_migration" validate:"nonzero"`
	}
}

type CustomMode

type CustomMode string

type DBConfig

type DBConfig struct {
	manager.DBConfig
	Schema string `json:"schema"`
}

type DeleteMigrationRequest

type DeleteMigrationRequest struct {
	IdMigration string `json:"id_migration"`
}

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Cause   string `json:"cause,omitempty"`
}

type Executor

type Executor interface {
	Open() error
	Begin() error
	Execute(arg interface{}, args ...interface{}) error
	Commit() error
	Rollback() error
	Close() error
}

func NewExecutor

func NewExecutor(service *CmdService, mode ExecutorMode) Executor

type ExecutorDatabase

type ExecutorDatabase struct {
	*sql.DB
	*sql.Tx
	// contains filtered or unexported fields
}

func NewExecutorDatabase

func NewExecutorDatabase(service *CmdService) *ExecutorDatabase

func (*ExecutorDatabase) Begin

func (e *ExecutorDatabase) Begin() (err error)

func (*ExecutorDatabase) Close

func (e *ExecutorDatabase) Close() error

func (*ExecutorDatabase) Commit

func (e *ExecutorDatabase) Commit() error

func (*ExecutorDatabase) Execute

func (e *ExecutorDatabase) Execute(arg interface{}, args ...interface{}) error

func (*ExecutorDatabase) Open

func (e *ExecutorDatabase) Open() (err error)

func (*ExecutorDatabase) Rollback

func (e *ExecutorDatabase) Rollback() error

type ExecutorMode

type ExecutorMode string
const (
	ExecutorModeAll      ExecutorMode = "all"
	ExecutorModeDatabase ExecutorMode = "database"
	ExecutorModeRabbitMq ExecutorMode = "rabbitmq"
)

type ExecutorRabbitMq

type ExecutorRabbitMq struct {
	// contains filtered or unexported fields
}

func NewExecutorRabbitMq

func NewExecutorRabbitMq(service *CmdService) *ExecutorRabbitMq

func (*ExecutorRabbitMq) Begin

func (e *ExecutorRabbitMq) Begin() error

func (*ExecutorRabbitMq) Close

func (e *ExecutorRabbitMq) Close() error

func (*ExecutorRabbitMq) Commit

func (e *ExecutorRabbitMq) Commit() error

func (*ExecutorRabbitMq) Execute

func (e *ExecutorRabbitMq) Execute(arg interface{}, args ...interface{}) error

func (*ExecutorRabbitMq) Open

func (e *ExecutorRabbitMq) Open() (err error)

func (*ExecutorRabbitMq) Rollback

func (e *ExecutorRabbitMq) Rollback() error

type GetMigrationRequest

type GetMigrationRequest struct {
	IdMigration string `json:"id_migration" validate:"nonzero"`
}

type Handler

type Handler func(option MigrationOption, conn Executor, data string) error

type IStorageDB

type IStorageDB interface {
	GetMigration(idMigration string) (*Migration, error)
	GetMigrations(values map[string][]string) (ListMigration, error)
	CreateMigration(newMigration *Migration) error
	DeleteMigration(idMigration string) error
	DeleteMigrations() error
	ExecuteMigration(migration string) error
}

type Interactor

type Interactor struct {
	// contains filtered or unexported fields
}

func NewInteractor

func NewInteractor(logger logger.ILogger, storageDB IStorageDB) *Interactor

func (*Interactor) CreateMigration

func (interactor *Interactor) CreateMigration(newMigration *Migration) error

func (*Interactor) DeleteMigration

func (interactor *Interactor) DeleteMigration(idMigration string) error

func (*Interactor) DeleteMigrations

func (interactor *Interactor) DeleteMigrations() error

func (*Interactor) ExecuteMigration

func (interactor *Interactor) ExecuteMigration(migration string) error

func (*Interactor) GetMigration

func (interactor *Interactor) GetMigration(idMigration string) (*Migration, error)

func (*Interactor) GetMigrations

func (interactor *Interactor) GetMigrations(values map[string][]string) (ListMigration, error)

type ListMigration

type ListMigration []*Migration

type Migration

type Migration struct {
	IdMigration string       `json:"id_migration"`
	Mode        ExecutorMode `json:"mode"`
	User        string       `json:"user"`
	ExecutedAt  time.Time    `json:"executed_at"`
}

type MigrationCommand

type MigrationCommand string

type MigrationConfig

type MigrationConfig struct {
	Host string `json:"host"`
	Path struct {
		Database string `json:"database"`
		Rabbitmq string `json:"rabbitmq"`
	} `json:"path"`
	Db       *DBConfig `json:"db"`
	RabbitMq *struct {
		Host  string  `json:"host"`
		VHost *string `json:"vhost"`
	} `json:"rabbitmq"`
	Log struct {
		Level string `json:"level"`
	} `json:"log"`
}

MigrationConfig ...

type MigrationOption

type MigrationOption string

type StoragePostgres

type StoragePostgres struct {
	// contains filtered or unexported fields
}

func NewStoragePostgres

func NewStoragePostgres(logger logger.ILogger, connection manager.IDB) *StoragePostgres

func (*StoragePostgres) CreateMigration

func (storage *StoragePostgres) CreateMigration(newMigration *Migration) error

func (*StoragePostgres) DeleteMigration

func (storage *StoragePostgres) DeleteMigration(idMigration string) error

func (*StoragePostgres) DeleteMigrations

func (storage *StoragePostgres) DeleteMigrations() error

func (*StoragePostgres) ExecuteMigration

func (storage *StoragePostgres) ExecuteMigration(migration string) error

func (*StoragePostgres) GetMigration

func (storage *StoragePostgres) GetMigration(idMigration string) (*Migration, error)

func (*StoragePostgres) GetMigrations

func (storage *StoragePostgres) GetMigrations(values map[string][]string) (ListMigration, error)

type Tag

type Tag string

type WebService

type WebService struct {
	// contains filtered or unexported fields
}

func NewWebService

func NewWebService(options ...WebServiceOption) (*WebService, error)

NewWebService ...

func (*WebService) Reconfigure

func (service *WebService) Reconfigure(options ...WebServiceOption)

Reconfigure ...

func (*WebService) Start

func (m *WebService) Start() error

Start ...

func (*WebService) Stop

func (m *WebService) Stop() error

Stop ...

type WebServiceOption

type WebServiceOption func(client *WebService)

WebServiceOption ...

func WithWebConfiguration

func WithWebConfiguration(config *MigrationConfig) WebServiceOption

WithWebConfiguration ...

func WithWebLogLevel

func WithWebLogLevel(level logger.Level) WebServiceOption

WithLogLevel ...

func WithWebLogger

func WithWebLogger(logger logger.ILogger) WebServiceOption

WithLogger ...

func WithWebManager

func WithWebManager(mgr *manager.Manager) WebServiceOption

WithManager ...

Jump to

Keyboard shortcuts

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