mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 20:36:12 +02:00
context propagation: pkg/apiserver (#3272)
* context propagation: apic.Push() * context propagation: NewServer() * lint
This commit is contained in:
parent
40021b6bcf
commit
b9bccfa56f
12 changed files with 59 additions and 61 deletions
|
@ -159,11 +159,9 @@ func newGinLogger(config *csconfig.LocalApiServerCfg) (*log.Logger, string, erro
|
|||
|
||||
// NewServer creates a LAPI server.
|
||||
// It sets up a gin router, a database client, and a controller.
|
||||
func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) {
|
||||
func NewServer(ctx context.Context, config *csconfig.LocalApiServerCfg) (*APIServer, error) {
|
||||
var flushScheduler *gocron.Scheduler
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
dbClient, err := database.NewClient(ctx, config.DbConfig)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to init database client: %w", err)
|
||||
|
@ -300,8 +298,8 @@ func (s *APIServer) Router() (*gin.Engine, error) {
|
|||
return s.router, nil
|
||||
}
|
||||
|
||||
func (s *APIServer) apicPush() error {
|
||||
if err := s.apic.Push(); err != nil {
|
||||
func (s *APIServer) apicPush(ctx context.Context) error {
|
||||
if err := s.apic.Push(ctx); err != nil {
|
||||
log.Errorf("capi push: %s", err)
|
||||
return err
|
||||
}
|
||||
|
@ -337,7 +335,7 @@ func (s *APIServer) papiSync() error {
|
|||
}
|
||||
|
||||
func (s *APIServer) initAPIC(ctx context.Context) {
|
||||
s.apic.pushTomb.Go(s.apicPush)
|
||||
s.apic.pushTomb.Go(func() error { return s.apicPush(ctx) })
|
||||
s.apic.pullTomb.Go(func() error { return s.apicPull(ctx) })
|
||||
|
||||
// csConfig.API.Server.ConsoleConfig.ShareCustomScenarios
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue