Skip to content

Commit

Permalink
rename eventhub checkpointStrategy parameter azureWebJob to azureFunc…
Browse files Browse the repository at this point in the history
…tion

Signed-off-by: Christian Leinweber <christian.leinweber@maibornwolff.de>
  • Loading branch information
christle committed May 4, 2021
1 parent 0822640 commit 36b1196
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions pkg/scalers/azure/azure_eventhub_checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type checkpointer interface {
extractCheckpoint(get *azblob.DownloadResponse) (Checkpoint, error)
}

type azureWebjobCheckpointer struct {
type azureFunctionCheckpointer struct {
partitionID string
containerName string
}
Expand Down Expand Up @@ -88,8 +88,8 @@ func newCheckpointer(info EventHubInfo, partitionID string) checkpointer {
containerName: info.BlobContainer,
partitionID: partitionID,
}
case (info.CheckpointStrategy == "azureWebJob" || info.BlobContainer == ""):
return &azureWebjobCheckpointer{
case (info.CheckpointStrategy == "azureFunction" || info.BlobContainer == ""):
return &azureFunctionCheckpointer{
containerName: "azure-webjobs-eventhub",
partitionID: partitionID,
}
Expand All @@ -101,8 +101,8 @@ func newCheckpointer(info EventHubInfo, partitionID string) checkpointer {
}
}

// resolve path for AzureWebJobCheckpointer
func (checkpointer *azureWebjobCheckpointer) resolvePath(info EventHubInfo) (*url.URL, error) {
// resolve path for AzureFunctionCheckpointer
func (checkpointer *azureFunctionCheckpointer) resolvePath(info EventHubInfo) (*url.URL, error) {
eventHubNamespace, eventHubName, err := getHubAndNamespace(info)
if err != nil {
return nil, err
Expand All @@ -113,8 +113,8 @@ func (checkpointer *azureWebjobCheckpointer) resolvePath(info EventHubInfo) (*ur
return path, nil
}

// extract checkpoint for AzureWebJobCheckpointer
func (checkpointer *azureWebjobCheckpointer) extractCheckpoint(get *azblob.DownloadResponse) (Checkpoint, error) {
// extract checkpoint for AzureFunctionCheckpointer
func (checkpointer *azureFunctionCheckpointer) extractCheckpoint(get *azblob.DownloadResponse) (Checkpoint, error) {
var checkpoint Checkpoint
err := readToCheckpointFromBody(get, &checkpoint)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/scalers/azure/azure_eventhub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// Add a valid Storage account connection string here
const StorageConnectionString = ""

func TestCheckpointFromBlobStorageAzureWebjob(t *testing.T) {
func TestCheckpointFromBlobStorageAzureFunction(t *testing.T) {
if StorageConnectionString == "" {
return
}
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestCheckpointFromBlobStorageGoSdk(t *testing.T) {
assert.Equal(t, check, expectedCheckpoint)
}

func TestShouldParseCheckpointForWebJob(t *testing.T) {
func TestShouldParseCheckpointForFunction(t *testing.T) {
eventHubInfo := EventHubInfo{
EventHubConnection: "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;EntityPath=hub-test",
EventHubConsumerGroup: "$Default",
Expand All @@ -237,11 +237,11 @@ func TestShouldParseCheckpointForWebJob(t *testing.T) {
assert.Equal(t, url.Path, "/azure-webjobs-eventhub/eventhubnamespace.servicebus.windows.net/hub-test/$Default/0")
}

func TestShouldParseCheckpointForWebJobWithCheckpointStrategy(t *testing.T) {
func TestShouldParseCheckpointForFunctionWithCheckpointStrategy(t *testing.T) {
eventHubInfo := EventHubInfo{
EventHubConnection: "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;EntityPath=hub-test",
EventHubConsumerGroup: "$Default",
CheckpointStrategy: "azureWebJob",
CheckpointStrategy: "azureFunction",
}

cp := newCheckpointer(eventHubInfo, "0")
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/azure_eventhub_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var parseEventHubMetadataDataset = []parseEventHubMetadataTestData{
// missing unprocessed event threshold - should replace with default
{map[string]string{"storageConnectionFromEnv": storageConnectionSetting, "consumerGroup": eventHubConsumerGroup, "connectionFromEnv": eventHubConnectionSetting}, false},
// added blob container details
{map[string]string{"storageConnectionFromEnv": storageConnectionSetting, "consumerGroup": eventHubConsumerGroup, "connectionFromEnv": eventHubConnectionSetting, "blobContainer": testContainerName, "checkpointStrategy": "azureWebJob"}, false},
{map[string]string{"storageConnectionFromEnv": storageConnectionSetting, "consumerGroup": eventHubConsumerGroup, "connectionFromEnv": eventHubConnectionSetting, "blobContainer": testContainerName, "checkpointStrategy": "azureFunction"}, false},
}

var parseEventHubMetadataDatasetWithPodIdentity = []parseEventHubMetadataTestData{
Expand Down

0 comments on commit 36b1196

Please sign in to comment.