-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation and Sample Fixes for Schema Registry (#26703)
* Adding SchemaId sync file. Renaming old file to GetSchemaIdSampleAsync. * Renaming GetSchemaSample.java to GetSchemaSampleAsync. * Fix documentation on getSchemaId. * Fixing documentation on samples. * Adding RegisterSchemaSample and renaming async sample to RegisterSchemaSampleAsync. * Updating README links. * Update README and readme samples. * Updating documentation for Client and clientbuilder.
- Loading branch information
Showing
12 changed files
with
188 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...schemaregistry/src/samples/java/com/azure/data/schemaregistry/GetSchemaIdSampleAsync.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.data.schemaregistry; | ||
|
||
import com.azure.core.credential.TokenCredential; | ||
import com.azure.data.schemaregistry.models.SchemaFormat; | ||
import com.azure.identity.DefaultAzureCredentialBuilder; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
|
||
/** | ||
* Sample to demonstrate retrieving properties of a schema from Schema Registry using async client. | ||
* | ||
* @see GetSchemaIdSample for the synchronous sample. | ||
*/ | ||
public class GetSchemaIdSampleAsync { | ||
|
||
/** | ||
* The main method to run this program. | ||
* @param args Ignored args. | ||
*/ | ||
public static void main(String[] args) throws InterruptedException { | ||
TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); | ||
|
||
SchemaRegistryAsyncClient schemaRegistryAsyncClient = new SchemaRegistryClientBuilder() | ||
.fullyQualifiedNamespace("{schema-registry-endpoint") | ||
.credential(tokenCredential) | ||
.buildAsyncClient(); | ||
|
||
CountDownLatch countDownLatch = new CountDownLatch(1); | ||
|
||
// Gets the properties of an existing schema. | ||
// `subscribe` is a non-blocking operation. It hooks up the callbacks and then moves onto the next line of code. | ||
schemaRegistryAsyncClient | ||
.getSchemaProperties("{group-name}", "{schema-name}", "{schema-string}", SchemaFormat.AVRO) | ||
.subscribe(schemaId -> { | ||
System.out.println("Successfully retrieved the schema id: " + schemaId); | ||
countDownLatch.countDown(); | ||
}); | ||
|
||
// wait for the async task to complete | ||
countDownLatch.await(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...a-schemaregistry/src/samples/java/com/azure/data/schemaregistry/GetSchemaSampleAsync.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.data.schemaregistry; | ||
|
||
import com.azure.core.credential.TokenCredential; | ||
import com.azure.identity.DefaultAzureCredentialBuilder; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
|
||
/** | ||
* Sample to demonstrate retrieving a schema from Schema Registry using the async client. | ||
*/ | ||
public class GetSchemaSampleAsync { | ||
/** | ||
* The main method to run this program. | ||
* @param args Ignored args. | ||
*/ | ||
public static void main(String[] args) throws InterruptedException { | ||
TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); | ||
|
||
SchemaRegistryAsyncClient schemaRegistryAsyncClient = new SchemaRegistryClientBuilder() | ||
.fullyQualifiedNamespace("{schema-registry-endpoint") | ||
.credential(tokenCredential) | ||
.buildAsyncClient(); | ||
|
||
CountDownLatch countDownLatch = new CountDownLatch(1); | ||
|
||
// Get a schema using its id. The schema id is generated when it is registered via the client or Azure Portal. | ||
// `subscribe` is a non-blocking operation. It hooks up the callbacks and then moves onto the next line of code. | ||
schemaRegistryAsyncClient | ||
.getSchema("{schema-id}") | ||
.subscribe(schema -> { | ||
System.out.println("Successfully retrieved schema."); | ||
System.out.printf("Id: %s%nContents: %s%n", schema.getProperties().getId(), schema.getDefinition()); | ||
|
||
countDownLatch.countDown(); | ||
}); | ||
|
||
// wait for the async task to complete | ||
countDownLatch.await(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...emaregistry/src/samples/java/com/azure/data/schemaregistry/RegisterSchemaSampleAsync.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.data.schemaregistry; | ||
|
||
import com.azure.core.credential.TokenCredential; | ||
import com.azure.data.schemaregistry.models.SchemaFormat; | ||
import com.azure.identity.DefaultAzureCredentialBuilder; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
|
||
/** | ||
* Sample to demonstrate registering a schema with Schema Registry. | ||
* | ||
* @see RegisterSchemaSample for the sync sample. | ||
*/ | ||
public class RegisterSchemaSampleAsync { | ||
/** | ||
* The main method to run this program. | ||
* | ||
* @param args Ignored args. | ||
*/ | ||
public static void main(String[] args) throws InterruptedException { | ||
TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); | ||
|
||
SchemaRegistryAsyncClient schemaRegistryAsyncClient = new SchemaRegistryClientBuilder() | ||
.fullyQualifiedNamespace("{schema-registry-endpoint}") | ||
.credential(tokenCredential) | ||
.buildAsyncClient(); | ||
|
||
CountDownLatch countDownLatch = new CountDownLatch(1); | ||
|
||
// Register a schema | ||
// `subscribe` is a non-blocking operation. It hooks up the callbacks and then moves onto the next line of code. | ||
schemaRegistryAsyncClient | ||
.registerSchema("{group-name}", "{schema-name}", "{schema-string}", SchemaFormat.AVRO) | ||
.subscribe(schemaProperties -> { | ||
System.out.println("Successfully registered a schema with id " + schemaProperties.getId()); | ||
countDownLatch.countDown(); | ||
}); | ||
|
||
// wait for the async task to complete | ||
countDownLatch.await(); | ||
} | ||
} |