Skip to content

Commit

Permalink
Hot Reload: Subscription (dapr#7583)
Browse files Browse the repository at this point in the history
* Hot Reload: Subscription

Adds support for Subscription Hot Reloading.

If the Hot Reloading preview feature is enabled, create, update and
delete events to declarative Subscriptions will be reflected in the
Subscriptions runtime without needing to restart the Dapr runtime. Works
in both self-hosted and Kubernetes modes.

Note that, because topic routes and not indexed by Subscription
resources, all Subscriptions will be cancelled and topic routes re-built
and re-subscribed when a Subscription event occurs. A possible
improvement would to only cancel all topic route subscriptions which are
related to the Subscription pubsub or include an index of the
Subscription which a topic is routed for, however this is out of scope
of this change. Support for per topic route cancellation will be needed
for on-demand bi-directional subscriptions.

In-flight messages are not effected by Subscription hot reloading.

Branched from dapr#7582

Closes dapr#7139

Signed-off-by: joshvanl <[email protected]>

* Load all Subscriptions before reloading on boot

Signed-off-by: joshvanl <[email protected]>

* Adds unit tests for subscription client side scope filtering

Signed-off-by: joshvanl <[email protected]>

* Linting

Signed-off-by: joshvanl <[email protected]>

---------

Signed-off-by: joshvanl <[email protected]>
Co-authored-by: Dapr Bot <[email protected]>
  • Loading branch information
JoshVanL and dapr-bot authored Apr 18, 2024
1 parent fa211af commit 6ef8029
Show file tree
Hide file tree
Showing 80 changed files with 4,500 additions and 1,470 deletions.
17 changes: 17 additions & 0 deletions dapr/proto/operator/v1/operator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ service Operator {
rpc ListResiliency (ListResiliencyRequest) returns (ListResiliencyResponse) {}
// Returns a list of pub/sub subscriptions, ListSubscriptionsRequest to expose pod info
rpc ListSubscriptionsV2 (ListSubscriptionsRequest) returns (ListSubscriptionsResponse) {}
// Sends events to Dapr sidecars upon subscription changes.
rpc SubscriptionUpdate (SubscriptionUpdateRequest) returns (stream SubscriptionUpdateEvent) {}
// Returns a list of http endpoints
rpc ListHTTPEndpoints (ListHTTPEndpointsRequest) returns (ListHTTPEndpointsResponse) {}
// Sends events to Dapr sidecars upon http endpoint changes.
Expand Down Expand Up @@ -97,6 +99,21 @@ message ListSubscriptionsResponse {
repeated bytes subscriptions = 1;
}

// SubscriptionUpdateRequest is the request to get updates about new
// subscriptions for a given namespace.
message SubscriptionUpdateRequest {
string namespace = 1;
string podName = 2;
}

// SubscriptionUpdateEvent includes the updated subscription event.
message SubscriptionUpdateEvent {
bytes subscription = 1;

// type is the type of event.
ResourceEventType type = 2;
}

// GetResiliencyRequest is the request to get a resiliency configuration.
message GetResiliencyRequest {
string name = 1;
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1
github.com/cloudevents/sdk-go/v2 v2.14.0
github.com/dapr/components-contrib v1.13.0-rc.10
github.com/dapr/kit v0.13.0
github.com/dapr/kit v0.13.1-0.20240402103809-0c7cfce53d9e
github.com/evanphx/json-patch/v5 v5.8.1
github.com/go-chi/chi/v5 v5.0.11
github.com/go-chi/cors v1.2.1
Expand All @@ -36,7 +36,7 @@ require (
github.com/jackc/pgx/v5 v5.5.2
github.com/jhump/protoreflect v1.15.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/lestrrat-go/jwx/v2 v2.0.19
github.com/lestrrat-go/jwx/v2 v2.0.20
github.com/microsoft/durabletask-go v0.4.1-0.20240122160106-fb5c4c05729d
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuA
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
github.com/dapr/components-contrib v1.13.0-rc.10 h1:d5xGjRAl2Gm23YsMfwa7Lwz5FFCb1ad4UqCmHTmtyV4=
github.com/dapr/components-contrib v1.13.0-rc.10/go.mod h1:CFCvUwS2ClqTVyzfqHEGiXM3gftWOjOI73pxECoY/Iw=
github.com/dapr/kit v0.13.0 h1:4S+5QqDCreva+MBONtIgxeg6B2b1W89bB8F5lqKgTa0=
github.com/dapr/kit v0.13.0/go.mod h1:VyHrelNXPbtS/VcQX0Y/uzW0lfEVuveJ+1E5bDys8mo=
github.com/dapr/kit v0.13.1-0.20240402103809-0c7cfce53d9e h1:mLvqfGuppb6uhsijmwTlF5sZVtGvig+Ua5ESKF17SxA=
github.com/dapr/kit v0.13.1-0.20240402103809-0c7cfce53d9e/go.mod h1:dons8V2bF6MPR2yFdxtTa86PfaE7EJtKAOkZ9hOavBQ=
github.com/dave/jennifer v1.4.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -1096,8 +1096,8 @@ github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbq
github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI=
github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4=
github.com/lestrrat-go/jwx v1.2.24/go.mod h1:zoNuZymNl5lgdcu6P7K6ie2QRll5HVfF4xwxBBK1NxY=
github.com/lestrrat-go/jwx/v2 v2.0.19 h1:ekv1qEZE6BVct89QA+pRF6+4pCpfVrOnEJnTnT4RXoY=
github.com/lestrrat-go/jwx/v2 v2.0.19/go.mod h1:l3im3coce1lL2cDeAjqmaR+Awx+X8Ih+2k8BuHNJ4CU=
github.com/lestrrat-go/jwx/v2 v2.0.20 h1:sAgXuWS/t8ykxS9Bi2Qtn5Qhpakw1wrcjxChudjolCc=
github.com/lestrrat-go/jwx/v2 v2.0.20/go.mod h1:UlCSmKqw+agm5BsOBfEAbTvKsEApaGNqHAEUTv5PJC4=
github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU=
github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
Expand Down
Loading

0 comments on commit 6ef8029

Please sign in to comment.