-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go native sqlite dockerfile go releaser cli
- Loading branch information
Showing
12 changed files
with
389 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.idea | ||
bin | ||
dist | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
ldflags: | ||
- -s -w -X main.version={{ .Version }} | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm | ||
- arm64 | ||
goarm: | ||
- 6 | ||
- 7 | ||
ignore: | ||
- goos: windows | ||
goarch: arm | ||
goarm: 7 | ||
- goos: windows | ||
goarch: arm | ||
goarm: 6 | ||
- goos: windows | ||
goarch: arm64 | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
release: | ||
github: | ||
owner: mikekonan | ||
name: freqtrade-proxy | ||
draft: true | ||
name_template: "{{.ProjectName}}-v{{.Version}}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,70 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/Gurpartap/logrus-stack" | ||
logrus_stack "github.com/Gurpartap/logrus-stack" | ||
"github.com/jaffee/commandeer" | ||
"github.com/mikekonan/freqtradeProxy/proxy/kucoin" | ||
"github.com/mikekonan/freqtradeProxy/store" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func main() { | ||
logrus.SetOutput(os.Stdout) | ||
logrus.AddHook(logrus_stack.StandardHook()) | ||
var version = "dev" | ||
|
||
port := flag.Int("port", 8080, "listen port") | ||
verbose := flag.Int("verbose", 0, "verbose level. 0 - info [default]. 1 - debug. 2 - trace.") | ||
flag.Parse() | ||
type app struct { | ||
Config kucoin.Config `flag:"!embed"` | ||
Verbose int `help:"verbose level: 0 - info, 1 - debug, 2 - trace"` | ||
} | ||
|
||
func newApp() *app { | ||
return &app{ | ||
Verbose: 0, | ||
Config: kucoin.Config{ | ||
Port: "8080", | ||
Bindaddr: "0.0.0.0", | ||
}, | ||
} | ||
} | ||
|
||
switch *verbose { | ||
func (m *app) configure() { | ||
switch m.Verbose { | ||
case 0: | ||
logrus.SetLevel(logrus.InfoLevel) | ||
case 1: | ||
logrus.SetLevel(logrus.DebugLevel) | ||
case 2: | ||
logrus.SetLevel(logrus.TraceLevel) | ||
} | ||
} | ||
|
||
func (a *app) Run() error { | ||
logrus.SetOutput(os.Stdout) | ||
logrus.AddHook(logrus_stack.StandardHook()) | ||
|
||
logrus.Infof("freqtrade-proxy version - %s", version) | ||
|
||
s := store.New() | ||
k := kucoin.New(s) | ||
k.Start(*port) | ||
if a.Verbose > 2 { | ||
return fmt.Errorf("wrong verbose level '%d'", a.Verbose) | ||
} | ||
|
||
a.configure() | ||
|
||
if err := a.Config.Validate(); err != nil { | ||
return err | ||
} | ||
|
||
k := kucoin.New(store.New(), a.Config) | ||
k.Start() | ||
|
||
return nil | ||
} | ||
|
||
func main() { | ||
app := newApp() | ||
|
||
if err := commandeer.Run(app); err != nil { | ||
logrus.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package kucoin | ||
|
||
import ( | ||
"github.com/go-ozzo/ozzo-validation/v4" | ||
"github.com/go-ozzo/ozzo-validation/v4/is" | ||
) | ||
|
||
type Config struct { | ||
Port string `help:"listen port"` | ||
Bindaddr string `help:"bindable address"` | ||
//Localaddr string `help:"local address (use it if you understand what you are doing)"` | ||
} | ||
|
||
func (c Config) Validate() error { | ||
return validation.ValidateStruct(&c, | ||
validation.Field(&c.Port, is.Port), | ||
validation.Field(&c.Bindaddr, is.IPv4), | ||
//validation.Field(&c.Localaddr, validation.When(c.Localaddr != "", is.IPv4)), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters