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
5d7fa8d2
Commit
5d7fa8d2
authored
Aug 25, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensure w.Add is called in the same routine as as w.Done
parent
f8b3e028
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
indexer.go
indexer/indexer.go
+25
-24
No files found.
indexer/indexer.go
View file @
5d7fa8d2
...
...
@@ -72,39 +72,40 @@ func (i *Indexer) Run(ctx context.Context) error {
var
wg
sync
.
WaitGroup
errCh
:=
make
(
chan
error
,
3
)
//
If either processor errors out, we stop
//
if any goroutine halts, we stop the entire indexer
subCtx
,
cancel
:=
context
.
WithCancel
(
ctx
)
run
:=
func
(
start
func
(
ctx
context
.
Context
)
error
)
{
wg
.
Add
(
1
)
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
i
.
log
.
Error
(
"halting indexer on panic"
,
"err"
,
err
)
debug
.
PrintStack
()
errCh
<-
fmt
.
Errorf
(
"panic: %v"
,
err
)
}
cancel
()
wg
.
Done
()
go
func
()
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
i
.
log
.
Error
(
"halting indexer on panic"
,
"err"
,
err
)
debug
.
PrintStack
()
errCh
<-
fmt
.
Errorf
(
"panic: %v"
,
err
)
}
cancel
()
wg
.
Done
()
}()
errCh
<-
start
(
subCtx
)
}()
err
:=
start
(
subCtx
)
if
err
!=
nil
{
i
.
log
.
Error
(
"halting indexer on error"
,
"err"
,
err
)
}
// Send a value down regardless if we've received an error
// or halted via cancellation where err == nil
errCh
<-
err
}
// Kick off all the dependent routines
go
run
(
i
.
L1ETL
.
Start
)
go
run
(
i
.
L2ETL
.
Start
)
go
run
(
i
.
BridgeProcessor
.
Start
)
run
(
i
.
L1ETL
.
Start
)
run
(
i
.
L2ETL
.
Start
)
run
(
i
.
BridgeProcessor
.
Start
)
wg
.
Wait
()
// Since we wait to receipt of an error
err
:=
<-
errCh
if
err
!=
nil
{
i
.
log
.
Error
(
"indexer stopped"
,
"err"
,
err
)
}
else
{
i
.
log
.
Info
(
"indexer stopped"
)
}
wg
.
Wait
()
i
.
log
.
Info
(
"indexer stopped"
)
return
err
}
...
...
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