Skip to content

Commit dee3166

Browse files
committed
chore: run golines
Use ``` golines -w --ignore-generated --chain-split-dots --max-len=80 --reformat-tags . ``` Signed-off-by: Chris Gianelloni <[email protected]>
1 parent d8b302b commit dee3166

File tree

4 files changed

+47
-10
lines changed

4 files changed

+47
-10
lines changed

api/api.go

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ func Start(cfg *config.Config) error {
3636
router.POST("/api/submit/tx", handleSubmitTx)
3737

3838
// Start listener
39-
err := router.Run(fmt.Sprintf("%s:%d", cfg.Api.ListenAddress, cfg.Api.ListenPort))
39+
err := router.Run(
40+
fmt.Sprintf("%s:%d", cfg.Api.ListenAddress, cfg.Api.ListenPort),
41+
)
4042
return err
4143
}
4244

@@ -88,16 +90,28 @@ func handleSubmitTx(c *gin.Context) {
8890
clientTrace := &httptrace.ClientTrace{
8991
GotConn: func(info httptrace.GotConnInfo) { connReused = info.Reused },
9092
}
91-
traceCtx := httptrace.WithClientTrace(context.Background(), clientTrace)
92-
req, err := http.NewRequestWithContext(traceCtx, http.MethodPost, backend, body)
93+
traceCtx := httptrace.WithClientTrace(
94+
context.Background(),
95+
clientTrace,
96+
)
97+
req, err := http.NewRequestWithContext(
98+
traceCtx,
99+
http.MethodPost,
100+
backend,
101+
body,
102+
)
93103
if err != nil {
94104
logger.Errorf("failed to create request: %s", err)
95105
return
96106
}
97107
req.Header.Add("Content-Type", "application/cbor")
98108
resp, err := http.DefaultClient.Do(req)
99109
if err != nil {
100-
logger.Errorf("failed to send request to backend %s: %s", backend, err)
110+
logger.Errorf(
111+
"failed to send request to backend %s: %s",
112+
backend,
113+
err,
114+
)
101115
return
102116
}
103117
elapsedTime := time.Since(startTime)
@@ -109,7 +123,17 @@ func handleSubmitTx(c *gin.Context) {
109123
}
110124
defer resp.Body.Close()
111125
if resp.StatusCode == 202 {
112-
logger.Infow(fmt.Sprintf("successfully submitted transaction %s to backend %s", tx.Hash(), backend), "latency", elapsedTime.Seconds(), "connReused", connReused)
126+
logger.Infow(
127+
fmt.Sprintf(
128+
"successfully submitted transaction %s to backend %s",
129+
tx.Hash(),
130+
backend,
131+
),
132+
"latency",
133+
elapsedTime.Seconds(),
134+
"connReused",
135+
connReused,
136+
)
113137
} else {
114138
logger.Errorw(fmt.Sprintf("failed to send request to backend %s: got response %d, %s", backend, resp.StatusCode, string(respBody)), "latency", elapsedTime.Seconds(), "connReused", connReused)
115139
}

cmd/tx-submit-api-mirror/main.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ var cmdlineFlags struct {
1515
}
1616

1717
func main() {
18-
flag.StringVar(&cmdlineFlags.configFile, "config", "", "path to config file to load")
18+
flag.StringVar(
19+
&cmdlineFlags.configFile,
20+
"config",
21+
"",
22+
"path to config file to load",
23+
)
1924
flag.Parse()
2025

2126
// Load config
@@ -38,7 +43,11 @@ func main() {
3843
}()
3944

4045
// Start API listener
41-
logger.Infof("starting API listener on %s:%d", cfg.Api.ListenAddress, cfg.Api.ListenPort)
46+
logger.Infof(
47+
"starting API listener on %s:%d",
48+
cfg.Api.ListenAddress,
49+
cfg.Api.ListenPort,
50+
)
4251
if err := api.Start(cfg); err != nil {
4352
logger.Fatalf("failed to start API: %s", err)
4453
}

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type LoggingConfig struct {
1919

2020
type ApiConfig struct {
2121
ListenAddress string `yaml:"address" envconfig:"API_LISTEN_ADDRESS"`
22-
ListenPort uint `yaml:"port" envconfig:"API_LISTEN_PORT"`
22+
ListenPort uint `yaml:"port" envconfig:"API_LISTEN_PORT"`
2323
}
2424

2525
// Singleton config instance with default values

logging/logging.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ func Setup(cfg *config.LoggingConfig) {
2020
// Change timestamp key name
2121
loggerConfig.EncoderConfig.TimeKey = "timestamp"
2222
// Use a human readable time format
23-
loggerConfig.EncoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout(time.RFC3339)
23+
loggerConfig.EncoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout(
24+
time.RFC3339,
25+
)
2426

2527
// Set level
2628
if cfg.Level != "" {
@@ -50,5 +52,7 @@ func GetDesugaredLogger() *zap.Logger {
5052
}
5153

5254
func GetAccessLogger() *zap.Logger {
53-
return globalLogger.Desugar().With(zap.String("type", "access")).WithOptions(zap.WithCaller(false))
55+
return globalLogger.Desugar().
56+
With(zap.String("type", "access")).
57+
WithOptions(zap.WithCaller(false))
5458
}

0 commit comments

Comments
 (0)