Skip to content

Commit

Permalink
feat(BUX-170): add pulse config (#313)
Browse files Browse the repository at this point in the history
* feat(BUX-164): add pulse config

* chore(BUX-164): refactor Pulse config

* chore(BUX-164): define if use beef

* chore(BUX-170): add Pulse config to jsons

* chore(BUX-170): remove unnecessary logs

* chore(BUX-170): require Pulse config when using BEEF

* chore(BUX-170): change the way of providing Pulse auth Key

* chore(BUX-170): update go-paymail

* chore(BUX-164): enable paymail in test env config

* chore: update additional libs

* chore(BUX-164): update bux version

* chore: bump bux-server version
  • Loading branch information
pawellewandowski98 authored Oct 12, 2023
1 parent 3e5eb1a commit 2f7e9e8
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 57 deletions.
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

// main method starts everything for the BUX Server
// @title BUX: Server
// @version v0.5.13
// @version v0.5.14
// @securityDefinitions.apikey bux-auth-xpub
// @in header
// @name bux-auth-xpub
Expand Down
10 changes: 9 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
EnvironmentStaging = "staging"
EnvironmentTest = "test"
HealthRequestPath = "health"
Version = "v0.5.13"
Version = "v0.5.14"
)

// Local variables for configuration
Expand Down Expand Up @@ -74,6 +74,8 @@ type (
MinercraftAPI string `json:"minercraft_api" mapstructure:"minercraft_api"`
MinercraftCustomAPIs []*minercraft.MinerAPIs `json:"minercraft_custom_apis" mapstructure:"minercraft_custom_apis"`
BroadcastClientAPIs []string `json:"broadcast_client_apis" mapstructure:"broadcast_client_apis"`
UseBeef bool `json:"use_beef" mapstructure:"use_beef"`
Pulse *PulseConfig `json:"pulse" mapstructure:"pulse"`
}

// AuthenticationConfig is the configuration for Authentication
Expand Down Expand Up @@ -174,6 +176,12 @@ type (
WriteTimeout time.Duration `json:"write_timeout" mapstructure:"write_timeout"` // 15s
Port string `json:"port" mapstructure:"port"` // 3003
}

// PulseConfig is a configuration for the Pulse service
PulseConfig struct {
PulseURL string `json:"pulse_url" mapstructure:"pulse_url"`
PulseAuthToken string `json:"pulse_auth_token" mapstructure:"pulse_auth_token"`
}
)

// GetUserAgent will return the outgoing user agent
Expand Down
7 changes: 6 additions & 1 deletion config/envs/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,10 @@
},
"broadcast_client_apis": [
"url|token"
]
],
"use_beef": true,
"pulse": {
"pulse_url": "http://localhost:8000/api/v1/chain/merkleroot/verify",
"pulse_auth_token": "asd"
}
}
7 changes: 6 additions & 1 deletion config/envs/docker-compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,10 @@
},
"broadcast_client_apis": [
"url|token"
]
],
"use_beef": true,
"pulse": {
"pulse_url": "http://localhost:8000/api/v1/chain/merkleroot/verify",
"pulse_auth_token": "asd"
}
}
7 changes: 6 additions & 1 deletion config/envs/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,10 @@
},
"broadcast_client_apis": [
"url|token"
]
],
"use_beef": true,
"pulse": {
"pulse_url": "http://localhost:8000/api/v1/chain/merkleroot/verify",
"pulse_auth_token": "asd"
}
}
7 changes: 6 additions & 1 deletion config/envs/staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,10 @@
},
"broadcast_client_apis": [
"url|token"
]
],
"use_beef": true,
"pulse": {
"pulse_url": "http://localhost:8000/api/v1/chain/merkleroot/verify",
"pulse_auth_token": "asd"
}
}
9 changes: 7 additions & 2 deletions config/envs/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"save_destinations": true
},
"paymail": {
"enabled": false,
"enabled": true,
"default_from_paymail": "from@domain.com",
"default_note": "bux Address Resolution",
"domain_validation_enabled": false,
Expand Down Expand Up @@ -98,5 +98,10 @@
},
"broadcast_client_apis": [
"url|token"
]
],
"use_beef": true,
"pulse": {
"pulse_url": "http://localhost:8000/api/v1/chain/merkleroot/verify",
"pulse_auth_token": "asd"
}
}
10 changes: 9 additions & 1 deletion config/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ func (s *AppServices) loadBux(ctx context.Context, appConfig *AppConfig, testMod
))
}

if appConfig.UseBeef {

if appConfig.Pulse == nil || appConfig.Pulse.PulseURL == "" {
err = errors.New("pulse is required for BEEF to work")
return
}
options = append(options, bux.WithPaymailBeefSupport(appConfig.Pulse.PulseURL, appConfig.Pulse.PulseAuthToken))
}

// Load task manager (redis or taskq)
// todo: this needs more improvement with redis options etc
if appConfig.TaskManager.Engine == taskmanager.TaskQ {
Expand Down Expand Up @@ -304,7 +313,6 @@ func (s *AppServices) loadBux(ctx context.Context, appConfig *AppConfig, testMod

if appConfig.BroadcastClientAPIs != nil {
arcClientConfigs := splitBroadcastClientApis(appConfig.BroadcastClientAPIs)
fmt.Println("arcClientConfigs", arcClientConfigs)
options = append(options, bux.WithBroadcastClientAPIs(arcClientConfigs))

builder := broadcast_client.Builder()
Expand Down
2 changes: 1 addition & 1 deletion docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "BUX: Server",
"contact": {},
"version": "v0.5.13"
"version": "v0.5.14"
},
"paths": {
"/v1/access-key": {
Expand Down Expand Up @@ -1871,4 +1871,4 @@
"in": "header"
}
}
}
}
2 changes: 1 addition & 1 deletion docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
info:
contact: {}
title: 'BUX: Server'
version: v0.5.13
version: v0.5.14
paths:
/v1/access-key:
delete:
Expand Down
34 changes: 15 additions & 19 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2f7e9e8

Please sign in to comment.