Skip to content

Commit

Permalink
fix: Add shutdown for server
Browse files Browse the repository at this point in the history
  • Loading branch information
highpon committed Dec 17, 2024
1 parent 1d9062c commit e9db705
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pkg/index/job/exportation/service/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const (
type Exporter interface {
StartClient(ctx context.Context) (<-chan error, error)
Start(ctx context.Context) error
PreStop(ctx context.Context) error
}

type export struct {
Expand Down Expand Up @@ -215,3 +216,7 @@ func (e *export) doExportIndex(
}
}
}

func (e *export) PreStop(ctx context.Context) error {
return e.storedVector.Close(false)

Check warning on line 221 in pkg/index/job/exportation/service/exporter.go

View check run for this annotation

Codecov / codecov/patch

pkg/index/job/exportation/service/exporter.go#L220-L221

Added lines #L220 - L221 were not covered by tests
}
11 changes: 8 additions & 3 deletions pkg/index/job/exportation/usecase/exportation.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (r *run) PreStart(ctx context.Context) error {
// during the operation and an error representing any initialization errors.
func (r *run) Start(ctx context.Context) (<-chan error, error) {
ech := make(chan error, 3)
var sech, oech, cech <-chan error
var sech, oech <-chan error
if r.observability != nil {
oech = r.observability.Start(ctx)
}
Expand Down Expand Up @@ -167,8 +167,8 @@ func (r *run) Start(ctx context.Context) (<-chan error, error) {
}

// PreStop is a method called before execution of Stop.
func (*run) PreStop(_ context.Context) error {
return nil
func (r *run) PreStop(ctx context.Context) error {
return r.exporter.PreStop(ctx)

Check warning on line 171 in pkg/index/job/exportation/usecase/exportation.go

View check run for this annotation

Codecov / codecov/patch

pkg/index/job/exportation/usecase/exportation.go#L170-L171

Added lines #L170 - L171 were not covered by tests
}

// Stop is a method used to stop an operation in the run.
Expand All @@ -178,6 +178,11 @@ func (r *run) Stop(ctx context.Context) (errs error) {
errs = errors.Join(errs, err)
}

Check warning on line 179 in pkg/index/job/exportation/usecase/exportation.go

View check run for this annotation

Codecov / codecov/patch

pkg/index/job/exportation/usecase/exportation.go#L175-L179

Added lines #L175 - L179 were not covered by tests
}
if r.server != nil {
if err := r.server.Shutdown(ctx); err != nil {
errs = errors.Join(errs, err)
}

Check warning on line 184 in pkg/index/job/exportation/usecase/exportation.go

View check run for this annotation

Codecov / codecov/patch

pkg/index/job/exportation/usecase/exportation.go#L181-L184

Added lines #L181 - L184 were not covered by tests
}
return errs

Check warning on line 186 in pkg/index/job/exportation/usecase/exportation.go

View check run for this annotation

Codecov / codecov/patch

pkg/index/job/exportation/usecase/exportation.go#L186

Added line #L186 was not covered by tests
}

Expand Down

0 comments on commit e9db705

Please sign in to comment.