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

chore: upgrade to latest go-libs #59

Merged
Merged
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
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
exclude: client
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: .cloud
- id: check-added-large-files
- repo: https://github.com/formancehq/pre-commit-hooks
rev: dd079f7c30ad72446d615f55a000d4f875e79633
hooks:
- id: gogenerate
files: swagger.yaml
- id: gomodtidy
- id: goimports
- id: gofmt
- id: golangci-lint
- id: gotests
- id: commitlint
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ lint-fix:

run-tests:
go test -race -count=1 ./...

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
Payments works as a standalone binary, the latest of which can be downloaded from the [releases page](https://github.com/formancehq/payments/releases). You can move the binary to any executable path, such as to `/usr/local/bin`. Installations using brew, apt, yum or docker are also [available](https://docs.formance.com/oss/payments/get-started/installation).

```SHELL
payments
payments
```

# What is it?

Basically, a framework.

A framework to ingest payin and payout coming from different payment providers (PSP).
A framework to ingest payin and payout coming from different payment providers (PSP).

The framework contains connectors. Each connector is basically a translator for a PSP.
Translator, because the main role of a connector is to translate specific PSP payin/payout formats to a generalized format used at Formance.
Expand Down
60 changes: 24 additions & 36 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

_ "github.com/bombsimon/logrusr/v3"
"github.com/formancehq/go-libs/sharedotlp/pkg/sharedotlptraces"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -37,46 +38,33 @@ func rootCommand() *cobra.Command {
root.AddCommand(server)

root.PersistentFlags().Bool(debugFlag, false, "Debug mode")
root.Flags().BoolP("toggle", "t", false, "Help message for toggle")
root.Flags().Bool(debugFlag, false, "Debug mode")
root.Flags().String(mongodbURIFlag, "mongodb://localhost:27017", "MongoDB address")
root.Flags().String(mongodbDatabaseFlag, "payments", "MongoDB database name")
root.Flags().Bool(otelTracesFlag, false, "Enable OpenTelemetry traces support")
root.Flags().String(otelTracesExporterFlag, "stdout", "OpenTelemetry traces exporter")
root.Flags().String(otelTracesExporterJaegerEndpointFlag,
"", "OpenTelemetry traces Jaeger exporter endpoint")
root.Flags().String(otelTracesExporterJaegerUserFlag,
"", "OpenTelemetry traces Jaeger exporter user")
root.Flags().String(otelTracesExporterJaegerPasswordFlag,
"", "OpenTelemetry traces Jaeger exporter password")
root.Flags().String(otelTracesExporterOTLPModeFlag,
"grpc", "OpenTelemetry traces OTLP exporter mode (grpc|http)")
root.Flags().String(otelTracesExporterOTLPEndpointFlag,
"", "OpenTelemetry traces grpc endpoint")
root.Flags().Bool(otelTracesExporterOTLPInsecureFlag,
false, "OpenTelemetry traces grpc insecure")
root.Flags().String(envFlag, "local", "Environment")
root.Flags().Bool(publisherKafkaEnabledFlag, false, "Publish write events to kafka")
root.Flags().StringSlice(publisherKafkaBrokerFlag, []string{}, "Kafka address is kafka enabled")
root.Flags().StringSlice(publisherTopicMappingFlag,
server.Flags().BoolP("toggle", "t", false, "Help message for toggle")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set flags on server command and not un root command.

server.Flags().String(mongodbURIFlag, "mongodb://localhost:27017", "MongoDB address")
server.Flags().String(mongodbDatabaseFlag, "payments", "MongoDB database name")
server.Flags().String(envFlag, "local", "Environment")
server.Flags().Bool(publisherKafkaEnabledFlag, false, "Publish write events to kafka")
server.Flags().StringSlice(publisherKafkaBrokerFlag, []string{}, "Kafka address is kafka enabled")
server.Flags().StringSlice(publisherTopicMappingFlag,
[]string{}, "Define mapping between internal event types and topics")
root.Flags().Bool(publisherHTTPEnabledFlag, false, "Sent write event to http endpoint")
root.Flags().Bool(publisherKafkaSASLEnabled, false, "Enable SASL authentication on kafka publisher")
root.Flags().String(publisherKafkaSASLUsername, "", "SASL username")
root.Flags().String(publisherKafkaSASLPassword, "", "SASL password")
root.Flags().String(publisherKafkaSASLMechanism, "", "SASL authentication mechanism")
root.Flags().Int(publisherKafkaSASLScramSHASize, 512, "SASL SCRAM SHA size")
root.Flags().Bool(publisherKafkaTLSEnabled, false, "Enable TLS to connect on kafka")
root.Flags().Bool(authBasicEnabledFlag, false, "Enable basic auth")
root.Flags().StringSlice(authBasicCredentialsFlag, []string{},
server.Flags().Bool(publisherHTTPEnabledFlag, false, "Sent write event to http endpoint")
server.Flags().Bool(publisherKafkaSASLEnabled, false, "Enable SASL authentication on kafka publisher")
server.Flags().String(publisherKafkaSASLUsername, "", "SASL username")
server.Flags().String(publisherKafkaSASLPassword, "", "SASL password")
server.Flags().String(publisherKafkaSASLMechanism, "", "SASL authentication mechanism")
server.Flags().Int(publisherKafkaSASLScramSHASize, 512, "SASL SCRAM SHA size")
server.Flags().Bool(publisherKafkaTLSEnabled, false, "Enable TLS to connect on kafka")
server.Flags().Bool(authBasicEnabledFlag, false, "Enable basic auth")
server.Flags().StringSlice(authBasicCredentialsFlag, []string{},
"HTTP basic auth credentials (<username>:<password>)")
root.Flags().Bool(authBearerEnabledFlag, false, "Enable bearer auth")
root.Flags().String(authBearerIntrospectURLFlag, "", "OAuth2 introspect URL")
root.Flags().StringSlice(authBearerAudienceFlag, []string{}, "Allowed audiences")
root.Flags().Bool(authBearerAudiencesWildcardFlag, false, "Don't check audience")
root.Flags().Bool(authBearerUseScopesFlag,
server.Flags().Bool(authBearerEnabledFlag, false, "Enable bearer auth")
server.Flags().String(authBearerIntrospectURLFlag, "", "OAuth2 introspect URL")
server.Flags().StringSlice(authBearerAudienceFlag, []string{}, "Allowed audiences")
server.Flags().Bool(authBearerAudiencesWildcardFlag, false, "Don't check audience")
server.Flags().Bool(authBearerUseScopesFlag,
false, "Use scopes as defined by rfc https://datatracker.ietf.org/doc/html/rfc8693")

sharedotlptraces.InitOTLPTracesFlags(server.Flags())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Library now automatically setup flags.


viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_"))
viper.AutomaticEnv()

Expand Down
22 changes: 7 additions & 15 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (

"github.com/Shopify/sarama"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/numary/go-libs/sharedlogging"
"github.com/numary/go-libs/sharedlogging/sharedlogginglogrus"
"github.com/numary/go-libs/sharedotlp/pkg/sharedotlptraces"
"github.com/numary/go-libs/sharedpublish"
"github.com/numary/go-libs/sharedpublish/sharedpublishhttp"
"github.com/numary/go-libs/sharedpublish/sharedpublishkafka"
"github.com/formancehq/go-libs/sharedlogging"
"github.com/formancehq/go-libs/sharedlogging/sharedlogginglogrus"
"github.com/formancehq/go-libs/sharedotlp/pkg/sharedotlptraces"
"github.com/formancehq/go-libs/sharedpublish"
"github.com/formancehq/go-libs/sharedpublish/sharedpublishhttp"
"github.com/formancehq/go-libs/sharedpublish/sharedpublishkafka"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -83,15 +83,7 @@ func runServer(cmd *cobra.Command, args []string) error {
}

options = append(options, databaseOptions)

options = append(options, sharedotlptraces.TracesModule(sharedotlptraces.ModuleConfig{
Exporter: viper.GetString(otelTracesExporterFlag),
OTLPConfig: &sharedotlptraces.OTLPConfig{
Mode: viper.GetString(otelTracesExporterOTLPModeFlag),
Endpoint: viper.GetString(otelTracesExporterOTLPEndpointFlag),
Insecure: viper.GetBool(otelTracesExporterOTLPInsecureFlag),
},
}))
options = append(options, sharedotlptraces.CLITracesModule(viper.GetViper()))

options = append(options,
fx.Provide(fx.Annotate(func(p message.Publisher) *sharedpublish.TopicMapperPublisher {
Expand Down
5 changes: 5 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: [
'@commitlint/config-conventional'
]
}
Loading