Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MG-36 - Global ticker for scheduled rules #42

Merged
merged 16 commits into from
Jan 24, 2025
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ define make_docker_dev
-f docker/Dockerfile.dev ./build
endef

ADDON_SERVICES = bootstrap journal provision certs timescale-reader timescale-writer postgres-reader postgres-writer
ADDON_SERVICES = bootstrap journal provision certs timescale-reader timescale-writer postgres-reader postgres-writer re

EXTERNAL_SERVICES = vault prometheus

Expand Down
7 changes: 6 additions & 1 deletion cmd/re/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ func main() {
go chc.CallHome(ctx)
}

// Start scheduler
g.Go(func() error {
return svc.StartScheduler(ctx)
})

// Start all servers
g.Go(func() error {
return httpSvc.Start()
Expand All @@ -201,7 +206,7 @@ func newService(ctx context.Context, db *sqlx.DB, dbConfig pgclient.Config, auth
idp := uuid.New()

// csvc = authzmw.AuthorizationMiddleware(csvc, authz)
csvc := re.NewService(repo, idp, nil)
csvc := re.NewService(repo, idp, nil, re.NewTicker(time.Minute))

return csvc, nil
}
2 changes: 1 addition & 1 deletion docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ MG_RE_DB_HOST=re-db
MG_RE_DB_PORT=5432
MG_RE_DB_USER=magistrala
MG_RE_DB_PASS=magistrala
MG_RE_DB_NAME=rule_engine
MG_RE_DB_NAME=rules_engine
MG_RE_DB_SSL_MODE=disable
MG_RE_DB_SSL_CERT=
MG_RE_DB_SSL_KEY=
Expand Down
2 changes: 1 addition & 1 deletion re/api/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func decodeAddRuleRequest(_ context.Context, r *http.Request) (interface{}, erro
}
var rule re.Rule
if err := json.NewDecoder(r.Body).Decode(&rule); err != nil {
return nil, err
return nil, errors.Wrap(err, apiutil.ErrValidation)
}
return addRuleReq{Rule: rule}, nil
}
Expand Down
189 changes: 189 additions & 0 deletions re/mocks/repo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading