Skip to content

Commit

Permalink
See changelog 2024-06-30
Browse files Browse the repository at this point in the history
  • Loading branch information
mondegor committed Jun 30, 2024
1 parent 0715878 commit 4b3d493
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 38 deletions.
15 changes: 12 additions & 3 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
## System vars:
# MRCMD_PLUGINS_DIR=../mrcmd/plugins
# APPX_PLUGINS_DIR=./scripts
MRCMD_SHARED_PLUGINS_ENABLED=global,go-dev
MRCMD_SHARED_PLUGINS_ENABLED=global,go-dev,docker,golangci-lint

## Global vars:
APPX_WORK_DIR=./
APPX_WORK_DIR=.

## Go Dev:
GO_DEV_LOCAL_PACKAGE=github.com/mondegor/go-components
GO_DEV_LOCAL_PACKAGE=github.com/mondegor/go-components

## GolangCI Lint:
# GOLANGCI_GOPATH_DIR=./../tmp/golang
# GOLANGCI_LINT_CACHE_DIR=./../tmp/golangci-lint

## Plantuml:
# PLANTUML_SOURCE_DIR=./docs
# PLANTUML_OUTPUT_IN_DOCKER_DIR=./resources
# PLANTUML_OUTPUT_FORMAT=svg
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# GoStorage Changelog
Все изменения библиотеки GoComponents будут документироваться на этой странице.

## 2024-06-30
### Added
- Добавлено описание по локальной разработке библиотеки;
- Добавлены комментарии для некоторых структур данных;

## 2024-06-26
### Changed
- Изменено местоположение компонентов пакетов `mrsettings` и `mrsort`;
Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Описание GoComponents v0.7.2
# Описание GoComponents v0.7.3
Этот репозиторий содержит описание библиотеки GoComponents.

## Статус библиотеки
Expand All @@ -11,4 +11,22 @@
позволяет встраиваться в произвольные таблицы БД;

## Подключение библиотеки
`go get github.com/mondegor/go-components`
`go get -u github.com/mondegor/[email protected]`

## Установка библиотеки для её локальной разработки

- Выбрать рабочую директорию, где должна быть расположена библиотека
- `mkdir go-components && cd go-components` // создать и перейти в директорию проекта
- `git clone [email protected]:mondegor/go-components.git .`
- `cp .env.dist .env`

### Консольные команды используемые при разработке библиотеки

