Skip to content

Commit

Permalink
edge sync recv (#361)
Browse files Browse the repository at this point in the history
* fix IdleTimeout init
* refactor edge sync and add recv
* address linter issues
* refactor builtin test, use single engine instance
  • Loading branch information
gertd authored Apr 11, 2024
1 parent affebd9 commit 180b7cc
Show file tree
Hide file tree
Showing 10 changed files with 444 additions and 272 deletions.
25 changes: 25 additions & 0 deletions cmd/topazd/topaz_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ import (
"github.com/aserto-dev/topaz/pkg/app"
"github.com/aserto-dev/topaz/pkg/app/topaz"
"github.com/aserto-dev/topaz/pkg/cc/config"
"github.com/aserto-dev/topaz/pkg/debug"
"github.com/spf13/cobra"
"golang.org/x/sync/errgroup"
)

var (
flagRunConfigFile string
flagRunBundleFiles []string
flagRunWatchLocalBundles bool
flagRunIgnorePaths []string
flagRunDebug bool
debugService *debug.Server
errGroup *errgroup.Group
)

var cmdRun = &cobra.Command{
Expand All @@ -38,6 +43,13 @@ var cmdRun = &cobra.Command{
if flagRunWatchLocalBundles {
cfg.OPA.LocalBundles.Watch = true
}

if flagRunDebug {
cfg.Debug.Enabled = true
cfg.Debug.ListenAddress = "localhost:6060"
cfg.Debug.ShutdownTimeout = 5
}

})
defer func() {
if cleanup != nil {
Expand All @@ -52,6 +64,13 @@ var cmdRun = &cobra.Command{
if err != nil {
return err
}

if topazApp.Configuration.Debug.Enabled {
errGroup = new(errgroup.Group)
debugService = debug.NewServer(&topazApp.Configuration.Debug, topazApp.Logger, errGroup)
debugService.Start()
}

if _, ok := topazApp.Services["authorizer"]; ok {
directory := topaz.DirectoryResolver(topazApp.Context, topazApp.Logger, topazApp.Configuration)
decisionlog, err := topazApp.GetDecisionLogger(topazApp.Configuration.DecisionLogger)
Expand Down Expand Up @@ -79,6 +98,8 @@ var cmdRun = &cobra.Command{

<-topazApp.Context.Done()

debugService.Stop()

return nil
},
}
Expand All @@ -101,6 +122,10 @@ func init() {
&flagRunIgnorePaths,
"ignore", "", []string{},
"set file and directory names to ignore during loading local bundles (e.g., '.*' excludes hidden files)")
cmdRun.Flags().BoolVarP(
&flagRunDebug,
"debug", "", false,
"start debug service")
rootCmd.AddCommand(cmdRun)
cmdRun.MarkFlagRequired("config-file")
}
108 changes: 56 additions & 52 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/aserto-dev/topaz
go 1.21

// replace github.com/aserto-dev/go-directory => ../go-directory
// replace aserto-dev/go-directory-cli => ../go-directory-cli
// replace github.com/aserto-dev/go-edge-ds => ../go-edge-ds
// replace github.com/aserto-dev/azm => ../azm
// replace github.com/aserto-dev/go-topaz-ui => ../go-topaz-ui
Expand All @@ -14,15 +15,15 @@ require (
github.com/alecthomas/kong v0.9.0
github.com/aserto-dev/aserto-grpc v0.2.2
github.com/aserto-dev/aserto-management v0.9.4
github.com/aserto-dev/azm v0.1.5
github.com/aserto-dev/certs v0.0.5
github.com/aserto-dev/azm v0.1.8
github.com/aserto-dev/certs v0.0.6
github.com/aserto-dev/clui v0.8.3
github.com/aserto-dev/errors v0.0.7
github.com/aserto-dev/go-aserto v0.31.2
github.com/aserto-dev/go-aserto v0.31.3-0.20240411011658-eecfb593dc54
github.com/aserto-dev/go-authorizer v0.20.5
github.com/aserto-dev/go-directory v0.31.2
github.com/aserto-dev/go-directory-cli v0.31.0
github.com/aserto-dev/go-edge-ds v0.31.2
github.com/aserto-dev/go-directory v0.31.3
github.com/aserto-dev/go-directory-cli v0.31.1
github.com/aserto-dev/go-edge-ds v0.31.4
github.com/aserto-dev/go-grpc v0.8.63
github.com/aserto-dev/go-topaz-ui v0.1.4
github.com/aserto-dev/header v0.0.7
Expand All @@ -31,12 +32,12 @@ require (
github.com/aserto-dev/openapi-directory v0.31.1
github.com/aserto-dev/runtime v0.62.1
github.com/aserto-dev/self-decision-logger v0.0.5
github.com/aserto-dev/service-host v0.0.9
github.com/aserto-dev/service-host v0.0.10
github.com/cli/browser v1.3.0
github.com/docker/docker v25.0.4+incompatible
github.com/docker/docker v26.0.0+incompatible
github.com/docker/go-connections v0.5.0
github.com/fatih/color v1.16.0
github.com/fullstorydev/grpcurl v1.8.9
github.com/fullstorydev/grpcurl v1.9.1
github.com/google/uuid v1.6.0
github.com/google/wire v0.6.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
Expand All @@ -45,8 +46,8 @@ require (
github.com/magefile/mage v1.15.0
github.com/mennanov/fmutils v0.3.0
github.com/mitchellh/mapstructure v1.5.0
github.com/open-policy-agent/opa v0.62.1
github.com/opencontainers/image-spec v1.1.0-rc6
github.com/open-policy-agent/opa v0.63.0
github.com/opencontainers/image-spec v1.1.0
github.com/panmari/cuckoofilter v1.0.6
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.32.0
Expand All @@ -55,39 +56,42 @@ require (
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
go.opencensus.io v0.24.0
golang.org/x/sync v0.6.0
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
golang.org/x/sync v0.7.0
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002
gopkg.in/natefinch/lumberjack.v2 v2.2.1
sigs.k8s.io/controller-runtime v0.17.2
sigs.k8s.io/controller-runtime v0.17.3
)

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1 // indirect
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240401165935-b983156c5e99.1 // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/Microsoft/hcsshim v0.12.2 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/aserto-dev/go-decision-logs v0.0.4 // indirect
github.com/aserto-dev/go-http-metrics v0.10.1-20221024-1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bufbuild/protocompile v0.7.1 // indirect
github.com/bufbuild/protovalidate-go v0.6.0 // indirect
github.com/bufbuild/protocompile v0.10.0 // indirect
github.com/bufbuild/protovalidate-go v0.6.1 // indirect
github.com/bytecodealliance/wasmtime-go/v3 v3.0.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/containerd v1.7.13 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20240329184929-0c46c01016dc // indirect
github.com/containerd/containerd v1.7.15 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/envoyproxy/go-control-plane v0.12.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-http-utils/headers v0.0.0-20181008091004-fed159eddc2a // indirect
Expand All @@ -106,13 +110,13 @@ require (
github.com/google/subcommands v1.2.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jhump/protoreflect v1.15.4 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/jhump/protoreflect v1.16.0 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/kyokomi/emoji v2.2.4+incompatible // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
Expand All @@ -127,25 +131,26 @@ require (
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/nats-io/jwt/v2 v2.5.3 // indirect
github.com/nats-io/nats-server/v2 v2.10.7 // indirect
github.com/nats-io/nats.go v1.31.0 // indirect
github.com/nats-io/jwt/v2 v2.5.5 // indirect
github.com/nats-io/nats-server/v2 v2.10.12 // indirect
github.com/nats-io/nats.go v1.34.1 // indirect
github.com/nats-io/nkeys v0.4.7 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/statsd_exporter v0.26.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/prometheus/statsd_exporter v0.26.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand All @@ -161,29 +166,28 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/yashtewari/glob-intersection v0.2.0 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.etcd.io/bbolt v1.3.9 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/sdk v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.18.0 // indirect
google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
oras.land/oras-go/v2 v2.3.1 // indirect
oras.land/oras-go/v2 v2.5.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 180b7cc

Please sign in to comment.