-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Subscriptions: bi-directional subscription streaming. (dapr#7747)
* Subscriptions: bi-directional subscription & publish streaming. Adds SubscribeTopicEvents proto API which dynamically subscribes to pubsub topics based on dapr/proposals#52. This is a basic gRPC implementation of the API whereby, like Subscription hot-reloading today, subscribing to a topic will reload _every_ active subscription for the current daprd. In a future PR, reloading of Subscriptions will be granular to the specific pubsub topic. Stream subscriptions are also only active once daprd declares the application as both present and ready. Dynamic stream subscriptions should be active both whether a app is running or not, as well as whether it is ready or not. This will be addressed in a future PR. Signed-off-by: joshvanl <[email protected]> * Updates go.mod go version to 1.22.3 in e2e apps Signed-off-by: joshvanl <[email protected]> * Remove small context timeout on httpserver int tests Signed-off-by: joshvanl <[email protected]> * Wait for daprd2 to be ready before calling meta endpoint in hot-op-inf-comp test Signed-off-by: joshvanl <[email protected]> * Increase int test daprd wait until ready timeout to 30s Signed-off-by: joshvanl <[email protected]> * Assert httpendpoint int test resp body with eventually Signed-off-by: joshvanl <[email protected]> * Set subscription APIs Alpha1 Signed-off-by: joshvanl <[email protected]> --------- Signed-off-by: joshvanl <[email protected]> Co-authored-by: Yaron Schneider <[email protected]>
- Loading branch information
Showing
32 changed files
with
3,977 additions
and
2,150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/dapr/dapr | ||
|
||
go 1.22.2 | ||
go 1.22.3 | ||
|
||
require ( | ||
contrib.go.opencensus.io/exporter/prometheus v0.4.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Copyright 2023 The Dapr Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package grpc | ||
|
||
import ( | ||
runtimev1pb "github.com/dapr/dapr/pkg/proto/runtime/v1" | ||
) | ||
|
||
// SubscribeTopicEvents is called by the Dapr runtime to ad hoc stream | ||
// subscribe to topics. If gRPC API server closes, returns func early with nil | ||
// to close stream. | ||
func (a *api) SubscribeTopicEventsAlpha1(stream runtimev1pb.Dapr_SubscribeTopicEventsAlpha1Server) error { | ||
errCh := make(chan error, 2) | ||
subDone := make(chan struct{}) | ||
a.wg.Add(2) | ||
go func() { | ||
errCh <- a.processor.PubSub().Streamer().Subscribe(stream) | ||
close(subDone) | ||
a.wg.Done() | ||
}() | ||
go func() { | ||
select { | ||
case <-a.closeCh: | ||
case <-subDone: | ||
} | ||
errCh <- nil | ||
a.wg.Done() | ||
}() | ||
|
||
return <-errCh | ||
} |
Oops, something went wrong.