Skip to content

Commit d3f3d3a

Browse files
[azeventhubs] Stress tests and a fix to the checkpoint store for loading/storing offsets (Azure#19056)
Rounding the corner on items for the release: - First migration guide created. Tries to stick to our principle of limited to no inline snippets, and lean on example files more. - Fixed a bug where the CheckpointStore wasn't using the stored offset, which is the "faster" of the two seek methods. * Adding in the first suite of stress tests.
1 parent efd2925 commit d3f3d3a

28 files changed

+1132
-210
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
# PRLabel: %Service Bus
4444
/sdk/messaging/azservicebus @richardpark-msft @jhendrixMSFT
4545

46+
# PRLabel: %Event Hubs
47+
/sdk/messaging/azeventhubs @richardpark-msft @jhendrixMSFT
48+
4649
# PRLabel: %Service Bus
4750
/sdk/messaging/internal @richardpark-msft @jhendrixMSFT
4851

sdk/messaging/azeventhubs/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release History
22

3-
## 0.1.1 (2022-09-07)
3+
## 0.1.1 (2022-09-08)
44

55
### Features Added
66

sdk/messaging/azeventhubs/checkpoint_store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ type CheckpointStoreAddress struct {
5656
// CheckpointData tracks latest offset and sequence number that have been
5757
// processed by the client.
5858
type CheckpointData struct {
59-
Offset int64
60-
SequenceNumber int64
59+
Offset *int64
60+
SequenceNumber *int64
6161
}
6262

6363
// ListCheckpointsOptions contains optional parameters for the ListCheckpoints function

sdk/messaging/azeventhubs/checkpoints/blob_store.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,23 @@ func newCheckpointData(metadata map[string]*string) (azeventhubs.CheckpointData,
338338
}
339339

340340
return azeventhubs.CheckpointData{
341-
Offset: offset,
342-
SequenceNumber: sequenceNumber,
341+
Offset: &offset,
342+
SequenceNumber: &sequenceNumber,
343343
}, nil
344344
}
345345

346346
func newCheckpointBlobMetadata(cpd azeventhubs.CheckpointData) map[string]string {
347-
return map[string]string{
348-
"sequencenumber": strconv.FormatInt(cpd.SequenceNumber, 10),
349-
"offset": strconv.FormatInt(cpd.Offset, 10),
347+
m := map[string]string{}
348+
349+
if cpd.SequenceNumber != nil {
350+
m["sequencenumber"] = strconv.FormatInt(*cpd.SequenceNumber, 10)
350351
}
352+
353+
if cpd.Offset != nil {
354+
m["offset"] = strconv.FormatInt(*cpd.Offset, 10)
355+
}
356+
357+
return m
351358
}
352359

353360
func newOwnershipData(b *blob.BlobItemInternal) (azeventhubs.OwnershipData, error) {

sdk/messaging/azeventhubs/checkpoints/blob_store_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010
"time"
1111

12+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
1213
"github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs"
1314
"github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/checkpoints"
1415
"github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/internal/blob"
@@ -35,8 +36,8 @@ func TestBlobStore_Checkpoints(t *testing.T) {
3536
PartitionID: "partition-id",
3637
},
3738
CheckpointData: azeventhubs.CheckpointData{
38-
Offset: 101,
39-
SequenceNumber: 202,
39+
Offset: to.Ptr[int64](101),
40+
SequenceNumber: to.Ptr[int64](202),
4041
},
4142
}, nil)
4243
require.NoError(t, err)
@@ -52,8 +53,8 @@ func TestBlobStore_Checkpoints(t *testing.T) {
5253
PartitionID: "partition-id",
5354
},
5455
CheckpointData: azeventhubs.CheckpointData{
55-
Offset: 101,
56-
SequenceNumber: 202,
56+
Offset: to.Ptr[int64](101),
57+
SequenceNumber: to.Ptr[int64](202),
5758
},
5859
}, checkpoints[0])
5960
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build go1.16
2+
// +build go1.16
3+
4+
// Copyright (c) Microsoft Corporation. All rights reserved.
5+
// Licensed under the MIT License.
6+
7+
// Package checkpoints provides a CheckpointStore that uses Azure Blob Storage.
8+
// This checkpoint store can be used with the azeventhubs.Processor type to
9+
// coordinate distributed consumption of events from an event hub.
10+
package checkpoints

sdk/messaging/azeventhubs/doc.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build go1.16
2+
// +build go1.16
3+
4+
// Copyright (c) Microsoft Corporation. All rights reserved.
5+
// Licensed under the MIT License.
6+
7+
// Package azeventhubs provides clients for sending events, using the ConsumerClient type or
8+
// the Processor, and receiving using the ProducerClient type.
9+
package azeventhubs

sdk/messaging/azeventhubs/go.mod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ require (
1111
)
1212

1313
require (
14+
code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c // indirect
1415
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect
1516
github.com/davecgh/go-spew v1.1.1 // indirect
17+
github.com/gofrs/uuid v3.3.0+incompatible // indirect
1618
github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
1719
github.com/google/uuid v1.1.1 // indirect
18-
github.com/kr/pretty v0.1.0 // indirect
1920
github.com/kylelemons/godebug v1.1.0 // indirect
2021
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect
2122
github.com/pmezard/go-difflib v1.0.0 // indirect
2223
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect
2324
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
2425
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
2526
golang.org/x/text v0.3.7 // indirect
26-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
2727
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
2828
)
29+
30+
// used in stress tests
31+
require github.com/microsoft/ApplicationInsights-Go v0.4.4

sdk/messaging/azeventhubs/go.sum

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c h1:5eeuG0BHx1+DHeT3AP+ISKZ2ht1UjGhm581ljqYpVeQ=
2+
code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c/go.mod h1:QD9Lzhd/ux6eNQVUDVRJX/RKTigpewimNYBi7ivZKY8=
13
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.0 h1:Ut0ZGdOwJDw0npYEg+TLlPls3Pq6JiZaP2/aGKir7Zw=
24
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
35
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8=
@@ -10,11 +12,16 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
1012
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1113
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1214
github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c=
15+
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
16+
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
17+
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
1318
github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c=
1419
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
1520
github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU=
21+
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
1622
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
1723
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
24+
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
1825
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
1926
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
2027
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
@@ -24,26 +31,39 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
2431
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
2532
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
2633
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
34+
github.com/microsoft/ApplicationInsights-Go v0.4.4 h1:G4+H9WNs6ygSCe6sUyxRc2U81TI5Es90b2t/MwX5KqY=
35+
github.com/microsoft/ApplicationInsights-Go v0.4.4/go.mod h1:fKRUseBqkw6bDiXTs3ESTiU/4YTIHsQS4W3fP2ieF4U=
2736
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
37+
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
38+
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
39+
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
2840
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI=
2941
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ=
3042
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3143
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3244
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
3345
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
3446
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
47+
github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0=
3548
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw=
3649
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
50+
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
3751
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
3852
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
53+
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
54+
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
3955
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
4056
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
4157
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
58+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
4259
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
4360
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
4461
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
4562
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
4663
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
64+
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
65+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
66+
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
4767
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
4868
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4969
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

0 commit comments

Comments
 (0)