|
1 | | -# Azure Template Package client library for Go |
| 1 | +# Azure Event Grid Client Module for Go |
2 | 2 |
|
3 | | -Azure Template Package client library for Go (`aztemplate`) matches necessary patterns that the development team has established to create a unified SDK written in the Go programming language. These libraries follow the Azure SDK Design Guidelines for Go. |
| 3 | +[Azure Event Grid](https://learn.microsoft.com/azure/event-grid/overview) is a highly scalable, fully managed Pub Sub message distribution service that offers flexible message consumption patterns. For more information about Event Grid see: [link](https://learn.microsoft.com/azure/event-grid/overview). |
4 | 4 |
|
5 | | -The library allows client libraries to expose common functionality in a consistent fashion. Once you learn how to use these APIs in one client library, you will know how to use them in other client libraries. |
| 5 | +This client module allows you to publish events and receive events using the [Pull delivery](https://learn.microsoft.com/azure/event-grid/pull-delivery-overview) API. |
| 6 | + |
| 7 | +Key links: |
| 8 | +- [Source code][source] |
| 9 | +- [API Reference Documentation][godoc] |
| 10 | +- [Product documentation](https://azure.microsoft.com/services/event-grid/) |
| 11 | +- [Samples][godoc_examples] |
6 | 12 |
|
7 | 13 | ## Getting started |
8 | 14 |
|
9 | | -For a rich example of a well formatted readme, please check [here.](https://github.com/Azure/azure-sdk/blob/main/docs/policies/README-TEMPLATE.md) In addition, this is an [example readme](https://github.com/Azure/azure-sdk/blob/main/docs/policies/README-EXAMPLE.md) that should be emulated. Note that the top-level sections in this template align with that of the [template.](https://github.com/Azure/azure-sdk/blob/main/docs/policies/README-TEMPLATE.md) |
| 15 | +### Install the package |
| 16 | + |
| 17 | +Install the Azure Event Grid client module for Go with `go get`: |
| 18 | + |
| 19 | +```bash |
| 20 | +go get github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventgrid |
| 21 | +``` |
| 22 | + |
| 23 | +### Prerequisites |
| 24 | + |
| 25 | +- Go, version 1.18 or higher |
| 26 | +- An [Azure subscription](https://azure.microsoft.com/free/) |
| 27 | +- An [Event Grid namespace](https://learn.microsoft.com/azure/event-grid/). |
| 28 | +- An Event Grid namespace. You can create an Event Grid Namespace using the [Azure Portal](https://learn.microsoft.com/azure/event-grid/create-view-manage-namespaces). |
| 29 | + |
| 30 | +### Authenticate the client |
| 31 | + |
| 32 | +Event Grid clients authenticate using a shared key credential. An example of that can be viewed here: [ExampleNewClientWithSharedKeyCredential][godoc_example_newclient]. |
10 | 33 |
|
11 | 34 | # Key concepts |
12 | 35 |
|
13 | | -Bullet point list of your library's main concepts. |
| 36 | +An Azure Event Grid [**namespace**](https://learn.microsoft.com/azure/event-grid/mqtt-event-grid-namespace-terminology#namespace) can contain multiple **namespace topics**. Publishers publish events to namespace topics. More on creating namespace topics can be found here: [link](https://learn.microsoft.com/azure/event-grid/create-view-manage-namespace-topics). |
| 37 | + |
| 38 | +To receive events, you must create an **event subscription**, which is associated with a topic. More on creating topic subscriptions can be found here: [link](https://learn.microsoft.com/azure/event-grid/create-view-manage-event-subscriptions). |
14 | 39 |
|
15 | 40 | # Examples |
16 | 41 |
|
17 | | -Examples of some of the key concepts for your library. |
| 42 | +Examples for various scenarios can be found on [pkg.go.dev](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventgrid#pkg-examples) or in the example*_test.go files in our GitHub repo for [azeventgrid](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/messaging/azeventgrid). |
18 | 43 |
|
19 | 44 | # Troubleshooting |
20 | 45 |
|
21 | | -Running into issues? This section should contain details as to what to do there. |
| 46 | +### Logging |
| 47 | + |
| 48 | +This module uses the classification-based logging implementation in `azcore`. To enable console logging for all SDK modules, set the environment variable `AZURE_SDK_GO_LOGGING` to `all`. |
| 49 | + |
| 50 | +Use the `azcore/log` package to control log event output. |
| 51 | + |
| 52 | +```go |
| 53 | +import ( |
| 54 | + "fmt" |
| 55 | + azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log" |
| 56 | +) |
| 57 | + |
| 58 | +// print log output to stdout |
| 59 | +azlog.SetListener(func(event azlog.Event, s string) { |
| 60 | + fmt.Printf("[%s] %s\n", event, s) |
| 61 | +}) |
| 62 | +``` |
22 | 63 |
|
23 | 64 | # Next steps |
24 | 65 |
|
@@ -67,3 +108,7 @@ Azure SDK for Go is licensed under the [MIT](https://github.com/Azure/azure-sdk- |
67 | 108 | [azure_sub]: https://azure.microsoft.com/free/ |
68 | 109 | [cloud_shell]: https://docs.microsoft.com/azure/cloud-shell/overview |
69 | 110 | [cloud_shell_bash]: https://shell.azure.com/bash |
| 111 | +[source]: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/messaging/azeventgrid |
| 112 | +[godoc]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventgrid |
| 113 | +[godoc_examples]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventgrid#pkg-examples |
| 114 | +[godoc_example_newclient]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventgrid#example-NewClientWithSharedKeyCredential |
0 commit comments