Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/eventhub/eventhubs-checkpointstore-blob/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": ["@azure/azure-sdk"],
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"]
}
3 changes: 3 additions & 0 deletions sdk/eventhub/eventhubs-checkpointstore-blob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.1.0-beta.1 (Unreleased)

### Features Added

- With the dropping of support for Node.js versions that are no longer in LTS, the dependency on `@types/node` has been updated to version 12. Read our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
- Updates all async methods on `BlobCheckpointStore` to accept
an optional `options` parameter that can be used to pass in an
Expand All @@ -13,6 +14,8 @@

### Key Bugs Fixed

- Fixed a bug where `ContainerClient` could not passed to `BlobCheckpointStore` if the `ContainerClient` was created by another version of `@azure/storage-blob`.

## 1.0.1 (2020-08-03)

- Fixes issue [#10132](https://github.com/Azure/azure-sdk-for-js/issues/10132)
Expand Down
1 change: 1 addition & 0 deletions sdk/eventhub/eventhubs-checkpointstore-blob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
},
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/core-paging": "^1.2.0",
"@azure/event-hubs": "^5.8.0-beta.1",
"@azure/logger": "^1.0.0",
"@azure/storage-blob": "^12.8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,47 @@
```ts

import { AzureLogger } from '@azure/logger';
import { BlobItem } from '@azure/storage-blob';
import { BlobSetMetadataOptions } from '@azure/storage-blob';
import { BlockBlobUploadOptions } from '@azure/storage-blob';
import { BlockBlobUploadResponse } from '@azure/storage-blob';
import { Checkpoint } from '@azure/event-hubs';
import { CheckpointStore } from '@azure/event-hubs';
import { ContainerClient } from '@azure/storage-blob';
import { ContainerListBlobFlatSegmentResponse } from '@azure/storage-blob';
import { ContainerListBlobsOptions } from '@azure/storage-blob';
import { ContainerSetMetadataResponse } from '@azure/storage-blob';
import { HttpRequestBody } from '@azure/storage-blob';
import { Metadata } from '@azure/storage-blob';
import { OperationOptions } from '@azure/event-hubs';
import { PagedAsyncIterableIterator } from '@azure/core-paging';
import { PartitionOwnership } from '@azure/event-hubs';

// @public
export class BlobCheckpointStore implements CheckpointStore {
constructor(containerClient: ContainerClient);
constructor(containerClient: ContainerClientLike);
claimOwnership(partitionOwnership: PartitionOwnership[], options?: OperationOptions): Promise<PartitionOwnership[]>;
listCheckpoints(fullyQualifiedNamespace: string, eventHubName: string, consumerGroup: string, options?: OperationOptions): Promise<Checkpoint[]>;
listOwnership(fullyQualifiedNamespace: string, eventHubName: string, consumerGroup: string, options?: OperationOptions): Promise<PartitionOwnership[]>;
updateCheckpoint(checkpoint: Checkpoint, options?: OperationOptions): Promise<void>;
}

// @public
export interface BlobClientLike {
getBlockBlobClient(): BlockBlobClientLike;
}

// @public
export interface BlockBlobClientLike {
setMetadata(metadata?: Metadata, options?: BlobSetMetadataOptions): Promise<ContainerSetMetadataResponse>;
upload(body: HttpRequestBody, contentLength: number, options?: BlockBlobUploadOptions): Promise<BlockBlobUploadResponse>;
}

// @public
export interface ContainerClientLike {
getBlobClient(blobName: string): BlobClientLike;
listBlobsFlat(options?: ContainerListBlobsOptions): PagedAsyncIterableIterator<BlobItem, ContainerListBlobFlatSegmentResponse>;
}

// @public
export const logger: AzureLogger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ import {
Checkpoint,
OperationOptions,
} from "@azure/event-hubs";
import { ContainerClient, Metadata, RestError, BlobSetMetadataResponse } from "@azure/storage-blob";
import { Metadata, RestError, BlobSetMetadataResponse } from "@azure/storage-blob";
import { logger, logErrorStackTrace } from "./log";
import { ContainerClientLike } from "./storageBlobInterfaces";
import { throwTypeErrorIfParameterMissing } from "./util/error";

/**
* An implementation of CheckpointStore that uses Azure Blob Storage to persist checkpoint data.
*/
export class BlobCheckpointStore implements CheckpointStore {
private _containerClient: ContainerClient;
private _containerClient: ContainerClientLike;

constructor(containerClient: ContainerClient) {
/**
* Constructs a new instance of {@link BlobCheckpointStore}
* @param containerClient - An instance of a storage blob ContainerClient.
*/
constructor(containerClient: ContainerClientLike) {
this._containerClient = containerClient;
}
/**
Expand Down
1 change: 1 addition & 0 deletions sdk/eventhub/eventhubs-checkpointstore-blob/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/// <reference lib="esnext.asynciterable" />

export { BlobCheckpointStore } from "./blobCheckpointStore";
export { ContainerClientLike, BlobClientLike, BlockBlobClientLike } from "./storageBlobInterfaces";
export { logger } from "./log";
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import {
Metadata,
BlobItem,
ContainerListBlobFlatSegmentResponse,
ContainerListBlobsOptions,
BlockBlobUploadOptions,
BlockBlobUploadResponse,
HttpRequestBody,
BlobSetMetadataOptions,
ContainerSetMetadataResponse,
} from "@azure/storage-blob";
import { PagedAsyncIterableIterator } from "@azure/core-paging";

/**
* An interface compatible with an instance of {@link BlobClient}.
*/
export interface BlobClientLike {
Comment thread
maorleger marked this conversation as resolved.
/**
* Creates a BlockBlobClient object.
*/
getBlockBlobClient(): BlockBlobClientLike;
}

/**
* An interface compatible with Storage Blob's ContainerClient class.
*/
export interface ContainerClientLike {
/**
* Creates a {@link BlobClient}
*/
getBlobClient(blobName: string): BlobClientLike;
/**
* Returns an async iterable iterator to list all the blobs
* under the specified account.
*/
listBlobsFlat(
options?: ContainerListBlobsOptions
): PagedAsyncIterableIterator<BlobItem, ContainerListBlobFlatSegmentResponse>;
}

/**
* An interface compatible with Storage Blob's BlockBlobClient class.
*/
export interface BlockBlobClientLike {
/**
* Creates a new block blob, or updated the content of an existing block blob.
*/
upload(
body: HttpRequestBody,
contentLength: number,
options?: BlockBlobUploadOptions
): Promise<BlockBlobUploadResponse>;
/**
* Sets user-defined metadata for the specified blob as one or more name-value pairs.
*/
setMetadata(
metadata?: Metadata,
options?: BlobSetMetadataOptions
): Promise<ContainerSetMetadataResponse>;
}