From 5a9c82207578fe70515e975c4b4d6813db38fdc6 Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Tue, 19 Aug 2025 11:40:06 +0300 Subject: [PATCH] added the grassrootseconomics/go-vise package to visedriver --- config/config.go | 6 ++-- config/config_test.go | 5 +-- config/reporter_noop.go | 15 ++++---- doc/data.md | 2 +- entry/handlers.go | 4 +-- go.mod | 18 +++++----- go.sum | 34 ++++++++++--------- request/base.go | 8 ++--- request/http/server.go | 4 +-- request/http/server_test.go | 2 +- request/request.go | 10 +++--- storage/storage.go | 4 +-- storage/storage_service.go | 28 ++++++--------- storage/storage_service_test.go | 2 +- .../mocks/httpmocks/request_handler_mock.go | 6 ++-- testutil/mocks/storage.go | 8 ++--- 16 files changed, 75 insertions(+), 81 deletions(-) diff --git a/config/config.go b/config/config.go index 30fbbef..294d99b 100644 --- a/config/config.go +++ b/config/config.go @@ -4,13 +4,13 @@ import ( "strconv" "strings" - "git.defalsify.org/vise.git/logging" "git.grassecon.net/grassrootseconomics/visedriver/env" "git.grassecon.net/grassrootseconomics/visedriver/storage" + slogging "github.com/grassrootseconomics/go-vise/slog" ) var ( - logg = logging.NewVanilla().WithDomain("visedriver-config") + logg = slogging.Get().With("component", "visedriver-config") defaultLanguage = "eng" languages []string DefaultLanguage string @@ -136,7 +136,7 @@ func GetConns() (storage.Conns, error) { // LoadConfig initializes the configuration values after environment variables are loaded. func LoadConfig() error { - configManager = NewConfig(logg) + configManager = NewConfig() // Add configuration keys with validation configManager.AddKey("HOST", "127.0.0.1", false, nil) diff --git a/config/config_test.go b/config/config_test.go index 6c07375..9d43da1 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,3 +1,4 @@ +//go:build configreport // +build configreport package config @@ -7,12 +8,12 @@ import ( "os" "testing" - "git.defalsify.org/vise.git/logging" + slogging "github.com/grassrootseconomics/go-vise/slog" ) // go test -tags configreport ./config/... ---> run with tag func TestConfig(t *testing.T) { - logger := logging.NewVanilla().WithDomain("test") + logger := slogging.Get().With("component", "test") cfg := NewConfig(logger) t.Run("Default Values", func(t *testing.T) { diff --git a/config/reporter_noop.go b/config/reporter_noop.go index 67e4d71..822e335 100644 --- a/config/reporter_noop.go +++ b/config/reporter_noop.go @@ -2,20 +2,17 @@ package config -import ( - "git.defalsify.org/vise.git/logging" -) - type Config struct{} -func NewConfig(logger logging.Vanilla) *Config { - return &Config{} +func NewConfig() *Config { + return &Config{} } -func (c *Config) AddKey(key string, defaultValue string, sensitive bool, validator func(string) error) {} +func (c *Config) AddKey(key string, defaultValue string, sensitive bool, validator func(string) error) { +} func (c *Config) GetValue(key string) (string, error) { - return "", nil + return "", nil } -func (c *Config) Report(level string) {} \ No newline at end of file +func (c *Config) Report(level string) {} diff --git a/doc/data.md b/doc/data.md index 7a41f0c..e93930b 100644 --- a/doc/data.md +++ b/doc/data.md @@ -10,7 +10,7 @@ This document describes component versions: ## User profile data -All user profile items are stored under keys matching the user's session id, prefixed with the 8-bit value `git.defalsify.org/vise.git/db.DATATYPE_USERDATA` (32), and followed with a 16-big big-endian value subprefix. +All user profile items are stored under keys matching the user's session id, prefixed with the 8-bit value `github.com/grassrootseconomics/go-vise/db.DATATYPE_USERDATA` (32), and followed with a 16-big big-endian value subprefix. For example, given the sessionId `+254123` and the key `git.grassecon.net/urdt-ussd/common.DATA_PUBLIC_KEY` (2) will be stored under the key: diff --git a/entry/handlers.go b/entry/handlers.go index 8622e6a..beb32c0 100644 --- a/entry/handlers.go +++ b/entry/handlers.go @@ -3,8 +3,8 @@ package entry import ( "context" - "git.defalsify.org/vise.git/persist" - "git.defalsify.org/vise.git/resource" + "github.com/grassrootseconomics/go-vise/persist" + "github.com/grassrootseconomics/go-vise/resource" ) type EntryHandler interface { diff --git a/go.mod b/go.mod index c6c6084..e49dde8 100644 --- a/go.mod +++ b/go.mod @@ -1,27 +1,29 @@ module git.grassecon.net/grassrootseconomics/visedriver -go 1.23.0 +go 1.24 + +toolchain go1.24.6 require ( git.defalsify.org/vise.git v0.2.3-0.20250204132233-2bffe532f21e - github.com/jackc/pgx/v5 v5.7.1 + github.com/grassrootseconomics/go-vise v0.5.0 + github.com/jackc/pgx/v5 v5.7.5 github.com/joho/godotenv v1.5.1 ) require ( github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/fxamacker/cbor/v2 v2.4.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.0 // indirect github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect - github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a // indirect + github.com/leonelquinteros/gotext v1.7.2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/stretchr/testify v1.9.0 // indirect github.com/x448/float16 v0.8.4 // indirect - golang.org/x/crypto v0.27.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/text v0.18.0 // indirect - gopkg.in/leonelquinteros/gotext.v1 v1.3.1 // indirect + golang.org/x/crypto v0.40.0 // indirect + golang.org/x/sync v0.16.0 // indirect + golang.org/x/text v0.27.0 // indirect ) diff --git a/go.sum b/go.sum index bd4f3e1..a98f6e7 100644 --- a/go.sum +++ b/go.sum @@ -5,24 +5,28 @@ github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c/go.mod h1:rGod7 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88= -github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= +github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= +github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/grassrootseconomics/go-vise v0.5.0 h1:FRg2de55Eb5SisrgTBeFWfWX+sXwp5q9r7YWtKWDwsk= +github.com/grassrootseconomics/go-vise v0.5.0/go.mod h1:b2/q4jfTu2i1wyUwYUu7FYq4m2f1AZv8MpiDM3ZcoGo= github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 h1:U4kkNYryi/qfbBF8gh7Vsbuz+cVmhf5kt6pE9bYYyLo= github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4/go.mod h1:zpZDgZFzeq9s0MIeB1P50NIEWDFFHSFBohI/NbaTD/Y= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -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/pgx/v5 v5.7.5 h1:JHGfMnQY+IEtGM63d+NGMjoRpysB2JBwDr5fsngwmJs= +github.com/jackc/pgx/v5 v5.7.5/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M= 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/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= -github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a h1:0Q3H0YXzMHiciXtRcM+j0jiCe8WKPQHoRgQiRTnfcLY= -github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a/go.mod h1:CdTTBOYzS5E4mWS1N8NWP6AHI19MP0A2B18n3hLzRMk= -github.com/pashagolub/pgxmock/v4 v4.3.0 h1:DqT7fk0OCK6H0GvqtcMsLpv8cIwWqdxWgfZNLeHCb/s= -github.com/pashagolub/pgxmock/v4 v4.3.0/go.mod h1:9VoVHXwS3XR/yPtKGzwQvwZX1kzGB9sM8SviDcHDa3A= +github.com/leonelquinteros/gotext v1.7.2 h1:bDPndU8nt+/kRo1m4l/1OXiiy2v7Z7dfPQ9+YP7G1Mc= +github.com/leonelquinteros/gotext v1.7.2/go.mod h1:9/haCkm5P7Jay1sxKDGJ5WIg4zkz8oZKw4ekNpALob8= +github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w= +github.com/lmittmann/tint v1.1.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= +github.com/pashagolub/pgxmock/v4 v4.7.0 h1:de2ORuFYyjwOQR7NBm57+321RnZxpYiuUjsmqRiqgh8= +github.com/pashagolub/pgxmock/v4 v4.7.0/go.mod h1:9L57pC193h2aKRHVyiiE817avasIPZnPwPlw3JczWvM= github.com/peteole/testdata-loader v0.3.0 h1:8jckE9KcyNHgyv/VPoaljvKZE0Rqr8+dPVYH6rfNr9I= github.com/peteole/testdata-loader v0.3.0/go.mod h1:Mt0ZbRtb56u8SLJpNP+BnQbENljMorYBpqlvt3cS83U= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -35,15 +39,13 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -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/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/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= +golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= +golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= +golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/leonelquinteros/gotext.v1 v1.3.1 h1:8d9/fdTG0kn/B7NNGV1BsEyvektXFAbkMsTZS2sFSCc= -gopkg.in/leonelquinteros/gotext.v1 v1.3.1/go.mod h1:X1WlGDeAFIYsW6GjgMm4VwUwZ2XjI7Zan2InxSUQWrU= 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= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/request/base.go b/request/base.go index 30400c0..0e65f0f 100644 --- a/request/base.go +++ b/request/base.go @@ -3,10 +3,10 @@ package request import ( "context" - "git.defalsify.org/vise.git/db" - "git.defalsify.org/vise.git/engine" - "git.defalsify.org/vise.git/persist" - "git.defalsify.org/vise.git/resource" + "github.com/grassrootseconomics/go-vise/db" + "github.com/grassrootseconomics/go-vise/engine" + "github.com/grassrootseconomics/go-vise/persist" + "github.com/grassrootseconomics/go-vise/resource" "git.grassecon.net/grassrootseconomics/visedriver/entry" "git.grassecon.net/grassrootseconomics/visedriver/errors" "git.grassecon.net/grassrootseconomics/visedriver/storage" diff --git a/request/http/server.go b/request/http/server.go index 97a2dd8..d23f35a 100644 --- a/request/http/server.go +++ b/request/http/server.go @@ -4,13 +4,13 @@ import ( "net/http" "strconv" - "git.defalsify.org/vise.git/logging" "git.grassecon.net/grassrootseconomics/visedriver/errors" "git.grassecon.net/grassrootseconomics/visedriver/request" + slogging "github.com/grassrootseconomics/go-vise/slog" ) var ( - logg = logging.NewVanilla().WithDomain("visedriver.http.session") + logg = slogging.Get().With("component", "visedriver.http.session") ) // HTTPRequestHandler implements the session handler for HTTP diff --git a/request/http/server_test.go b/request/http/server_test.go index 8bfaf8f..9078bcb 100644 --- a/request/http/server_test.go +++ b/request/http/server_test.go @@ -8,7 +8,7 @@ import ( "net/http/httptest" "testing" - "git.defalsify.org/vise.git/engine" + "github.com/grassrootseconomics/go-vise/engine" viseerrors "git.grassecon.net/grassrootseconomics/visedriver/errors" "git.grassecon.net/grassrootseconomics/visedriver/request" "git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks/httpmocks" diff --git a/request/request.go b/request/request.go index 279d504..2d3f4e3 100644 --- a/request/request.go +++ b/request/request.go @@ -4,15 +4,15 @@ import ( "context" "io" - "git.defalsify.org/vise.git/engine" - "git.defalsify.org/vise.git/logging" - "git.defalsify.org/vise.git/persist" - "git.defalsify.org/vise.git/resource" "git.grassecon.net/grassrootseconomics/visedriver/storage" + "github.com/grassrootseconomics/go-vise/engine" + "github.com/grassrootseconomics/go-vise/persist" + "github.com/grassrootseconomics/go-vise/resource" + slogging "github.com/grassrootseconomics/go-vise/slog" ) var ( - logg = logging.NewVanilla().WithDomain("visedriver.request") + logg = slogging.Get().With("component", "visedriver.request") ) type RequestSession struct { diff --git a/storage/storage.go b/storage/storage.go index 391835c..4e87e3c 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -3,8 +3,8 @@ package storage import ( "context" - "git.defalsify.org/vise.git/db" - "git.defalsify.org/vise.git/persist" + "github.com/grassrootseconomics/go-vise/db" + "github.com/grassrootseconomics/go-vise/persist" ) const ( diff --git a/storage/storage_service.go b/storage/storage_service.go index 4f18702..b9d1710 100644 --- a/storage/storage_service.go +++ b/storage/storage_service.go @@ -5,22 +5,20 @@ import ( "errors" "fmt" "os" - "path" - "git.defalsify.org/vise.git/db" - fsdb "git.defalsify.org/vise.git/db/fs" - memdb "git.defalsify.org/vise.git/db/mem" - "git.defalsify.org/vise.git/db/postgres" - "git.defalsify.org/vise.git/lang" - "git.defalsify.org/vise.git/logging" - "git.defalsify.org/vise.git/persist" - "git.defalsify.org/vise.git/resource" - gdbmstorage "git.grassecon.net/grassrootseconomics/visedriver/storage/db/gdbm" + "github.com/grassrootseconomics/go-vise/db" + fsdb "github.com/grassrootseconomics/go-vise/db/fs" + memdb "github.com/grassrootseconomics/go-vise/db/mem" + "github.com/grassrootseconomics/go-vise/db/postgres" + "github.com/grassrootseconomics/go-vise/lang" + "github.com/grassrootseconomics/go-vise/persist" + "github.com/grassrootseconomics/go-vise/resource" + slogging "github.com/grassrootseconomics/go-vise/slog" "github.com/jackc/pgx/v5/pgxpool" ) var ( - logg = logging.NewVanilla().WithDomain("storage") + logg = slogging.Get().With("component", "storage") ) type StorageService interface { @@ -94,13 +92,7 @@ func (ms *MenuStorageService) getOrCreateDb(ctx context.Context, section string, return nil, err } newDb = postgres.NewPgDb().WithSchema(connData.Domain()) - } else if dbTyp == DBTYPE_GDBM { - err = ms.ensureDbDir(connStr) - if err != nil { - return nil, err - } - connStr = path.Join(connStr, section) - newDb = gdbmstorage.NewThreadGdbmDb() + } else if dbTyp == DBTYPE_FS { err = ms.ensureDbDir(connStr) if err != nil { diff --git a/storage/storage_service_test.go b/storage/storage_service_test.go index 37423c6..48c91ca 100644 --- a/storage/storage_service_test.go +++ b/storage/storage_service_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - fsdb "git.defalsify.org/vise.git/db/fs" + fsdb "github.com/grassrootseconomics/go-vise/db/fs" ) func TestMenuStorageServiceOneSet(t *testing.T) { diff --git a/testutil/mocks/httpmocks/request_handler_mock.go b/testutil/mocks/httpmocks/request_handler_mock.go index ee6a9bf..2afe6f7 100644 --- a/testutil/mocks/httpmocks/request_handler_mock.go +++ b/testutil/mocks/httpmocks/request_handler_mock.go @@ -3,10 +3,10 @@ package httpmocks import ( "context" - "git.defalsify.org/vise.git/engine" - "git.defalsify.org/vise.git/persist" - "git.defalsify.org/vise.git/resource" "git.grassecon.net/grassrootseconomics/visedriver/request" + "github.com/grassrootseconomics/go-vise/engine" + "github.com/grassrootseconomics/go-vise/persist" + "github.com/grassrootseconomics/go-vise/resource" ) // MockRequestHandler implements request.RequestHandler interface for testing diff --git a/testutil/mocks/storage.go b/testutil/mocks/storage.go index 059bc04..dfa8add 100644 --- a/testutil/mocks/storage.go +++ b/testutil/mocks/storage.go @@ -3,10 +3,10 @@ package mocks import ( "context" - "git.defalsify.org/vise.git/db" - memdb "git.defalsify.org/vise.git/db/mem" - "git.defalsify.org/vise.git/persist" - "git.defalsify.org/vise.git/resource" + "github.com/grassrootseconomics/go-vise/db" + memdb "github.com/grassrootseconomics/go-vise/db/mem" + "github.com/grassrootseconomics/go-vise/persist" + "github.com/grassrootseconomics/go-vise/resource" ) type MemStorageService struct {