Skip to content

Commit

Permalink
See changelog 2024-10-09
Browse files Browse the repository at this point in the history
  • Loading branch information
mondegor committed Oct 8, 2024
1 parent 0b5408e commit f179aa0
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 162 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ issues:
linters:
- dupl
- gosec
- gochecknoglobals
- exhaustruct
- forbidigo
- forcetypeassert
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# GoStorage Changelog
Все изменения библиотеки GoComponents будут документироваться на этой странице.

## 2024-10-09
### Changed
- Заменены следующие типы:
- `mrtype.KeyInt32` -> `uint64`;
- `mrentity.ZeronullInt32` -> `mrentity.ZeronullUint64`;

## 2024-09-29
### Changed
- Обновлены зависимости библиотеки;
Expand Down
13 changes: 3 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
-include Makefile.mk

.PHONY: deps
deps:
mrcmd go-dev deps

.PHONY: deps-upgrade
deps-upgrade:
mrcmd go-dev get -u ./...
mrcmd go-dev tidy

.PHONY: generate
generate:
mrcmd go-dev generate

.PHONY: fmt
fmt:
mrcmd go-dev fmt

.PHONY: fmti
fmti:
mrcmd go-dev fmti

.PHONY: lint
lint:
mrcmd golangci-lint check

.PHONY: test
test:
mrcmd go-dev test

.PHONY: test-report
test-report:
mrcmd go-dev test-report

.PHONY: plantuml
plantuml:
mrcmd plantuml build-all
mrcmd plantuml build-all

.PHONY: deps deps-upgrade generate fmt fmti lint test test-report plantuml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Описание GoComponents v0.7.12
# Описание GoComponents v0.7.13
Этот репозиторий содержит описание библиотеки GoComponents.

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

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

## Установка библиотеки для её локальной разработки
- Выбрать рабочую директорию, где должна быть расположена библиотека
Expand Down
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ module github.com/mondegor/go-components

go 1.22.0

toolchain go1.22.6

require (
github.com/mondegor/go-storage v0.13.1
github.com/mondegor/go-sysmess v0.11.3
github.com/mondegor/go-webcore v0.24.1
github.com/mondegor/go-storage v0.14.0
github.com/mondegor/go-sysmess v0.11.5
github.com/mondegor/go-webcore v0.25.0
)

require (
Expand All @@ -16,9 +14,10 @@ require (
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/text v0.19.0 // indirect
)

// replace github.com/mondegor/go-storage => ../go-storage
Expand Down
22 changes: 12 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/mondegor/go-storage v0.13.1 h1:gq6JpEaBoDBHtKN9o/lUPJW6Zi/TUNuKZblEhRtCLiI=
github.com/mondegor/go-storage v0.13.1/go.mod h1:4FPm7K/FeVIngIgV97HNWB4ZstVKgoAWlYy2zLUhbmc=
github.com/mondegor/go-sysmess v0.11.3 h1:/rOghgdgkkpe2GJtJSuWH7hIs8RxPueXyfyG3kKrgr0=
github.com/mondegor/go-sysmess v0.11.3/go.mod h1:lmtm83olOIDpxyfhjLT5ZTX4sQIUYH/Gv2A6pfbCSsc=
github.com/mondegor/go-webcore v0.24.1 h1:a8P1qLG4JgJ54Ml1t13ljysxDUDwNRls+ymRe8m00Io=
github.com/mondegor/go-webcore v0.24.1/go.mod h1:oL9AksLoN4OTtEpocrnaziWpQc4tfeTnMIdfTnV/OzU=
github.com/mondegor/go-storage v0.14.0 h1:NmA4GbIkjyV2nut9MNUHIZte/hfRSA/TBMxT2kG1YEc=
github.com/mondegor/go-storage v0.14.0/go.mod h1:MUqjmzBoHX2QefmkSI3dbVFkq1xqh5ur2U3rck233HQ=
github.com/mondegor/go-sysmess v0.11.5 h1:pI+8xPDwsXUSYYSnWg7hICJdB7I/CRMOjiVuO6N6p30=
github.com/mondegor/go-sysmess v0.11.5/go.mod h1:lmtm83olOIDpxyfhjLT5ZTX4sQIUYH/Gv2A6pfbCSsc=
github.com/mondegor/go-webcore v0.25.0 h1:vK9pzqxFas9LyOquUSdVktpbjPdSySrh0qAsoYlgq0k=
github.com/mondegor/go-webcore v0.25.0/go.mod h1:VgKlVPHPwTzz8z0Q+5oyQyNgIch+ve/UQ2onPf0Mlfk=
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=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 h1:1wqE9dj9NpSm04INVsJhhEUzhuDVjbcyKH91sVyPATw=
golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
16 changes: 8 additions & 8 deletions mrsettings/component/cachegetter/cache_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type (
reloadMu sync.Mutex
lastUpdated time.Time
settingsMu sync.RWMutex
settings map[mrtype.KeyInt32]entity.CachedSetting
settings map[uint64]entity.CachedSetting
}
)

