Skip to content

Commit

Permalink
Remove termination policy (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa authored Feb 29, 2024
1 parent fbf1ca8 commit 00db220
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 214 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ jobs:
export SHA256SUM=$(sha256sum ptg | awk '{print $1}')
cat <<EOF > gatewayd_plugins.yaml
compatibilityPolicy: "strict"
terminationPolicy: "stop"
metricsMergerPeriod: 1s
healthCheckPeriod: 1s
reloadOnCrash: true
Expand Down
3 changes: 0 additions & 3 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func TestGetPlugins(t *testing.T) {
context.TODO(),
actRegistry,
config.Loose,
config.Stop,
zerolog.Logger{},
true,
)
Expand Down Expand Up @@ -143,7 +142,6 @@ func TestGetPluginsWithEmptyPluginRegistry(t *testing.T) {
context.TODO(),
actRegistry,
config.Loose,
config.Stop,
zerolog.Logger{},
true,
)
Expand Down Expand Up @@ -253,7 +251,6 @@ func TestGetServers(t *testing.T) {
context.TODO(),
actRegistry,
config.Loose,
config.Stop,
zerolog.Logger{},
true,
)
Expand Down
328 changes: 163 additions & 165 deletions api/v1/api.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/v1/api.proto

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

1 change: 0 additions & 1 deletion api/v1/api.swagger.json

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

5 changes: 0 additions & 5 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,6 @@ var runCmd = &cobra.Command{
config.CompatibilityPolicies, conf.Plugin.CompatibilityPolicy),
config.CompatibilityPolicies[conf.Plugin.CompatibilityPolicy],
config.DefaultCompatibilityPolicy),
config.If[config.TerminationPolicy](
config.Exists[string, config.TerminationPolicy](
config.TerminationPolicies, conf.Plugin.TerminationPolicy),
config.TerminationPolicies[conf.Plugin.TerminationPolicy],
config.DefaultTerminationPolicy),
logger,
devMode,
)
Expand Down
1 change: 0 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func (c *Config) LoadDefaults(ctx context.Context) {

c.pluginDefaults = PluginConfig{
CompatibilityPolicy: string(Strict),
TerminationPolicy: string(Stop),
EnableMetricsMerger: true,
MetricsMergerPeriod: DefaultMetricsMergerPeriod,
HealthCheckPeriod: DefaultPluginHealthCheckPeriod,
Expand Down
9 changes: 0 additions & 9 deletions config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
type (
Status uint
CompatibilityPolicy string
TerminationPolicy string
LogOutput uint
)

Expand All @@ -23,13 +22,6 @@ const (
Loose CompatibilityPolicy = "loose" // Load the plugin, even if the requirements are not met
)

// TerminationPolicy is the termination policy for
// the functions registered to the OnTrafficFromClient hook.
const (
Continue TerminationPolicy = "continue" // Continue to the next function
Stop TerminationPolicy = "stop" // Stop the execution of the functions
)

// LogOutput is the output type for the logger.
const (
Console LogOutput = iota
Expand Down Expand Up @@ -129,7 +121,6 @@ const (

// Policies.
DefaultCompatibilityPolicy = Strict
DefaultTerminationPolicy = Stop

// Act.
DefaultPolicy = "passthrough"
Expand Down
4 changes: 0 additions & 4 deletions config/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ var (
"strict": Strict,
"loose": Loose,
}
TerminationPolicies = map[string]TerminationPolicy{
"continue": Continue,
"stop": Stop,
}
logOutputs = map[string]LogOutput{
"console": Console,
"stdout": Stdout,
Expand Down
1 change: 0 additions & 1 deletion config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type Policy struct {

type PluginConfig struct {
CompatibilityPolicy string `json:"compatibilityPolicy" jsonschema:"enum=strict,enum=loose"`
TerminationPolicy string `json:"terminationPolicy" jsonschema:"enum=continue,enum=stop"`
EnableMetricsMerger bool `json:"enableMetricsMerger"`
MetricsMergerPeriod time.Duration `json:"metricsMergerPeriod" jsonschema:"oneof_type=string;integer"`
HealthCheckPeriod time.Duration `json:"healthCheckPeriod" jsonschema:"oneof_type=string;integer"`
Expand Down
11 changes: 0 additions & 11 deletions gatewayd_plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@
# plugin and that version is not the one currently loaded.
compatibilityPolicy: "strict"

# The termination policy controls how to handle the termination of requests. If a plugin
# terminates a request, the termination policy controls whether to stop executing the
# remaining plugins or not. If the termination policy is set to "stop", the remaining plugins
# are not executed. If the termination policy is set to "continue", the remaining plugins are
# executed. Warning: if the termination policy is set to "continue", the output of the
# remaining plugins might be passed down to the next plugin, and the result depends on the
# what the remaining plugins do.
# - "stop" (default): the remaining plugins are not executed.
# - "continue": the remaining plugins are executed.
terminationPolicy: "stop"

# The metrics policy controls whether to collect and merge metrics from plugins or not.
# The Prometheus metrics are collected from the plugins via a Unix domain socket. The metrics
# are merged and exposed via the GatewayD metrics endpoint via HTTP.
Expand Down
6 changes: 0 additions & 6 deletions network/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func TestNewProxy(t *testing.T) {
context.Background(),
actRegistry,
config.Loose,
config.Stop,
logger,
false,
),
Expand Down Expand Up @@ -105,7 +104,6 @@ func BenchmarkNewProxy(b *testing.B) {
context.Background(),
actRegistry,
config.Loose,
config.Stop,
logger,
false,
),
Expand Down Expand Up @@ -154,7 +152,6 @@ func BenchmarkProxyConnectDisconnect(b *testing.B) {
context.Background(),
actRegistry,
config.Loose,
config.Stop,
logger,
false,
),
Expand Down Expand Up @@ -210,7 +207,6 @@ func BenchmarkProxyPassThrough(b *testing.B) {
context.Background(),
actRegistry,
config.Loose,
config.Stop,
logger,
false,
),
Expand Down Expand Up @@ -271,7 +267,6 @@ func BenchmarkProxyIsHealthyAndIsExhausted(b *testing.B) {
context.Background(),
actRegistry,
config.Loose,
config.Stop,
logger,
false,
),
Expand Down Expand Up @@ -330,7 +325,6 @@ func BenchmarkProxyAvailableAndBusyConnections(b *testing.B) {
context.Background(),
actRegistry,
config.Loose,
config.Stop,
logger,
false,
),
Expand Down
1 change: 0 additions & 1 deletion network/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func TestRunServer(t *testing.T) {
context.Background(),
actRegistry,
config.Loose,
config.Stop,
logger,
false,
)
Expand Down
3 changes: 0 additions & 3 deletions plugin/plugin_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ type Registry struct {

Logger zerolog.Logger
Compatibility config.CompatibilityPolicy
Termination config.TerminationPolicy
StartTimeout time.Duration
}

Expand All @@ -76,7 +75,6 @@ func NewRegistry(
ctx context.Context,
policiesRegistry *act.Registry,
compatibility config.CompatibilityPolicy,
termination config.TerminationPolicy,
logger zerolog.Logger,
devMode bool,
) *Registry {
Expand All @@ -91,7 +89,6 @@ func NewRegistry(
devMode: devMode,
Logger: logger,
Compatibility: compatibility,
Termination: termination,
}
}

Expand Down
2 changes: 0 additions & 2 deletions plugin/plugin_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func NewPluginRegistry(t *testing.T) *Registry {
context.Background(),
actRegistry,
config.Loose,
config.Stop,
logger,
false,
)
Expand Down Expand Up @@ -136,7 +135,6 @@ func BenchmarkHookRun(b *testing.B) {
context.Background(),
actRegistry,
config.Loose,
config.Stop,
logger,
false,
)
Expand Down

0 comments on commit 00db220

Please sign in to comment.