> Перед запуском консольных скриптов сервиса необходимо скачать и установить утилиту Mrcmd.\
> Инструкция по её установке находится [здесь](https://github.com/mondegor/mrcmd#readme)
- `mrcmd go-dev fmt` // исправляет форматирование кода (gofumpt -l -w -extra ./)
- `mrcmd go-dev goimports-fix` // исправление imports, если это требуется (goimports -d -local ${GO_DEV_LOCAL_PACKAGE} ./)
- `mrcmd go-dev check` // статический анализ кода библиотеки
- `mrcmd go-dev test` // запуск тестов библиотеки
- `mrcmd go-dev help` // выводит список всех доступных команд
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/mondegor/go-components

go 1.21
go 1.22

require (
github.com/mondegor/go-storage v0.11.3
github.com/mondegor/go-sysmess v0.10.5
github.com/mondegor/go-webcore v0.18.3
github.com/mondegor/go-storage v0.11.5
github.com/mondegor/go-sysmess v0.10.6
github.com/mondegor/go-webcore v0.19.1
)

require (
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/mondegor/go-storage v0.11.3 h1:0CmKIU+r0HW33YxRG2nkoQUbP6igkuKs9YvRC8J/XfQ=
github.com/mondegor/go-storage v0.11.3/go.mod h1:Irjf4GYg0mG9UdSqQuX98dE7HQWsOw9CSTR7DVKemCM=
github.com/mondegor/go-sysmess v0.10.5 h1:Kp1vyVGw1UzyefqKEaj6S8XPRnKqVHDDi8nt2iwN8AI=
github.com/mondegor/go-sysmess v0.10.5/go.mod h1:9HcJbyyyztIC/CLitFCU6eViQpE4xNl/xQMJB1GfKSw=
github.com/mondegor/go-webcore v0.18.3 h1:XqfcNmjIshLl2sM7iuH5Q0Ql/8+yYZq/KrLGy0Mc9aA=
github.com/mondegor/go-webcore v0.18.3/go.mod h1:qkRMP+Pe5SFPw12VBn/uUL2JXurHJq/GYaUq6rxPan4=
github.com/mondegor/go-storage v0.11.5 h1:qXAiYKTYjLcG3DjQMwDrvLx705X+AVLFWL9V+Q+xoC4=
github.com/mondegor/go-storage v0.11.5/go.mod h1:i1ZvV0gBhtxNTbe3+DggitqxXMG9ksYD9uPNriCuDCo=
github.com/mondegor/go-sysmess v0.10.6 h1:HTPGPlj/5K6TUTGZIV6heR8UhcVuoJBNETwOFbUVoJ0=
github.com/mondegor/go-sysmess v0.10.6/go.mod h1:9HcJbyyyztIC/CLitFCU6eViQpE4xNl/xQMJB1GfKSw=
github.com/mondegor/go-webcore v0.19.1 h1:yT77Zn6gxdnwNtgX10IfIcD2FE3OumHF5hFGAnP3QUM=
github.com/mondegor/go-webcore v0.19.1/go.mod h1:dZWQCW6QVVQoGmLFzuMl4ZBMVFuE5+ytwEWRrZPL3+U=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
27 changes: 13 additions & 14 deletions mrsettings/mrsetting_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

type (
// Getter - comment interface.
// Getter - интерфейс получения значения настройки по-указанному ID.
Getter interface {
Get(ctx context.Context, id mrtype.KeyInt32) (string, error)
GetList(ctx context.Context, id mrtype.KeyInt32) ([]string, error)
Expand All @@ -19,7 +19,8 @@ type (
GetBool(ctx context.Context, id mrtype.KeyInt32) (bool, error)
}

// DefaultValueGetter - comment interface.
// DefaultValueGetter - интерфейс получения значения настройки по-указанному ID.
// Если значение не найдено или случилась ошибка, то будет возвращено значение по умолчанию.
DefaultValueGetter interface {
Get(ctx context.Context, id mrtype.KeyInt32, defaultVal string) string
GetList(ctx context.Context, id mrtype.KeyInt32, defaultVal []string) []string
Expand All @@ -28,7 +29,7 @@ type (
GetBool(ctx context.Context, id mrtype.KeyInt32, defaultVal bool) bool
}

// Setter - comment interface.
// Setter - интерфейс сохранения значения настройки по-указанному ID.
Setter interface {
Set(ctx context.Context, id mrtype.KeyInt32, value string) error
SetList(ctx context.Context, id mrtype.KeyInt32, value []string) error
Expand All @@ -37,12 +38,14 @@ type (
SetBool(ctx context.Context, id mrtype.KeyInt32, value bool) error
}

// Loader - comment interface.
// Loader - интерфейс загрузки данных из хранилища в область памяти,
// для оперативного доступа за значениями настроек.
Loader interface {
Reload(ctx context.Context) (count uint64, err error)
}

// ValueParser - comment interface.
// ValueParser - парсер значения настройки полученного из хранилища,
// с целью приведения к нужному типу данных.
ValueParser interface {
ParseString(value string) (string, error)
ParseStringList(value string) ([]string, error)
Expand All @@ -51,7 +54,9 @@ type (
ParseBool(value string) (bool, error)
}

// ValueFormatter - comment interface.
// ValueFormatter - форматер значения настройки, который подготавливает
// его к сохранению в хранилище данных. Если необходима валидация данных,
// то она должна происходить до этапа форматирования.
ValueFormatter interface {
FormatString(value string) (string, error)
FormatStringList(values []string) (string, error)
Expand All @@ -60,18 +65,12 @@ type (
FormatBool(value bool) (string, error)
}

// ValueValidator - comment interface.
ValueValidator interface {
MatchString(s string) bool
String() string
}

// StorageLoader - comment interface.
// StorageLoader - выборка последних обновлённых данных в хранилище.
StorageLoader interface {
Fetch(ctx context.Context, lastUpdated time.Time) ([]entity.Setting, error)
}

// Storage - comment interface.
// Storage - извлечение и сохранение значения настройки по-указанному ID.
Storage interface {
FetchOne(ctx context.Context, id mrtype.KeyInt32) (entity.Setting, error)
Update(ctx context.Context, row entity.Setting) error
Expand Down
14 changes: 7 additions & 7 deletions mrsort/component/orderer/orderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func New(storage mrsort.Storage, eventEmitter mrsender.EventEmitter, errorWrappe
}
}

// WithMetaData - comment func.
// WithMetaData - comment method.
func (co *Component) WithMetaData(meta mrstorage.MetaGetter) mrsort.Orderer {
return &Component{
storage: co.storage.WithMetaData(meta),
eventEmitter: co.eventEmitter,
}
}

// InsertToFirst - comment func.
// InsertToFirst - comment method.
func (co *Component) InsertToFirst(ctx context.Context, nodeID mrtype.KeyInt32) error {
if nodeID < 1 {
return mrcore.ErrUseCaseIncorrectInputData.New("node", mrmsg.Data{"nodeId": nodeID})
Expand Down Expand Up @@ -90,7 +90,7 @@ func (co *Component) InsertToFirst(ctx context.Context, nodeID mrtype.KeyInt32)
return nil
}

// InsertToLast - comment func.
// InsertToLast - comment method.
func (co *Component) InsertToLast(ctx context.Context, nodeID mrtype.KeyInt32) error {
if nodeID < 1 {
return mrcore.ErrUseCaseIncorrectInputData.New("node", mrmsg.Data{"nodeId": nodeID})
Expand Down Expand Up @@ -125,7 +125,7 @@ func (co *Component) InsertToLast(ctx context.Context, nodeID mrtype.KeyInt32) e
return nil
}

// MoveToFirst - comment func.
// MoveToFirst - comment method.
func (co *Component) MoveToFirst(ctx context.Context, nodeID mrtype.KeyInt32) error {
if nodeID < 1 {
return mrcore.ErrUseCaseIncorrectInputData.New("node", mrmsg.Data{"nodeId": nodeID})
Expand Down Expand Up @@ -203,7 +203,7 @@ func (co *Component) MoveToFirst(ctx context.Context, nodeID mrtype.KeyInt32) er
return nil
}

// MoveToLast - comment func.
// MoveToLast - comment method.
func (co *Component) MoveToLast(ctx context.Context, nodeID mrtype.KeyInt32) error {
if nodeID < 1 {
return mrcore.ErrUseCaseIncorrectInputData.New("node", mrmsg.Data{"nodeId": nodeID})
Expand Down Expand Up @@ -275,7 +275,7 @@ func (co *Component) MoveToLast(ctx context.Context, nodeID mrtype.KeyInt32) err
return nil
}

// MoveAfterID - comment func.
// MoveAfterID - comment method.
func (co *Component) MoveAfterID(ctx context.Context, nodeID, afterNodeID mrtype.KeyInt32) error {
if afterNodeID < 1 {
return co.MoveToFirst(ctx, nodeID)
Expand Down Expand Up @@ -358,7 +358,7 @@ func (co *Component) MoveAfterID(ctx context.Context, nodeID, afterNodeID mrtype
return nil
}

// Unlink - comment func.
// Unlink - comment method.
func (co *Component) Unlink(ctx context.Context, nodeID mrtype.KeyInt32) error {
if nodeID < 1 {
return co.MoveToFirst(ctx, nodeID)
Expand Down
4 changes: 2 additions & 2 deletions mrsort/mrsort_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

type (
// Orderer - comment interface.
// Orderer - интерфейс управления порядком следования записей.
Orderer interface {
WithMetaData(meta mrstorage.MetaGetter) Orderer
InsertToFirst(ctx context.Context, nodeID mrtype.KeyInt32) error
Expand All @@ -22,7 +22,7 @@ type (
Unlink(ctx context.Context, nodeID mrtype.KeyInt32) error
}

// Storage - comment interface.
// Storage - интерфейс для доступа к записям порядка следования и их модификации.
Storage interface {
WithMetaData(meta mrstorage.MetaGetter) Storage
FetchNode(ctx context.Context, nodeID mrtype.KeyInt32) (entity.Node, error)
Expand Down

0 comments on commit 4b3d493

Please sign in to comment.