diff --git a/pkg/cmd/testing.go b/pkg/cmd/testing.go index b2118b831c..8fd6d583f2 100644 --- a/pkg/cmd/testing.go +++ b/pkg/cmd/testing.go @@ -29,6 +29,7 @@ func RegisterTestingFlags(cmd *cobra.Command, config *testserver.Config) { cmd.Flags().Uint32Var(&config.MaxDeleteRelationshipsLimit, "max-delete-relationships-limit", 1000, "maximum number of relationships that can be deleted in a single request") cmd.Flags().Uint32Var(&config.MaxLookupResourcesLimit, "max-lookup-resources-limit", 1000, "maximum number of resources that can be looked up in a single request") cmd.Flags().Uint32Var(&config.MaxBulkExportRelationshipsLimit, "max-bulk-export-relationships-limit", 10_000, "maximum number of relationships that can be exported in a single request") + cmd.Flags().BoolVar(&config.EnableExperimentalLookupResources, "enable-experimental-lookup-resources", false, "enables the experimental version of the lookup resources API") } func NewTestingCommand(programName string, config *testserver.Config) *cobra.Command { diff --git a/pkg/cmd/testserver/testserver.go b/pkg/cmd/testserver/testserver.go index 78895f2b3a..7d7b22653b 100644 --- a/pkg/cmd/testserver/testserver.go +++ b/pkg/cmd/testserver/testserver.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/ecordell/optgen/helpers" "github.com/rs/zerolog" "golang.org/x/sync/errgroup" "google.golang.org/grpc" @@ -32,19 +33,20 @@ const ( //go:generate go run github.com/ecordell/optgen -output zz_generated.options.go . Config type Config struct { - GRPCServer util.GRPCServerConfig `debugmap:"visible"` - ReadOnlyGRPCServer util.GRPCServerConfig `debugmap:"visible"` - HTTPGateway util.HTTPServerConfig `debugmap:"visible"` - ReadOnlyHTTPGateway util.HTTPServerConfig `debugmap:"visible"` - LoadConfigs []string `debugmap:"visible"` - MaximumUpdatesPerWrite uint16 `debugmap:"visible"` - MaximumPreconditionCount uint16 `debugmap:"visible"` - MaxCaveatContextSize int `debugmap:"visible"` - MaxRelationshipContextSize int `debugmap:"visible"` - MaxReadRelationshipsLimit uint32 `debugmap:"visible"` - MaxDeleteRelationshipsLimit uint32 `debugmap:"visible"` - MaxLookupResourcesLimit uint32 `debugmap:"visible"` - MaxBulkExportRelationshipsLimit uint32 `debugmap:"visible"` + GRPCServer util.GRPCServerConfig `debugmap:"visible"` + ReadOnlyGRPCServer util.GRPCServerConfig `debugmap:"visible"` + HTTPGateway util.HTTPServerConfig `debugmap:"visible"` + ReadOnlyHTTPGateway util.HTTPServerConfig `debugmap:"visible"` + LoadConfigs []string `debugmap:"visible"` + MaximumUpdatesPerWrite uint16 `debugmap:"visible"` + MaximumPreconditionCount uint16 `debugmap:"visible"` + MaxCaveatContextSize int `debugmap:"visible"` + MaxRelationshipContextSize int `debugmap:"visible"` + MaxReadRelationshipsLimit uint32 `debugmap:"visible"` + MaxDeleteRelationshipsLimit uint32 `debugmap:"visible"` + MaxLookupResourcesLimit uint32 `debugmap:"visible"` + MaxBulkExportRelationshipsLimit uint32 `debugmap:"visible"` + EnableExperimentalLookupResources bool `debugmap:"visible"` } type RunnableTestServer interface { @@ -60,6 +62,7 @@ func (dr datastoreReady) ReadyState(_ context.Context) (datastore.ReadyState, er } func (c *Config) Complete() (RunnableTestServer, error) { + log.Info().Fields(helpers.Flatten(c.DebugMap())).Msg("configuration") dispatcher := graph.NewLocalOnlyDispatcher(defaultConcurrencyLimit, defaultMaxChunkSize) datastoreMiddleware := pertoken.NewMiddleware(c.LoadConfigs) @@ -83,6 +86,7 @@ func (c *Config) Complete() (RunnableTestServer, error) { MaxLookupResourcesLimit: c.MaxLookupResourcesLimit, MaxBulkExportRelationshipsLimit: c.MaxBulkExportRelationshipsLimit, DispatchChunkSize: defaultMaxChunkSize, + UseExperimentalLookupResources2: c.EnableExperimentalLookupResources, }, 1*time.Second, ) diff --git a/pkg/cmd/testserver/zz_generated.options.go b/pkg/cmd/testserver/zz_generated.options.go index 594bfec734..4750c771e1 100644 --- a/pkg/cmd/testserver/zz_generated.options.go +++ b/pkg/cmd/testserver/zz_generated.options.go @@ -44,6 +44,7 @@ func (c *Config) ToOption() ConfigOption { to.MaxDeleteRelationshipsLimit = c.MaxDeleteRelationshipsLimit to.MaxLookupResourcesLimit = c.MaxLookupResourcesLimit to.MaxBulkExportRelationshipsLimit = c.MaxBulkExportRelationshipsLimit + to.EnableExperimentalLookupResources = c.EnableExperimentalLookupResources } } @@ -63,6 +64,7 @@ func (c Config) DebugMap() map[string]any { debugMap["MaxDeleteRelationshipsLimit"] = helpers.DebugValue(c.MaxDeleteRelationshipsLimit, false) debugMap["MaxLookupResourcesLimit"] = helpers.DebugValue(c.MaxLookupResourcesLimit, false) debugMap["MaxBulkExportRelationshipsLimit"] = helpers.DebugValue(c.MaxBulkExportRelationshipsLimit, false) + debugMap["EnableExperimentalLookupResources"] = helpers.DebugValue(c.EnableExperimentalLookupResources, false) return debugMap } @@ -179,3 +181,10 @@ func WithMaxBulkExportRelationshipsLimit(maxBulkExportRelationshipsLimit uint32) c.MaxBulkExportRelationshipsLimit = maxBulkExportRelationshipsLimit } } + +// WithEnableExperimentalLookupResources returns an option that can set EnableExperimentalLookupResources on a Config +func WithEnableExperimentalLookupResources(enableExperimentalLookupResources bool) ConfigOption { + return func(c *Config) { + c.EnableExperimentalLookupResources = enableExperimentalLookupResources + } +}