Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(subscription): mutex free subscription implementation #1613

Merged
merged 5 commits into from
Feb 20, 2025
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
2 changes: 1 addition & 1 deletion demo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/wundergraph/cosmo/composition-go v0.0.0-20240124120900-5effe48a4a1d
github.com/wundergraph/cosmo/router v0.0.0-20250218093943-e5b2167f65c7
github.com/wundergraph/cosmo/router-tests v0.0.0-20250218093943-e5b2167f65c7
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.155
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.157
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.23.1
Expand Down
6 changes: 3 additions & 3 deletions demo/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@ github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083 h1:8/D7f8gKxTB
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/cosmo/composition-go v0.0.0-20240124120900-5effe48a4a1d h1:NEUrhuqOaTO1dpW8pz2tu6dKbQAqFvgiF/m4NXdzZm0=
github.com/wundergraph/cosmo/composition-go v0.0.0-20240124120900-5effe48a4a1d/go.mod h1:9I3gPMAlAY+m1/cFL20iN7XHTyuZd3VT5ijccdU/FsI=
github.com/wundergraph/cosmo/router v0.0.0-20250218093943-e5b2167f65c7 h1:+kwYDe0/Tm10VTTAgGFXoeVHCnQVwPuKsHijtZKMD4Q=
github.com/wundergraph/cosmo/router v0.0.0-20250218093943-e5b2167f65c7/go.mod h1:fegv/vONTxD6SRweTJyQSBALVvyst1zI6DOhPj1vJsQ=
github.com/wundergraph/cosmo/router-tests v0.0.0-20250218093943-e5b2167f65c7 h1:xWDcFs4dCLKgu6ZxW8ADeywL5B8vSLLdZEM8htitzDY=
github.com/wundergraph/cosmo/router-tests v0.0.0-20250218093943-e5b2167f65c7/go.mod h1:M9w5UOrQkB86E4ZYoLFhvl+04U83B4zm5r2TFtobHxc=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.155 h1:+ygDhCfLCwDE1aL+2wjtU0PfrMJ9f9ZLb0Lm0w5W7Is=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.155/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.156 h1:OFc0aBKNYav0uZb72WjLNkHaE/onc+joeSTxCnZKdlI=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.156/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.157/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
Expand Down
4 changes: 2 additions & 2 deletions router-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/twmb/franz-go/pkg/kadm v1.11.0
github.com/wundergraph/cosmo/demo v0.0.0-20250218124445-6709220e2efe
github.com/wundergraph/cosmo/router v0.0.0-20250218124445-6709220e2efe
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.156
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.157
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/sdk v1.28.0
go.opentelemetry.io/otel/sdk/metric v1.28.0
Expand Down Expand Up @@ -178,7 +178,7 @@ require (
replace (
github.com/wundergraph/cosmo/demo => ../demo
github.com/wundergraph/cosmo/router => ../router
// github.com/wundergraph/graphql-go-tools/v2 => ../../graphql-go-tools/v2
// github.com/wundergraph/graphql-go-tools/v2 => ../../graphql-go-tools/v2
)

replace github.com/hashicorp/consul/sdk => github.com/wundergraph/consul/sdk v0.0.0-20250204115147-ed842a8fd301
4 changes: 2 additions & 2 deletions router-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083 h1:8/D7f8gKxTB
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/consul/sdk v0.0.0-20250204115147-ed842a8fd301 h1:EzfKHQoTjFDDcgaECCCR2aTePqMu9QBmPbyhqIYOhV0=
github.com/wundergraph/consul/sdk v0.0.0-20250204115147-ed842a8fd301/go.mod h1:wxI0Nak5dI5RvJuzGyiEK4nZj0O9X+Aw6U0tC1wPKq0=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.156 h1:OFc0aBKNYav0uZb72WjLNkHaE/onc+joeSTxCnZKdlI=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.156/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.157 h1:2Fc99E76AKChyJke2FyJYcRJyaTaChr9wnSeybia/FY=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.157/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
Expand Down
1 change: 1 addition & 0 deletions router/core/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (b *ExecutorConfigurationBuilder) Build(ctx context.Context, opts *Executor
AllowedSubgraphErrorFields: opts.RouterEngineConfig.SubgraphErrorPropagation.AllowedFields,
MaxRecyclableParserSize: opts.RouterEngineConfig.Execution.ResolverMaxRecyclableParserSize,
MultipartSubHeartbeatInterval: opts.HeartbeatInterval,
MaxSubscriptionFetchTimeout: opts.RouterEngineConfig.Execution.SubscriptionFetchTimeout,
}

if opts.ApolloCompatibilityFlags.ValueCompletion.Enabled {
Expand Down
2 changes: 1 addition & 1 deletion router/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/tidwall/gjson v1.18.0
github.com/tidwall/sjson v1.2.5
github.com/twmb/franz-go v1.16.1
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.156
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.157
// Do not upgrade, it renames attributes we rely on
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
go.opentelemetry.io/contrib/propagators/b3 v1.23.0
Expand Down
4 changes: 2 additions & 2 deletions router/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0
github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083 h1:8/D7f8gKxTBjW+SZK4mhxTTBVpxcqeBgWF1Rfmltbfk=
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.156 h1:OFc0aBKNYav0uZb72WjLNkHaE/onc+joeSTxCnZKdlI=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.156/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.157 h1:2Fc99E76AKChyJke2FyJYcRJyaTaChr9wnSeybia/FY=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.157/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
Expand Down
1 change: 1 addition & 0 deletions router/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ type EngineExecutionConfiguration struct {
ResolverMaxRecyclableParserSize int `envDefault:"32768" env:"ENGINE_RESOLVER_MAX_RECYCLABLE_PARSER_SIZE" yaml:"resolver_max_recyclable_parser_size,omitempty"`
EnableSubgraphFetchOperationName bool `envDefault:"false" env:"ENGINE_ENABLE_SUBGRAPH_FETCH_OPERATION_NAME" yaml:"enable_subgraph_fetch_operation_name"`
DisableVariablesRemapping bool `envDefault:"false" env:"ENGINE_DISABLE_VARIABLES_REMAPPING" yaml:"disable_variables_remapping"`
SubscriptionFetchTimeout time.Duration `envDefault:"30s" env:"ENGINE_SUBSCRIPTION_FETCH_TIMEOUT" yaml:"subscription_fetch_timeout,omitempty"`
}

type BlockOperationConfiguration struct {
Expand Down
6 changes: 6 additions & 0 deletions router/pkg/config/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2257,6 +2257,12 @@
"type": "boolean",
"default": false,
"description": "Disables variables renaming during normalization. This option could have a negative impact on planner cache hits."
},
"subscription_fetch_timeout": {
"type": "string",
"format": "go-duration",
"default": "30s",
"description": "The maximum time a subscription fetch can take before it is considered timed out. The period is specified as a string with a number and a unit, e.g. 10ms, 1s, 1m, 1h. The supported units are 'ms', 's', 'm', 'h'."
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion router/pkg/config/testdata/config_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@
"ValidationCacheSize": 1024,
"ResolverMaxRecyclableParserSize": 32768,
"EnableSubgraphFetchOperationName": false,
"DisableVariablesRemapping": false
"DisableVariablesRemapping": false,
"SubscriptionFetchTimeout": 30000000000
},
"WebSocket": {
"Enabled": true,
Expand Down
3 changes: 2 additions & 1 deletion router/pkg/config/testdata/config_full.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@
"ValidationCacheSize": 1024,
"ResolverMaxRecyclableParserSize": 4096,
"EnableSubgraphFetchOperationName": true,
"DisableVariablesRemapping": false
"DisableVariablesRemapping": false,
"SubscriptionFetchTimeout": 30000000000
},
"WebSocket": {
"Enabled": true,
Expand Down
Loading