Skip to content

Commit

Permalink
add experimental LR2 flag to test-serve command
Browse files Browse the repository at this point in the history
  • Loading branch information
vroldanbet committed Jul 31, 2024
1 parent 639b959 commit 7aabbfe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
30 changes: 17 additions & 13 deletions pkg/cmd/testserver/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -83,6 +86,7 @@ func (c *Config) Complete() (RunnableTestServer, error) {
MaxLookupResourcesLimit: c.MaxLookupResourcesLimit,
MaxBulkExportRelationshipsLimit: c.MaxBulkExportRelationshipsLimit,
DispatchChunkSize: defaultMaxChunkSize,
UseExperimentalLookupResources2: c.EnableExperimentalLookupResources,
},
1*time.Second,
)
Expand Down
9 changes: 9 additions & 0 deletions pkg/cmd/testserver/zz_generated.options.go

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

0 comments on commit 7aabbfe

Please sign in to comment.