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

Add default_route_behaviour setting #145

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/config/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ type Router struct {
}

type QRouter struct {
MulticastUnroutableInsertStatement bool `json:"multicast_unroutable_insert_statement" toml:"multicast_unroutable_insert_statement" yaml:"multicast_unroutable_insert_statement"`
MulticastUnroutableInsertStatement bool `json:"multicast_unroutable_insert_statement" toml:"multicast_unroutable_insert_statement" yaml:"multicast_unroutable_insert_statement"`
DefaultRouteBehaviour string `json:"default_route_behaviour" toml:"default_route_behaviour" yaml:"default_route_behaviour"`
}

type BackendRule struct {
Expand Down
7 changes: 6 additions & 1 deletion router/pkg/qrouter/proxy_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,12 @@ func (qr *ProxyQrouter) Route(ctx context.Context, parsedStmt *pgquery.ParseResu
}

if route == nil {
return MultiMatchState{}, nil
switch qr.cfg.DefaultRouteBehaviour {
case "BLOCK":
return SkipRoutingState{}, fmt.Errorf("failed to match query to any sharding rule")
default:
return MultiMatchState{}, nil
}
}

spqrlog.Logger.Printf(spqrlog.DEBUG1, "parsed shard route %+v", route)
Expand Down
Loading