EPH WebSocket Support (#153)
* updates * updates * updates * Update version.go
This commit is contained in:
Родитель
7a1b2e2089
Коммит
403470e620
|
@ -2,6 +2,8 @@
|
|||
|
||||
## `head`
|
||||
|
||||
- add support for websocket connections with eph with `eph.WithWebSocketConnection()`
|
||||
|
||||
## `v2.0.4`
|
||||
- add comment on the `PartitionID` field in `SystemProperties` to clarify that it will always return a nil value [#131](https://github.com/Azure/azure-event-hubs-go/issues/131)
|
||||
|
||||
|
|
17
eph/eph.go
17
eph/eph.go
|
@ -74,6 +74,7 @@ type (
|
|||
handlersMu sync.Mutex
|
||||
partitionIDs []string
|
||||
noBanner bool
|
||||
webSocketConnection bool
|
||||
env *azure.Environment
|
||||
}
|
||||
|
||||
|
@ -117,6 +118,14 @@ func WithEnvironment(env azure.Environment) EventProcessorHostOption {
|
|||
}
|
||||
}
|
||||
|
||||
// WithWebSocketConnection will configure an EventProcessorHost to use websockets
|
||||
func WithWebSocketConnection() EventProcessorHostOption {
|
||||
return func(host *EventProcessorHost) error {
|
||||
host.webSocketConnection = true
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewFromConnectionString builds a new Event Processor Host from an Event Hub connection string which can be found in
|
||||
// the Azure portal
|
||||
func NewFromConnectionString(ctx context.Context, connStr string, leaser Leaser, checkpointer Checkpointer, opts ...EventProcessorHostOption) (*EventProcessorHost, error) {
|
||||
|
@ -165,6 +174,10 @@ func NewFromConnectionString(ctx context.Context, connStr string, leaser Leaser,
|
|||
hubOpts = append(hubOpts, eventhub.HubWithEnvironment(*host.env))
|
||||
}
|
||||
|
||||
if host.webSocketConnection {
|
||||
hubOpts = append(hubOpts, eventhub.HubWithWebSocketConnection())
|
||||
}
|
||||
|
||||
client, err := eventhub.NewHubFromConnectionString(connStr, hubOpts...)
|
||||
if err != nil {
|
||||
tab.For(ctx).Error(err)
|
||||
|
@ -217,6 +230,10 @@ func New(ctx context.Context, namespace, hubName string, tokenProvider auth.Toke
|
|||
hubOpts = append(hubOpts, eventhub.HubWithEnvironment(*host.env))
|
||||
}
|
||||
|
||||
if host.webSocketConnection {
|
||||
hubOpts = append(hubOpts, eventhub.HubWithWebSocketConnection())
|
||||
}
|
||||
|
||||
client, err := eventhub.NewHub(namespace, hubName, tokenProvider, hubOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -2,5 +2,5 @@ package eventhub
|
|||
|
||||
const (
|
||||
// Version is the semantic version number
|
||||
Version = "3.0.0"
|
||||
Version = "3.1.0"
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче