Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use flipt sdk instead deprected package #230

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
inpackage: True
with-expecter: True
testonly: False
inpackage: True
with-expecter: True
testonly: False
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN --mount=type=cache,mode=0777,target=${GOCACHE} \
--mount=type=cache,mode=0777,target=${GOMODCACHE} \
go build -o /tmp/app

FROM alpine
FROM alpine
WORKDIR /app

ENV MODE="docker"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ test-wo-cache: clean-test-cache test
build:
go build -o=$(app_name) .

install:
install:
go build -ldflags="-s -w" -o=$(app_name) .
2 changes: 1 addition & 1 deletion assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,4 @@
}
}
}
}
}
7 changes: 4 additions & 3 deletions constants/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package constants

// variables
const (
CookieUser = "user"
CookieUser = "user"
KratosCookie = "ory_kratos_session"
)

Expand All @@ -13,9 +13,10 @@ const (

// kratos
const (
KratosID = "kratosId"
KratosID = "kratosId"
KratosUserDetails = "kratosUserDetails"
)

// params
const (
ParamUid = "userId"
Expand Down Expand Up @@ -43,7 +44,7 @@ const (
ErrKratosAuth = "error while fetching user from kratos"
ErrKratosDataInsertion = "error while inserting user data came from kratos"
ErrKratosIDEmpty = "error no session_id found in kratos cookie"
ErrKratosCookieTime = "error while parsing the expiration time of the cookie"
ErrKratosCookieTime = "error while parsing the expiration time of the cookie"
)

// Events
Expand Down
2 changes: 1 addition & 1 deletion controllers/api/v1/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (ctrl *UserController) CreateUser(c *fiber.Ctx) error {
if err != nil {
return utils.JSONFail(c, http.StatusBadRequest, utils.ValidatorErrorString(err))
}

user, err := ctrl.userService.RegisterUser(models.User{FirstName: userReq.FirstName, LastName: userReq.LastName, Email: userReq.Email, Password: userReq.Password, Roles: userReq.Roles}, ctrl.event)
if err != nil {
ctrl.logger.Error("error while insert user", zap.Error(err))
Expand Down
9 changes: 5 additions & 4 deletions database/watermill_mysql_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import (
)

// custom schema for mysql database
// source: https://github.com/ThreeDotsLabs/watermill-sql/blob/master/pkg/sql/schema_adapter_mysql.go
// source: https://github.com/ThreeDotsLabs/watermill-sql/blob/master/pkg/sql/schema_adapter_mysql.go
type MySQLSchema struct {
GenerateMessagesTableName func(topic string) string
SubscribeBatchSize int
SubscribeBatchSize int
}

func (s MySQLSchema) SchemaInitializingQueries(topic string) []string {
createMessagesTable := strings.Join([]string{
"CREATE TABLE IF NOT EXISTS " + s.MessagesTable(topic) + " (",
Expand Down Expand Up @@ -61,9 +62,9 @@ func (s MySQLSchema) SelectQuery(topic string, consumerGroup string, offsetsAdap
nextOffsetQuery, nextOffsetArgs := offsetsAdapter.NextOffsetQuery(topic, consumerGroup)
selectQuery := `
SELECT offset, uuid, payload, metadata FROM ` + s.MessagesTable(topic) + `
WHERE
WHERE
offset > (` + nextOffsetQuery + `)
ORDER BY
ORDER BY
offset ASC
LIMIT ` + fmt.Sprintf("%d", s.batchSize())

Expand Down
12 changes: 6 additions & 6 deletions database/watermill_postgres_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (

type PostgreSQLSchema struct {
GenerateMessagesTableName func(topic string) string
SubscribeBatchSize int
SubscribeBatchSize int
}

func (s PostgreSQLSchema) SchemaInitializingQueries(topic string) []string {
createMessagesTable := `
createMessagesTable := `
CREATE TABLE IF NOT EXISTS ` + s.MessagesTable(topic) + ` (
"offset" SERIAL,
"uuid" VARCHAR(36) NOT NULL,
Expand Down Expand Up @@ -97,17 +97,17 @@ func (s PostgreSQLSchema) SelectQuery(topic string, consumerGroup string, offset

SELECT "offset", transaction_id, uuid, payload, metadata FROM ` + s.MessagesTable(topic) + `

WHERE
WHERE
(
(
transaction_id = (SELECT last_processed_transaction_id FROM last_processed)
AND
transaction_id = (SELECT last_processed_transaction_id FROM last_processed)
AND
"offset" > (SELECT offset_acked FROM last_processed)
)
OR
(transaction_id > (SELECT last_processed_transaction_id FROM last_processed))
)
AND
AND
transaction_id < pg_snapshot_xmin(pg_current_snapshot())
ORDER BY
transaction_id ASC,
Expand Down
76 changes: 39 additions & 37 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/Improwised/golang-api

go 1.21
go 1.22

toolchain go1.21.6
toolchain go1.23.0

require (
clevergo.tech/jsend v1.1.3
cloud.google.com/go/pubsub v1.36.0
cloud.google.com/go/pubsub v1.37.0
github.com/Shopify/sarama v1.38.0
github.com/ThreeDotsLabs/watermill v1.3.5
github.com/ThreeDotsLabs/watermill-amqp v1.1.4
Expand Down Expand Up @@ -34,11 +34,11 @@ require (
github.com/samber/lo v1.38.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
go.flipt.io/flipt-grpc v1.11.0
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.18.0
google.golang.org/grpc v1.60.1
github.com/stretchr/testify v1.9.0
go.flipt.io/flipt/sdk/go v0.12.0
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.24.0
google.golang.org/grpc v1.66.0
gopkg.in/go-playground/validator.v9 v9.31.0
)

Expand All @@ -54,57 +54,60 @@ require (
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/rabbitmq/amqp091-go v1.9.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
go.flipt.io/flipt/errors v1.45.0 // indirect
go.flipt.io/flipt/rpc/flipt v1.45.0
go.mongodb.org/mongo-driver v1.11.3 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.157.0 // indirect
google.golang.org/api v0.170.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240122161410-6c6643bf1457 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go v0.112.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.7 // indirect
github.com/Rican7/retry v0.3.1 // indirect
github.com/ThreeDotsLabs/watermill-sql/v2 v2.0.0
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/eapache/go-resiliency v1.3.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofiber/contrib/swagger v1.1.1
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
Expand All @@ -126,7 +129,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
Expand All @@ -135,25 +138,24 @@ require (
github.com/sony/gobreaker v0.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/streadway/amqp v1.0.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.50.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/otelsarama v0.31.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading