EPH WebSocket Support (#153)
* updates * updates * updates * Update version.go
This commit is contained in:
Родитель
7a1b2e2089
Коммит
403470e620
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## `head`
|
## `head`
|
||||||
|
|
||||||
|
- add support for websocket connections with eph with `eph.WithWebSocketConnection()`
|
||||||
|
|
||||||
## `v2.0.4`
|
## `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)
|
- 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
|
handlersMu sync.Mutex
|
||||||
partitionIDs []string
|
partitionIDs []string
|
||||||
noBanner bool
|
noBanner bool
|
||||||
|
webSocketConnection bool
|
||||||
env *azure.Environment
|
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
|
// NewFromConnectionString builds a new Event Processor Host from an Event Hub connection string which can be found in
|
||||||
// the Azure portal
|
// the Azure portal
|
||||||
func NewFromConnectionString(ctx context.Context, connStr string, leaser Leaser, checkpointer Checkpointer, opts ...EventProcessorHostOption) (*EventProcessorHost, error) {
|
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))
|
hubOpts = append(hubOpts, eventhub.HubWithEnvironment(*host.env))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if host.webSocketConnection {
|
||||||
|
hubOpts = append(hubOpts, eventhub.HubWithWebSocketConnection())
|
||||||
|
}
|
||||||
|
|
||||||
client, err := eventhub.NewHubFromConnectionString(connStr, hubOpts...)
|
client, err := eventhub.NewHubFromConnectionString(connStr, hubOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tab.For(ctx).Error(err)
|
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))
|
hubOpts = append(hubOpts, eventhub.HubWithEnvironment(*host.env))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if host.webSocketConnection {
|
||||||
|
hubOpts = append(hubOpts, eventhub.HubWithWebSocketConnection())
|
||||||
|
}
|
||||||
|
|
||||||
client, err := eventhub.NewHub(namespace, hubName, tokenProvider, hubOpts...)
|
client, err := eventhub.NewHub(namespace, hubName, tokenProvider, hubOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -2,5 +2,5 @@ package eventhub
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Version is the semantic version number
|
// Version is the semantic version number
|
||||||
Version = "3.0.0"
|
Version = "3.1.0"
|
||||||
)
|
)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче