Updating documentation.
- Example stripped from README.md to prevent code decay. Link given to GoDoc examples which are unit-tests, therefore always up-to-date. - "Code of Conduct" and "Communication" sections moved from CONTRIBUTING.md to README.md. - Missing documentation for Resource Group location in unit tests added.
This commit is contained in:
Родитель
f69f68590a
Коммит
c4030ddc1c
|
@ -8,6 +8,9 @@ First of all, welcome. Thank you for your interest in furthering Go support for
|
||||||
|
|
||||||
The following programs should be installed on your machine before you begin developing.
|
The following programs should be installed on your machine before you begin developing.
|
||||||
|
|
||||||
|
> Note: Adhering to the linters below is enforced in CI. It is not required to have the tools locally, but contributors
|
||||||
|
are expected to fix those issues found in CI.
|
||||||
|
|
||||||
| Tool | Necessary | Description |
|
| Tool | Necessary | Description |
|
||||||
| :---------------------------------------------------: | :-----: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| :---------------------------------------------------: | :-----: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [go](https://godoc.org) | Required |This is a Go project, and as such you should have Go installed on your machine. As a general rule of thumb, we support two minor versions behind the current latest stable release. |
|
| [go](https://godoc.org) | Required |This is a Go project, and as such you should have Go installed on your machine. As a general rule of thumb, we support two minor versions behind the current latest stable release. |
|
||||||
|
@ -15,9 +18,9 @@ The following programs should be installed on your machine before you begin deve
|
||||||
| [dep](https://github.com/golang/dep) | Required |`dep` is used to vendor our dependencies. We plan on adopting Go modules in the future. |
|
| [dep](https://github.com/golang/dep) | Required |`dep` is used to vendor our dependencies. We plan on adopting Go modules in the future. |
|
||||||
| [az](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) | Optional | The Azure CLI is used for its ability to authenticate against Azure. Tests themselves only need a connection string and other metadata about the Service Bus namespace, but tooling to automatically setup the necessary infrastructure to run the tests may depend on the Azure CLI. |
|
| [az](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) | Optional | The Azure CLI is used for its ability to authenticate against Azure. Tests themselves only need a connection string and other metadata about the Service Bus namespace, but tooling to automatically setup the necessary infrastructure to run the tests may depend on the Azure CLI. |
|
||||||
| [terraform](https://terraform.io) | Optional | `terraform` is used to help provision the Azure infrastructure needed to run our tests both in CI and on your local machine. If you have already provisioned a Service Bus Namespace, and created the necessary Service Bus Queues, you do not need terraform. |
|
| [terraform](https://terraform.io) | Optional | `terraform` is used to help provision the Azure infrastructure needed to run our tests both in CI and on your local machine. If you have already provisioned a Service Bus Namespace, and created the necessary Service Bus Queues, you do not need terraform. |
|
||||||
| [golint](https://godoc.org/golang.org/x/lint/golint) | Required |`golint` is a linter that finds basic stylistic mistakes in Go programs. |
|
| [golint](https://godoc.org/golang.org/x/lint/golint) | Optional |`golint` is a linter that finds basic stylistic mistakes in Go programs. |
|
||||||
| [gocyclo](https://github.com/fzipp/gocyclo) | Required |`gocyclo` checks for programmatic complexity, to ensure code readability. |
|
| [gocyclo](https://github.com/fzipp/gocyclo) | Optional |`gocyclo` checks for programmatic complexity, to ensure code readability. |
|
||||||
| [megacheck](https://honnef.co/go/tools/cmd/megacheck) | Required | `megacheck` is a linter that checks for a broader set of errors than `go vet` or `golint`. |
|
| [megacheck](https://honnef.co/go/tools/cmd/megacheck) | Optional | `megacheck` is a linter that checks for a broader set of errors than `go vet` or `golint`. |
|
||||||
|
|
||||||
#### Editors
|
#### Editors
|
||||||
|
|
||||||
|
@ -46,6 +49,7 @@ your GitHub account. Sign once and commit to any Microsoft Open Source Project.
|
||||||
| AZURE_SUBSCRIPTION_ID | The Azure Subscription to be used to run your tests. |
|
| AZURE_SUBSCRIPTION_ID | The Azure Subscription to be used to run your tests. |
|
||||||
| AZURE_TENANT_ID | The UUID used to identify the tenant your Azure Subscription belongs to. |
|
| AZURE_TENANT_ID | The UUID used to identify the tenant your Azure Subscription belongs to. |
|
||||||
| TEST_SERVICEBUS_RESOURCE_GROUP | The Azure Resource Group that holds the infrastructure needed to run the tests. |
|
| TEST_SERVICEBUS_RESOURCE_GROUP | The Azure Resource Group that holds the infrastructure needed to run the tests. |
|
||||||
|
| TEST_SERVICEBUS_LOCATION | The Azure Region containing your resource group. (e.g. "eastus", "westus2", etc.) |
|
||||||
1. Authenticate using the CLI byt running the command `az login`.
|
1. Authenticate using the CLI byt running the command `az login`.
|
||||||
> Note: Alternatively, set environment variables `ARM_CLIENT_ID`, `ARM_CLIENT_SECRET`, `ARM_TENANT_ID`, and `ARM_SUBSCRIPTION_ID` equal to their AZURE counterparts.
|
> Note: Alternatively, set environment variables `ARM_CLIENT_ID`, `ARM_CLIENT_SECRET`, `ARM_TENANT_ID`, and `ARM_SUBSCRIPTION_ID` equal to their AZURE counterparts.
|
||||||
1. Run `terraform apply` to make sure that all of the infrastructure needed to run the tests is available.
|
1. Run `terraform apply` to make sure that all of the infrastructure needed to run the tests is available.
|
||||||
|
@ -76,14 +80,3 @@ the form of a [GitHub Gist](https://gist.github.com) or [Go Playground](https://
|
||||||
### Feature Requests
|
### Feature Requests
|
||||||
|
|
||||||
For expanded capabilities, please describe what you'd like to see and whom you believe would benefit.
|
For expanded capabilities, please describe what you'd like to see and whom you believe would benefit.
|
||||||
|
|
||||||
## Communication
|
|
||||||
|
|
||||||
The developers of this library are all active on the [Gopher Slack](https://gophers.slack.com), it is likely easiest to
|
|
||||||
get our attention in the [Microsoft Channel](https://gophers.slack.com/messages/C6NH8V2E9). We'll also find your issue
|
|
||||||
if you ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/go+azure) with the tags `azure` and `go`.
|
|
||||||
|
|
||||||
## Code of Conduct
|
|
||||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
||||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact
|
|
||||||
[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
||||||
|
|
71
README.md
71
README.md
|
@ -20,7 +20,8 @@ This library is currently a preview. There may be breaking interface changes unt
|
||||||
If you run into an issue, please don't hesitate to log a
|
If you run into an issue, please don't hesitate to log a
|
||||||
[new issue](https://github.com/Azure/azure-service-bus-go/issues/new) or open a pull request.
|
[new issue](https://github.com/Azure/azure-service-bus-go/issues/new) or open a pull request.
|
||||||
|
|
||||||
## Installing the library
|
## Getting Started
|
||||||
|
### Installing the library
|
||||||
To more reliably manage dependencies in your application we recommend [golang/dep](https://github.com/golang/dep).
|
To more reliably manage dependencies in your application we recommend [golang/dep](https://github.com/golang/dep).
|
||||||
|
|
||||||
With dep:
|
With dep:
|
||||||
|
@ -35,71 +36,17 @@ go get -u github.com/Azure/azure-service-bus-go/...
|
||||||
|
|
||||||
If you need to install Go, follow [the official instructions](https://golang.org/dl/)
|
If you need to install Go, follow [the official instructions](https://golang.org/dl/)
|
||||||
|
|
||||||
## Using Service Bus
|
### Examples
|
||||||
In this section we'll cover some basics of the library to help you get started.
|
|
||||||
|
|
||||||
### Quick start
|
Find up-to-date examples and documentation on [godoc.org](https://godoc.org/github.com/Azure/azure-service-bus-go#pkg-examples).
|
||||||
Let's send and receive `"hello, world!"`.
|
|
||||||
```go
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
### Have questions?
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
|
|
||||||
"github.com/Azure/azure-service-bus-go"
|
The developers of this library are all active on the [Gopher Slack](https://gophers.slack.com), it is likely easiest to
|
||||||
)
|
get our attention in the [Microsoft Channel](https://gophers.slack.com/messages/C6NH8V2E9). We'll also find your issue
|
||||||
|
if you ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/go+azure) with the tags `azure` and `go`.
|
||||||
|
|
||||||
func main() {
|
## Code of Conduct
|
||||||
connStr := os.Getenv("SERVICEBUS_CONNECTION_STRING")
|
|
||||||
ns, err := servicebus.NewNamespace(servicebus.NamespaceWithConnectionString(connStr))
|
|
||||||
if err != nil {
|
|
||||||
// handle error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize and create a Service Bus Queue named helloworld if it doesn't exist
|
|
||||||
queueName := "helloworld"
|
|
||||||
q, err := ns.NewQueue(queueName)
|
|
||||||
if err != nil {
|
|
||||||
// handle queue creation error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send message to the Queue named helloworld
|
|
||||||
err = q.Send(context.Background(), servicebus.NewMessageFromString("Hello World!"))
|
|
||||||
if err != nil {
|
|
||||||
// handle message send error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receive message from queue named helloworld
|
|
||||||
listenHandle, err := q.Receive(context.Background(),
|
|
||||||
func(ctx context.Context, msg *servicebus.Message) servicebus.DispositionAction {
|
|
||||||
fmt.Println(string(msg.Data))
|
|
||||||
return msg.Accept()
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
// handle queue listener creation err
|
|
||||||
}
|
|
||||||
// Close the listener handle for the Service Bus Queue
|
|
||||||
defer listenHandle.Close(context.Background())
|
|
||||||
|
|
||||||
// Wait for a signal to quit:
|
|
||||||
signalChan := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(signalChan, os.Interrupt, os.Kill)
|
|
||||||
<-signalChan
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
# Contributing
|
|
||||||
|
|
||||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
||||||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
||||||
the rights to use your contribution. For details, visit https://cla.microsoft.com.
|
|
||||||
|
|
||||||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
|
||||||
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
|
||||||
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
||||||
|
|
||||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
||||||
|
|
Загрузка…
Ссылка в новой задаче