Skip to content

The Go library for pulsar admin operations, providing a unified Go API for managing pulsar resources such as tenants, namespaces and topics, etc.

License

Notifications You must be signed in to change notification settings

flowchartsman/pulsar-admin-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pulsar Admin Go Library

Go Reference Go Report Card Language License

Pulsar-Admin-Go is a Go library for Apache Pulsar. 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 and pulsar-resources-operator) that need to manipulate the pulsar admin resources rely on the 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 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

    go get github.com/streamnative/pulsar-admin-go

Manage pulsar tenants

  • List all tenants
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
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
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
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 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. See LICENSE

About

The Go library for pulsar admin operations, providing a unified Go API for managing pulsar resources such as tenants, namespaces and topics, etc.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.6%
  • Makefile 0.4%