|
| 1 | +# Azure Event Grid Namespaces Client Module for Go |
| 2 | + |
| 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 | + |
| 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 | +> NOTE: This client does not work with Event Grid Basic. Use the [publisher.Client][godoc_publisher_client] in the `publisher` sub-package instead. |
| 8 | +
|
| 9 | +Key links: |
| 10 | +- [Source code][source] |
| 11 | +- [API Reference Documentation][godoc] |
| 12 | +- [Product documentation](https://azure.microsoft.com/services/event-grid/) |
| 13 | +- [Samples][godoc_examples] |
| 14 | + |
| 15 | +## Getting started |
| 16 | + |
| 17 | +### Install the package |
| 18 | + |
| 19 | +Install the Azure Event Grid Namespaces client module for Go with `go get`: |
| 20 | + |
| 21 | +```bash |
| 22 | +go get github.com/Azure/azure-sdk-for-go/sdk/messaging/eventgrid/aznamespaces |
| 23 | +``` |
| 24 | + |
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +- Go, version 1.18 or higher |
| 28 | +- An [Azure subscription](https://azure.microsoft.com/free/) |
| 29 | +- An [Event Grid namespace][ms_namespace]. You can create an Event Grid namespace using the [Azure Portal][ms_create_namespace]. |
| 30 | +- An [Event Grid namespace topic][ms_topic]. You can create an Event Grid namespace topic using the [Azure Portal][ms_create_topic]. |
| 31 | + |
| 32 | +### Authenticate the client |
| 33 | + |
| 34 | +Event Grid namespace clients authenticate using a shared key credential. An example of that can be viewed here: [ExampleNewClientWithSharedKeyCredential][godoc_example_newclient]. |
| 35 | + |
| 36 | +# Key concepts |
| 37 | + |
| 38 | +An Event Grid namespace is a container for multiple types of resources, including [**namespace topics**][ms_topic]: |
| 39 | +- A [**namespace topic**][ms_topic] contains CloudEvents that you publish, via [Client.PublishCloudEvents][godoc_client_publish]. |
| 40 | +- A [**topic subscription**][ms_subscription], associated with a single topic, can be used to receive events via [Client.ReceiveEvents][godoc_client_receive]. |
| 41 | + |
| 42 | +Namespaces also offer access using MQTT, although that is not covered in this package. |
| 43 | + |
| 44 | +# Examples |
| 45 | + |
| 46 | +Examples for various scenarios can be found on [pkg.go.dev][godoc_examples] or in the example*_test.go files in our GitHub repo for [aznamespaces][source]. |
| 47 | + |
| 48 | +# Troubleshooting |
| 49 | + |
| 50 | +### Logging |
| 51 | + |
| 52 | +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`. |
| 53 | + |
| 54 | +Use the `azcore/log` package to control log event output. |
| 55 | + |
| 56 | +```go |
| 57 | +import ( |
| 58 | + "fmt" |
| 59 | + azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log" |
| 60 | +) |
| 61 | + |
| 62 | +// print log output to stdout |
| 63 | +azlog.SetListener(func(event azlog.Event, s string) { |
| 64 | + fmt.Printf("[%s] %s\n", event, s) |
| 65 | +}) |
| 66 | +``` |
| 67 | + |
| 68 | +# Next steps |
| 69 | + |
| 70 | +More sample code should go here, along with links out to the appropriate example tests. |
| 71 | + |
| 72 | +## Contributing |
| 73 | +For details on contributing to this repository, see the [contributing guide][azure_sdk_for_go_contributing]. |
| 74 | + |
| 75 | +This project welcomes contributions and suggestions. Most contributions require you to agree to a |
| 76 | +Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us |
| 77 | +the rights to use your contribution. For details, visit https://cla.microsoft.com. |
| 78 | + |
| 79 | +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide |
| 80 | +a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions |
| 81 | +provided by the bot. You will only need to do this once across all repos using our CLA. |
| 82 | + |
| 83 | +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). |
| 84 | +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or |
| 85 | +contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. |
| 86 | + |
| 87 | +### Additional Helpful Links for Contributors |
| 88 | +Many people all over the world have helped make this project better. You'll want to check out: |
| 89 | + |
| 90 | +* [What are some good first issues for new contributors to the repo?](https://github.com/azure/azure-sdk-for-go/issues?q=is%3Aopen+is%3Aissue+label%3A%22up+for+grabs%22) |
| 91 | +* [How to build and test your change][azure_sdk_for_go_contributing_developer_guide] |
| 92 | +* [How you can make a change happen!][azure_sdk_for_go_contributing_pull_requests] |
| 93 | +* Frequently Asked Questions (FAQ) and Conceptual Topics in the detailed [Azure SDK for Go wiki](https://github.com/azure/azure-sdk-for-go/wiki). |
| 94 | + |
| 95 | +<!-- ### Community--> |
| 96 | +### Reporting security issues and security bugs |
| 97 | + |
| 98 | +Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) <secure@microsoft.com>. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://www.microsoft.com/msrc/faqs-report-an-issue). |
| 99 | + |
| 100 | +### License |
| 101 | + |
| 102 | +Azure SDK for Go is licensed under the [MIT](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/template/aztemplate/LICENSE.txt) license. |
| 103 | + |
| 104 | +<!-- LINKS --> |
| 105 | +[azure_sdk_for_go_contributing]: https://github.com/Azure/azure-sdk-for-go/blob/main/CONTRIBUTING.md |
| 106 | +[azure_sdk_for_go_contributing_developer_guide]: https://github.com/Azure/azure-sdk-for-go/blob/main/CONTRIBUTING.md#developer-guide |
| 107 | +[azure_sdk_for_go_contributing_pull_requests]: https://github.com/Azure/azure-sdk-for-go/blob/main/CONTRIBUTING.md#pull-requests |
| 108 | +[source]: https://aka.ms/azsdk/go/namespaces/src |
| 109 | +[godoc]: https://aka.ms/azsdk/go/namespaces/pkg |
| 110 | +[godoc_client_publish]: https://aka.ms/azsdk/go/namespaces/pkg#Client.PublishCloudEvents |
| 111 | +[godoc_client_receive]: https://aka.ms/azsdk/go/namespaces/pkg#Client.ReceiveCloudEvents |
| 112 | +[godoc_examples]: https://aka.ms/azsdk/go/namespaces/pkg#pkg-examples |
| 113 | +[godoc_example_newclient]: https://aka.ms/azsdk/go/namespaces/pkg#example-NewClientWithSharedKeyCredential |
| 114 | +[godoc_publisher_client]: https://aka.ms/azsdk/go/eventgrid/pkg/#Client |
| 115 | +[ms_namespace]: https://learn.microsoft.com/azure/event-grid/concepts-pull-delivery#namespaces |
| 116 | +[ms_topic]: https://learn.microsoft.com/azure/event-grid/concepts-pull-delivery#namespace-topics |
| 117 | +[ms_subscription]: https://learn.microsoft.com/azure/event-grid/concepts-pull-delivery#event-subscriptions |
| 118 | +[ms_create_namespace]: https://learn.microsoft.com/azure/event-grid/create-view-manage-namespaces |
| 119 | +[ms_create_topic]: https://learn.microsoft.com/azure/event-grid/create-view-manage-namespace-topics |
0 commit comments