Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
1a237256
Unverified
Commit
1a237256
authored
Sep 11, 2023
by
Ethen Pociask
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[indexer.risk_mitigations] [indexer] Added Write Timeouts & Closure Handling
parent
bc602c07
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
5 deletions
+19
-5
api.go
indexer/api/api.go
+2
-0
cli.go
indexer/cmd/indexer/cli.go
+12
-2
config.go
indexer/config/config.go
+4
-3
indexer.toml
indexer/indexer.toml
+1
-0
No files found.
indexer/api/api.go
View file @
1a237256
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"net/http"
"net/http"
"runtime/debug"
"runtime/debug"
"sync"
"sync"
"time"
"github.com/ethereum-optimism/optimism/indexer/api/routes"
"github.com/ethereum-optimism/optimism/indexer/api/routes"
"github.com/ethereum-optimism/optimism/indexer/config"
"github.com/ethereum-optimism/optimism/indexer/config"
...
@@ -46,6 +47,7 @@ func NewApi(logger log.Logger, bv database.BridgeTransfersView, serverConfig con
...
@@ -46,6 +47,7 @@ func NewApi(logger log.Logger, bv database.BridgeTransfersView, serverConfig con
promRecorder
:=
metrics
.
NewPromHTTPRecorder
(
mr
,
MetricsNamespace
)
promRecorder
:=
metrics
.
NewPromHTTPRecorder
(
mr
,
MetricsNamespace
)
apiRouter
.
Use
(
chiMetricsMiddleware
(
promRecorder
))
apiRouter
.
Use
(
chiMetricsMiddleware
(
promRecorder
))
apiRouter
.
Use
(
middleware
.
Timeout
(
time
.
Duration
(
serverConfig
.
WriteTimeout
)
*
time
.
Second
))
apiRouter
.
Use
(
middleware
.
Recoverer
)
apiRouter
.
Use
(
middleware
.
Recoverer
)
apiRouter
.
Use
(
middleware
.
Heartbeat
(
"/healthz"
))
apiRouter
.
Use
(
middleware
.
Heartbeat
(
"/healthz"
))
...
...
indexer/cmd/indexer/cli.go
View file @
1a237256
...
@@ -36,7 +36,12 @@ func runIndexer(ctx *cli.Context) error {
...
@@ -36,7 +36,12 @@ func runIndexer(ctx *cli.Context) error {
log
.
Error
(
"failed to connect to database"
,
"err"
,
err
)
log
.
Error
(
"failed to connect to database"
,
"err"
,
err
)
return
err
return
err
}
}
defer
db
.
Close
()
defer
func
()
{
err
:=
db
.
Close
()
if
err
!=
nil
{
log
.
Error
(
"failed to close database"
,
"err"
,
err
)
}
}()
indexer
,
err
:=
indexer
.
NewIndexer
(
log
,
db
,
cfg
.
Chain
,
cfg
.
RPCs
,
cfg
.
HTTPServer
,
cfg
.
MetricsServer
)
indexer
,
err
:=
indexer
.
NewIndexer
(
log
,
db
,
cfg
.
Chain
,
cfg
.
RPCs
,
cfg
.
HTTPServer
,
cfg
.
MetricsServer
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -60,7 +65,12 @@ func runApi(ctx *cli.Context) error {
...
@@ -60,7 +65,12 @@ func runApi(ctx *cli.Context) error {
log
.
Error
(
"failed to connect to database"
,
"err"
,
err
)
log
.
Error
(
"failed to connect to database"
,
"err"
,
err
)
return
err
return
err
}
}
defer
db
.
Close
()
defer
func
()
{
err
:=
db
.
Close
()
if
err
!=
nil
{
log
.
Error
(
"failed to close database"
,
"err"
,
err
)
}
}()
api
:=
api
.
NewApi
(
log
,
db
.
BridgeTransfers
,
cfg
.
HTTPServer
,
cfg
.
MetricsServer
)
api
:=
api
.
NewApi
(
log
,
db
.
BridgeTransfers
,
cfg
.
HTTPServer
,
cfg
.
MetricsServer
)
return
api
.
Start
(
ctx
.
Context
)
return
api
.
Start
(
ctx
.
Context
)
...
...
indexer/config/config.go
View file @
1a237256
...
@@ -96,10 +96,11 @@ type DBConfig struct {
...
@@ -96,10 +96,11 @@ type DBConfig struct {
Password
string
`toml:"password"`
Password
string
`toml:"password"`
}
}
// Configures the
a
server
// Configures the server
type
ServerConfig
struct
{
type
ServerConfig
struct
{
Host
string
`toml:"host"`
Host
string
`toml:"host"`
Port
int
`toml:"port"`
Port
int
`toml:"port"`
WriteTimeout
int
`toml:"timeout"`
}
}
// LoadConfig loads the `indexer.toml` config file from a given path
// LoadConfig loads the `indexer.toml` config file from a given path
...
...
indexer/indexer.toml
View file @
1a237256
...
@@ -35,6 +35,7 @@ name = "$INDEXER_DB_NAME"
...
@@ -35,6 +35,7 @@ name = "$INDEXER_DB_NAME"
[http]
[http]
host
=
"127.0.0.1"
host
=
"127.0.0.1"
port
=
8080
port
=
8080
timeout
=
10
[metrics]
[metrics]
host
=
"127.0.0.1"
host
=
"127.0.0.1"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment