Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tisonkun/pulsar-admin-go
The Go library for pulsar admin operations, providing a unified Go API for managing pulsar resources such as tenants, namespaces and topics, etc.
https://github.com/tisonkun/pulsar-admin-go
Last synced: 2 days ago
JSON representation
The Go library for pulsar admin operations, providing a unified Go API for managing pulsar resources such as tenants, namespaces and topics, etc.
- Host: GitHub
- URL: https://github.com/tisonkun/pulsar-admin-go
- Owner: tisonkun
- License: apache-2.0
- Fork: true (streamnative/pulsar-admin-go)
- Created: 2023-08-23T02:48:55.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-23T02:52:31.000Z (about 1 year ago)
- Last Synced: 2023-08-23T06:15:11.400Z (about 1 year ago)
- Homepage:
- Size: 622 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Pulsar Admin Go Library
[![Go Reference](https://pkg.go.dev/badge/github.com/streamnative/pulsar-admin-go.svg)](https://pkg.go.dev/github.com/streamnative/pulsar-admin-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/streamnative/pulsar-admin-go)](https://goreportcard.com/report/github.com/streamnative/pulsar-admin-go)
[![Language](https://img.shields.io/badge/Language-Go-blue.svg)](https://golang.org/)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/streamnative/pulsar-admin-go/blob/master/LICENSE)Pulsar-Admin-Go is a [Go](https://go.dev) library for [Apache Pulsar](https://pulsar.apache.org/). It provides a unified Go API for managing pulsar resources such as tenants, namespaces and topics, etc.
## Motivation
Currently many projects (e.g, [terraform-provider-pulsar](https://github.com/streamnative/terraform-provider-pulsar) and [pulsar-resources-operator](https://github.com/streamnative/pulsar-resources-operator))
that need to manipulate the pulsar admin resources rely on the [pulsarctl](https://github.com/streamnative/pulsarctl),
which poses challenges for dependency management and versioning as we have to release a new pulsarctl to get updates.
So we decoupled the pulsar admin related api from pulsarctl and created the [pulsar-admin-go](https://github.com/streamnative/pulsar-admin-go) library based on it,
which also provides a clearer perspective and maintainability from an architectural perspective.## Quickstart
### Prerequisite
- go1.18+
- pulsar-admin-go in go.mod```shell
go get github.com/streamnative/pulsar-admin-go
```### Manage pulsar tenants
- List all tenants
```go
import (
"github.com/streamnative/pulsar-admin-go"
)func main() {
cfg := &pulsaradmin.Config{}
admin, err := pulsaradmin.NewClient(cfg)
if err != nil {
panic(err)
}
tenants, _ := admin.Tenants().List()
}
```### Manage pulsar namespaces
- List all namespaces
```go
import (
"github.com/streamnative/pulsar-admin-go"
)func main() {
cfg := &pulsaradmin.Config{}
admin, err := pulsaradmin.NewClient(cfg)
if err != nil {
panic(err)
}
namespaces, _ := admin.Namespaces().GetNamespaces("public")
}
```- Create a new namespace
```go
import (
"github.com/streamnative/pulsar-admin-go"
)func main() {
cfg := &pulsaradmin.Config{}
admin, err := pulsaradmin.NewClient(cfg)
if err != nil {
panic(err)
}
admin.Namespaces().CreateNamespace("public/dev")
}
```### Manage pulsar topics
- Create a topic
```go
import (
"github.com/streamnative/pulsar-admin-go"
"github.com/streamnative/pulsar-admin-go/pkg/utils"
)func main() {
cfg := &pulsaradmin.Config{}
admin, err := pulsaradmin.NewClient(cfg)
if err != nil {
panic(err)
}
topic, _ := utils.GetTopicName("public/dev/topic")
admin.Topics().Create(*topic, 3)
}
```## Contributing
Contributions are warmly welcomed and greatly appreciated!
The project follows the typical GitHub pull request model. See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
Before starting any work, please either comment on an existing issue, or file a new one.## License
Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). See [LICENSE](LICENSE)