Expand All @@ -38,12 +38,12 @@ func New(parser mrsettings.ValueParser, storage mrsettings.StorageLoader, errorW
parser: parser,
storage: storage,
errorWrapper: errorWrapper,
settings: make(map[mrtype.KeyInt32]entity.CachedSetting, 0),
settings: make(map[uint64]entity.CachedSetting),
}
}

// Get - comment method.
func (co *Component) Get(_ context.Context, id mrtype.KeyInt32) (string, error) {
func (co *Component) Get(_ context.Context, id uint64) (string, error) {
co.settingsMu.RLock()
value, ok := co.settings[id]
co.settingsMu.RUnlock()
Expand All @@ -56,7 +56,7 @@ func (co *Component) Get(_ context.Context, id mrtype.KeyInt32) (string, error)
}

// GetList - comment method.
func (co *Component) GetList(_ context.Context, id mrtype.KeyInt32) ([]string, error) {
func (co *Component) GetList(_ context.Context, id uint64) ([]string, error) {
co.settingsMu.RLock()
value, ok := co.settings[id]
co.settingsMu.RUnlock()
Expand All @@ -69,7 +69,7 @@ func (co *Component) GetList(_ context.Context, id mrtype.KeyInt32) ([]string, e
}

// GetInt64 - comment method.
func (co *Component) GetInt64(_ context.Context, id mrtype.KeyInt32) (int64, error) {
func (co *Component) GetInt64(_ context.Context, id uint64) (int64, error) {
co.settingsMu.RLock()
value, ok := co.settings[id]
co.settingsMu.RUnlock()
Expand All @@ -82,7 +82,7 @@ func (co *Component) GetInt64(_ context.Context, id mrtype.KeyInt32) (int64, err
}

// GetInt64List - comment method.
func (co *Component) GetInt64List(_ context.Context, id mrtype.KeyInt32) ([]int64, error) {
func (co *Component) GetInt64List(_ context.Context, id uint64) ([]int64, error) {
co.settingsMu.RLock()
value, ok := co.settings[id]
co.settingsMu.RUnlock()
Expand All @@ -95,7 +95,7 @@ func (co *Component) GetInt64List(_ context.Context, id mrtype.KeyInt32) ([]int6
}

// GetBool - comment method.
func (co *Component) GetBool(_ context.Context, id mrtype.KeyInt32) (bool, error) {
func (co *Component) GetBool(_ context.Context, id uint64) (bool, error) {
co.settingsMu.RLock()
value, ok := co.settings[id]
co.settingsMu.RUnlock()
Expand Down Expand Up @@ -181,7 +181,7 @@ func (co *Component) makeItem(item entity.Setting) (setting entity.CachedSetting
case enum.SettingTypeBoolean:
var boolValue bool
boolValue, err = co.parser.ParseBool(item.Value)
setting.ValueInt64 = mrtype.BoolToInt64(boolValue)
setting.ValueInt64 = mrtype.CastBoolToNumber[int64](boolValue)
}

if err != nil {
Expand Down
13 changes: 6 additions & 7 deletions mrsettings/component/getter/component_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/mondegor/go-sysmess/mrmsg"
"github.com/mondegor/go-webcore/mrcore"
"github.com/mondegor/go-webcore/mrtype"

"github.com/mondegor/go-components/mrsettings"
"github.com/mondegor/go-components/mrsettings/entity"
Expand All @@ -32,7 +31,7 @@ func New(parser mrsettings.ValueParser, storage mrsettings.Storage, errorWrapper
}

// Get - comment method.
func (co *Component) Get(ctx context.Context, id mrtype.KeyInt32) (string, error) {
func (co *Component) Get(ctx context.Context, id uint64) (string, error) {
value, err := co.getValue(ctx, id, enum.SettingTypeString)
if err != nil {
return "", err
Expand All @@ -47,7 +46,7 @@ func (co *Component) Get(ctx context.Context, id mrtype.KeyInt32) (string, error
}

// GetList - comment method.
func (co *Component) GetList(ctx context.Context, id mrtype.KeyInt32) ([]string, error) {
func (co *Component) GetList(ctx context.Context, id uint64) ([]string, error) {
value, err := co.getValue(ctx, id, enum.SettingTypeStringList)
if err != nil {
return nil, err
Expand All @@ -62,7 +61,7 @@ func (co *Component) GetList(ctx context.Context, id mrtype.KeyInt32) ([]string,
}

// GetInt64 - comment method.
func (co *Component) GetInt64(ctx context.Context, id mrtype.KeyInt32) (int64, error) {
func (co *Component) GetInt64(ctx context.Context, id uint64) (int64, error) {
value, err := co.getValue(ctx, id, enum.SettingTypeInteger)
if err != nil {
return 0, err
Expand All @@ -77,7 +76,7 @@ func (co *Component) GetInt64(ctx context.Context, id mrtype.KeyInt32) (int64, e
}

// GetInt64List - comment method.
func (co *Component) GetInt64List(ctx context.Context, id mrtype.KeyInt32) ([]int64, error) {
func (co *Component) GetInt64List(ctx context.Context, id uint64) ([]int64, error) {
value, err := co.getValue(ctx, id, enum.SettingTypeIntegerList)
if err != nil {
return nil, err
Expand All @@ -92,7 +91,7 @@ func (co *Component) GetInt64List(ctx context.Context, id mrtype.KeyInt32) ([]in
}

// GetBool - comment method.
func (co *Component) GetBool(ctx context.Context, id mrtype.KeyInt32) (bool, error) {
func (co *Component) GetBool(ctx context.Context, id uint64) (bool, error) {
value, err := co.getValue(ctx, id, enum.SettingTypeBoolean)
if err != nil {
return false, err
Expand All @@ -106,7 +105,7 @@ func (co *Component) GetBool(ctx context.Context, id mrtype.KeyInt32) (bool, err
return parsedValue, nil
}

func (co *Component) getValue(ctx context.Context, id mrtype.KeyInt32, rowType enum.SettingType) (string, error) {
func (co *Component) getValue(ctx context.Context, id uint64, rowType enum.SettingType) (string, error) {
row, err := co.storage.FetchOne(ctx, id)
if err != nil {
return "", co.errorWrapper.WrapErrorEntityNotFoundOrFailed(err, entity.ModelNameSetting, mrmsg.Data{"id": id})
Expand Down
11 changes: 5 additions & 6 deletions mrsettings/component/lightgetter/component_light_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"

"github.com/mondegor/go-webcore/mrlog"
"github.com/mondegor/go-webcore/mrtype"

"github.com/mondegor/go-components/mrsettings"
)
Expand All @@ -25,7 +24,7 @@ func New(reader mrsettings.Getter) *Component {
}

// Get - comment method.
func (co *Component) Get(ctx context.Context, id mrtype.KeyInt32, defaultVal string) string {
func (co *Component) Get(ctx context.Context, id uint64, defaultVal string) string {
value, err := co.reader.Get(ctx, id)
if err != nil {
mrlog.Ctx(ctx).Error().Err(err).Send()
Expand All @@ -37,7 +36,7 @@ func (co *Component) Get(ctx context.Context, id mrtype.KeyInt32, defaultVal str
}

// GetList - comment method.
func (co *Component) GetList(ctx context.Context, id mrtype.KeyInt32, defaultVal []string) []string {
func (co *Component) GetList(ctx context.Context, id uint64, defaultVal []string) []string {
value, err := co.reader.GetList(ctx, id)
if err != nil {
mrlog.Ctx(ctx).Error().Err(err).Send()
Expand All @@ -49,7 +48,7 @@ func (co *Component) GetList(ctx context.Context, id mrtype.KeyInt32, defaultVal
}

// GetInt64 - comment method.
func (co *Component) GetInt64(ctx context.Context, id mrtype.KeyInt32, defaultVal int64) int64 {
func (co *Component) GetInt64(ctx context.Context, id uint64, defaultVal int64) int64 {
value, err := co.reader.GetInt64(ctx, id)
if err != nil {
mrlog.Ctx(ctx).Error().Err(err).Send()
Expand All @@ -61,7 +60,7 @@ func (co *Component) GetInt64(ctx context.Context, id mrtype.KeyInt32, defaultVa
}

// GetInt64List - comment method.
func (co *Component) GetInt64List(ctx context.Context, id mrtype.KeyInt32, defaultVal []int64) []int64 {
func (co *Component) GetInt64List(ctx context.Context, id uint64, defaultVal []int64) []int64 {
value, err := co.reader.GetInt64List(ctx, id)
if err != nil {
mrlog.Ctx(ctx).Error().Err(err).Send()
Expand All @@ -73,7 +72,7 @@ func (co *Component) GetInt64List(ctx context.Context, id mrtype.KeyInt32, defau
}

// GetBool - comment method.
func (co *Component) GetBool(ctx context.Context, id mrtype.KeyInt32, defaultVal bool) bool {
func (co *Component) GetBool(ctx context.Context, id uint64, defaultVal bool) bool {
value, err := co.reader.GetBool(ctx, id)
if err != nil {
mrlog.Ctx(ctx).Error().Err(err).Send()
Expand Down
13 changes: 6 additions & 7 deletions mrsettings/component/setter/component_setter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/mondegor/go-sysmess/mrmsg"
"github.com/mondegor/go-webcore/mrcore"
"github.com/mondegor/go-webcore/mrsender"
"github.com/mondegor/go-webcore/mrtype"

"github.com/mondegor/go-components/mrsettings"
"github.com/mondegor/go-components/mrsettings/entity"
Expand Down Expand Up @@ -39,7 +38,7 @@ func New(
}

// Set - comment method.
func (co *Component) Set(ctx context.Context, id mrtype.KeyInt32, value string) error {
func (co *Component) Set(ctx context.Context, id uint64, value string) error {
formattedValue, err := co.formatter.FormatString(value)
if err != nil {
return err
Expand All @@ -55,7 +54,7 @@ func (co *Component) Set(ctx context.Context, id mrtype.KeyInt32, value string)
}

// SetList - comment method.
func (co *Component) SetList(ctx context.Context, id mrtype.KeyInt32, value []string) error {
func (co *Component) SetList(ctx context.Context, id uint64, value []string) error {
formattedValue, err := co.formatter.FormatStringList(value)
if err != nil {
return err
Expand All @@ -71,7 +70,7 @@ func (co *Component) SetList(ctx context.Context, id mrtype.KeyInt32, value []st
}

// SetInt64 - comment method.
func (co *Component) SetInt64(ctx context.Context, id mrtype.KeyInt32, value int64) error {
func (co *Component) SetInt64(ctx context.Context, id uint64, value int64) error {
formattedValue, err := co.formatter.FormatInt64(value)
if err != nil {
return err
Expand All @@ -87,7 +86,7 @@ func (co *Component) SetInt64(ctx context.Context, id mrtype.KeyInt32, value int
}

// SetInt64List - comment method.
func (co *Component) SetInt64List(ctx context.Context, id mrtype.KeyInt32, value []int64) error {
func (co *Component) SetInt64List(ctx context.Context, id uint64, value []int64) error {
formattedValue, err := co.formatter.FormatInt64List(value)
if err != nil {
return err
Expand All @@ -103,7 +102,7 @@ func (co *Component) SetInt64List(ctx context.Context, id mrtype.KeyInt32, value
}

// SetBool - comment method.
func (co *Component) SetBool(ctx context.Context, id mrtype.KeyInt32, value bool) error {
func (co *Component) SetBool(ctx context.Context, id uint64, value bool) error {
formattedValue, err := co.formatter.FormatBool(value)
if err != nil {
return err
Expand All @@ -118,7 +117,7 @@ func (co *Component) SetBool(ctx context.Context, id mrtype.KeyInt32, value bool
return nil
}

func (co *Component) setValue(ctx context.Context, id mrtype.KeyInt32, value string, rowType enum.SettingType) error {
func (co *Component) setValue(ctx context.Context, id uint64, value string, rowType enum.SettingType) error {
row := entity.Setting{
ID: id,
Type: rowType,
Expand Down
Loading

0 comments on commit f179aa0

Please sign in to comment.