admin

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package admin implements the functions to call pulsar admin

Index

Constants

View Source
const (
	// TopicDomainSeparator is the separator to separate the topic name
	TopicDomainSeparator = "://"
	// TopicDomainPersistent is the prefix for persistent topic
	TopicDomainPersistent = "persistent"
	// TopicDomainNonPersistent is the prefix for non persistent topic
	TopicDomainNonPersistent = "non-persistent"
)

Variables

This section is empty.

Functions

func IsAlreadyExist

func IsAlreadyExist(err error) bool

IsAlreadyExist returns true if the error indicates the resource already exist

func IsInternalServerError

func IsInternalServerError(err error) bool

IsInternalServerError returns true if the error indicates the resource already exist

func IsNoSuchHostError added in v0.6.0

func IsNoSuchHostError(err error) bool

IsNoSuchHostError returns true if operator cannot connect the resource host

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error indicates the resource is not found on server

func IsPermissionNotFound

func IsPermissionNotFound(err error) bool

IsPermissionNotFound returns true if the permission is not set

func MakeCompleteTopicName added in v0.6.0

func MakeCompleteTopicName(topicName string, persistent *bool) string

Types

type ClusterParams added in v0.3.0

type ClusterParams struct {
	ServiceURL                     string
	ServiceSecureURL               string
	BrokerServiceURL               string
	BrokerServiceSecureURL         string
	AuthPlugin                     string
	AuthParameters                 string
	BrokerClientTrustCertsFilePath string
}

ClusterParams indicate the parameters for creating a cluster

type DummyPulsarAdmin

type DummyPulsarAdmin struct {
}

DummyPulsarAdmin is a dummy struct of PulsarAdmin

func (*DummyPulsarAdmin) ApplyNamespace

func (d *DummyPulsarAdmin) ApplyNamespace(string, *NamespaceParams) error

ApplyNamespace is a fake implements of ApplyNamespace

func (*DummyPulsarAdmin) ApplyPulsarFunction added in v0.5.0

func (d *DummyPulsarAdmin) ApplyPulsarFunction(_, _, _, _ string, _ *v1alpha1.PulsarFunctionSpec, _ bool) error

ApplyPulsarFunction is a fake implements of ApplyPulsarFunction

func (*DummyPulsarAdmin) ApplyPulsarPackage added in v0.5.0

func (d *DummyPulsarAdmin) ApplyPulsarPackage(_, _, _, _ string, _ map[string]string, _ bool) error

ApplyPulsarPackage is a fake implements of ApplyPulsarPackage

func (*DummyPulsarAdmin) ApplyPulsarSink added in v0.5.0

func (d *DummyPulsarAdmin) ApplyPulsarSink(_, _, _, _ string, _ *v1alpha1.PulsarSinkSpec, _ bool) error

ApplyPulsarSink is a fake implements of ApplyPulsarSink

func (*DummyPulsarAdmin) ApplyPulsarSource added in v0.5.0

func (d *DummyPulsarAdmin) ApplyPulsarSource(_, _, _, _ string, _ *v1alpha1.PulsarSourceSpec, _ bool) error

ApplyPulsarSource is a fake implements of ApplyPulsarSource

func (*DummyPulsarAdmin) ApplyTenant

func (d *DummyPulsarAdmin) ApplyTenant(string, *TenantParams) error

ApplyTenant is a fake implements of ApplyTenant

func (*DummyPulsarAdmin) ApplyTopic

func (d *DummyPulsarAdmin) ApplyTopic(string, *TopicParams) (error, error)

ApplyTopic is a fake implements of ApplyTopic

func (*DummyPulsarAdmin) CheckClusterExist added in v0.3.0

func (d *DummyPulsarAdmin) CheckClusterExist(string) (bool, error)

CheckClusterExist checks whether the cluster exists

func (*DummyPulsarAdmin) CheckPulsarFunctionExist added in v0.5.1

func (d *DummyPulsarAdmin) CheckPulsarFunctionExist(_, _, _ string) (bool, error)

CheckPulsarFunctionExist is a fake implements of CheckPulsarFunctionExist

func (*DummyPulsarAdmin) CheckPulsarPackageExist added in v0.5.1

func (d *DummyPulsarAdmin) CheckPulsarPackageExist(_ string) (bool, error)

CheckPulsarPackageExist is a fake implements of CheckPulsarPackageExist

func (*DummyPulsarAdmin) CheckPulsarSinkExist added in v0.5.1

func (d *DummyPulsarAdmin) CheckPulsarSinkExist(_, _, _ string) (bool, error)

CheckPulsarSinkExist is a fake implements of CheckPulsarSinkExist

func (*DummyPulsarAdmin) CheckPulsarSourceExist added in v0.5.1

func (d *DummyPulsarAdmin) CheckPulsarSourceExist(_, _, _ string) (bool, error)

CheckPulsarSourceExist is a fake implements of CheckPulsarSourceExist

func (*DummyPulsarAdmin) Close

func (d *DummyPulsarAdmin) Close() error

Close is a fake implements of Close

func (*DummyPulsarAdmin) CreateCluster added in v0.3.0

func (d *DummyPulsarAdmin) CreateCluster(string, *ClusterParams) error

CreateCluster is a fake implements of CreateCluster

func (*DummyPulsarAdmin) CreateNSIsolationPolicy added in v0.6.3

func (d *DummyPulsarAdmin) CreateNSIsolationPolicy(policyName, clusterName string, policyData utils.NamespaceIsolationData) error

func (*DummyPulsarAdmin) DeleteCluster added in v0.3.0

func (d *DummyPulsarAdmin) DeleteCluster(string) error

DeleteCluster is a fake implements of DeleteCluster

func (*DummyPulsarAdmin) DeleteNSIsolationPolicy added in v0.6.3

func (d *DummyPulsarAdmin) DeleteNSIsolationPolicy(policyName, clusterName string) error

func (*DummyPulsarAdmin) DeleteNamespace

func (d *DummyPulsarAdmin) DeleteNamespace(string) error

DeleteNamespace is a fake implements of DeleteNamespace

func (*DummyPulsarAdmin) DeletePulsarFunction added in v0.5.0

func (d *DummyPulsarAdmin) DeletePulsarFunction(_, _, _ string) error

DeletePulsarFunction is a fake implements of DeletePulsarFunction

func (*DummyPulsarAdmin) DeletePulsarPackage added in v0.5.0

func (d *DummyPulsarAdmin) DeletePulsarPackage(_ string) error

DeletePulsarPackage is a fake implements of DeletePulsarPackage

func (*DummyPulsarAdmin) DeletePulsarSink added in v0.5.0

func (d *DummyPulsarAdmin) DeletePulsarSink(_, _, _ string) error

DeletePulsarSink is a fake implements of DeletePulsarSink

func (*DummyPulsarAdmin) DeletePulsarSource added in v0.5.0

func (d *DummyPulsarAdmin) DeletePulsarSource(_, _, _ string) error

DeletePulsarSource is a fake implements of DeletePulsarSource

func (*DummyPulsarAdmin) DeleteSchema added in v0.2.0

func (d *DummyPulsarAdmin) DeleteSchema(string) error

DeleteSchema is a fake implements of DeleteSchema

func (*DummyPulsarAdmin) DeleteTenant

func (d *DummyPulsarAdmin) DeleteTenant(string) error

DeleteTenant is a fake implements of DeleteTenant

func (*DummyPulsarAdmin) DeleteTopic

func (d *DummyPulsarAdmin) DeleteTopic(string) error

DeleteTopic is a fake implements of DeleteTopic

func (*DummyPulsarAdmin) GetNSIsolationPolicy added in v0.6.3

func (d *DummyPulsarAdmin) GetNSIsolationPolicy(policyName, clusterName string) (*utils.NamespaceIsolationData, error)

func (*DummyPulsarAdmin) GetNamespaceClusters added in v0.3.0

func (d *DummyPulsarAdmin) GetNamespaceClusters(string) ([]string, error)

GetNamespaceClusters is a fake implements of GetNamespaceClusters

func (*DummyPulsarAdmin) GetSchema added in v0.2.0

func (d *DummyPulsarAdmin) GetSchema(string) (*v1alpha1.SchemaInfo, error)

GetSchema is a fake implements of GetSchema

func (*DummyPulsarAdmin) GetTenantAllowedClusters added in v0.5.7

func (d *DummyPulsarAdmin) GetTenantAllowedClusters(_ string) ([]string, error)

GetTenantAllowedClusters is a fake implements of GetTenantAllowedClusters

func (*DummyPulsarAdmin) GetTopicClusters added in v0.3.0

func (d *DummyPulsarAdmin) GetTopicClusters(string, *bool) ([]string, error)

GetTopicClusters is a fake implements of GetTopicClusters

func (*DummyPulsarAdmin) GrantPermissions

func (d *DummyPulsarAdmin) GrantPermissions(Permissioner) error

GrantPermissions is a fake implements of GrantPermissions

func (*DummyPulsarAdmin) RevokePermissions

func (d *DummyPulsarAdmin) RevokePermissions(Permissioner) error

RevokePermissions is a fake implements of RevokePermissions

func (*DummyPulsarAdmin) SetNamespaceClusters added in v0.3.0

func (d *DummyPulsarAdmin) SetNamespaceClusters(string, []string) error

SetNamespaceClusters is a fake implements of SetNamespaceClusters

func (*DummyPulsarAdmin) SetTopicClusters added in v0.3.0

func (d *DummyPulsarAdmin) SetTopicClusters(string, *bool, []string) error

SetTopicClusters is a fake implements of SetTopicClusters

func (*DummyPulsarAdmin) UpdateCluster added in v0.3.0

func (d *DummyPulsarAdmin) UpdateCluster(string, *ClusterParams) error

UpdateCluster is a fake implements of UpdateCluster

func (*DummyPulsarAdmin) UploadSchema added in v0.2.0

func (d *DummyPulsarAdmin) UploadSchema(string, *SchemaParams) error

UploadSchema is a fake implements of UploadSchema

type NamespaceParams

type NamespaceParams struct {
	Bundles                     *int32
	MaxProducersPerTopic        *int32
	MaxConsumersPerTopic        *int32
	MaxConsumersPerSubscription *int32
	MessageTTL                  *utils.Duration
	RetentionTime               *utils.Duration
	RetentionSize               *resource.Quantity
	BacklogQuotaLimitTime       *utils.Duration
	BacklogQuotaLimitSize       *resource.Quantity
	BacklogQuotaRetentionPolicy *string
	BacklogQuotaType            *string
	OffloadThresholdTime        *utils.Duration
	OffloadThresholdSize        *resource.Quantity
	ReplicationClusters         []string
	Deduplication               *bool
	BookieAffinityGroup         *v1alpha1.BookieAffinityGroupData
}

NamespaceParams indicates the parameters for creating a namespace

type NamespacePermission

type NamespacePermission struct {
	ResourceName string
	Roles        []string
	Actions      []string
}

NamespacePermission is the parameters to grant permission for a namespace

func (*NamespacePermission) Grant

func (n *NamespacePermission) Grant(client admin.Client) error

Grant implements the grant method for namespace permission

func (*NamespacePermission) Revoke

func (n *NamespacePermission) Revoke(client admin.Client) error

Revoke implements the revoke method for namespace permission

type Permissioner

type Permissioner interface {
	// Grant grants permission to role on a resource
	Grant(client admin.Client) error
	// Revoke revokes permission from role on a resource
	Revoke(client admin.Client) error
}

Permissioner implements the functions to grant and revoke permission for namespace and topic

type PulsarAdmin

type PulsarAdmin interface {
	// ApplyTenant creates or updates a tenant with parameters
	ApplyTenant(name string, params *TenantParams) error

	// DeleteTenant delete a specific tenant
	DeleteTenant(name string) error

	// ApplyNamespace creates a namespace with parameters
	ApplyNamespace(name string, params *NamespaceParams) error

	// DeleteNamespace delete a specific namespace
	DeleteNamespace(name string) error

	// GetNamespaceClusters get the assigned clusters of the namespace to the local default cluster
	GetNamespaceClusters(completeNSName string) ([]string, error)
	// SetNamespaceClusters resets the assigned clusters of the namespace to the local default cluster
	SetNamespaceClusters(name string, clusters []string) error

	// ApplyTopic creates a topic with parameters
	ApplyTopic(name string, params *TopicParams) (error, error)

	// DeleteTopic delete a specific topic
	DeleteTopic(name string) error

	// GetTopicClusters get the assigned clusters of the topic to the local default cluster
	GetTopicClusters(name string, persistent *bool) ([]string, error)
	// SetTopicClusters resets the assigned clusters of the topic to the local default cluster
	SetTopicClusters(name string, persistent *bool, clusters []string) error

	// GrantPermissions grants permissions to multiple role with multiple actions
	// on a namespace or topic, each role will be granted the same actions
	GrantPermissions(p Permissioner) error

	// RevokePermissions revoke permissions from roles on a namespace or topic.
	// it will revoke all actions which granted to a role on a namespace or topic
	RevokePermissions(p Permissioner) error

	// Close releases the connection with pulsar admin
	Close() error

	// GetSchema retrieves the latest schema of a topic
	GetSchema(topic string) (*v1alpha1.SchemaInfo, error)

	// UploadSchema creates or updates a schema for a given topic
	UploadSchema(topic string, params *SchemaParams) error

	// DeleteSchema deletes the schema associated with a given topic
	DeleteSchema(topic string) error

	// CreateCluster creates cluster info
	CreateCluster(name string, param *ClusterParams) error

	// UpdateCluster updates cluster info
	UpdateCluster(name string, param *ClusterParams) error

	// DeleteCluster delete cluster info
	DeleteCluster(name string) error

	// CheckClusterExist check whether the cluster is created or not
	CheckClusterExist(name string) (bool, error)

	// DeletePulsarPackage delete pulsar package
	DeletePulsarPackage(packageURL string) error

	// CheckPulsarPackageExist check whether the package is created or not
	CheckPulsarPackageExist(packageURL string) (bool, error)

	// ApplyPulsarPackage apply pulsar package
	ApplyPulsarPackage(packageURL, filePath, description, contact string, properties map[string]string, changed bool) error

	// DeletePulsarFunction delete pulsar function
	DeletePulsarFunction(tenant, namespace, name string) error

	// CheckPulsarFunctionExist check whether the function is created or not
	CheckPulsarFunctionExist(tenant, namespace, name string) (bool, error)

	// ApplyPulsarFunction apply pulsar function
	ApplyPulsarFunction(tenant, namespace, name, packageURL string, param *v1alpha1.PulsarFunctionSpec, changed bool) error

	// DeletePulsarSink delete pulsar sink
	DeletePulsarSink(tenant, namespace, name string) error

	// CheckPulsarSinkExist check whether the sink is created or not
	CheckPulsarSinkExist(tenant, namespace, name string) (bool, error)

	// ApplyPulsarSink apply pulsar sink
	ApplyPulsarSink(tenant, namespace, name, packageURL string, param *v1alpha1.PulsarSinkSpec, changed bool) error

	// DeletePulsarSource delete pulsar source
	DeletePulsarSource(tenant, namespace, name string) error

	// CheckPulsarSourceExist check whether the source is created or not
	CheckPulsarSourceExist(tenant, namespace, name string) (bool, error)

	// ApplyPulsarSource apply pulsar source
	ApplyPulsarSource(tenant, namespace, name, packageURL string, param *v1alpha1.PulsarSourceSpec, changed bool) error

	// GetTenantAllowedClusters get the allowed clusters of the tenant
	GetTenantAllowedClusters(name string) ([]string, error)

	// GetNSIsolationPolicy get the ns-isolation-policy
	GetNSIsolationPolicy(policyName, clusterName string) (*utils2.NamespaceIsolationData, error)

	// CreateNSIsolationPolicy create a ns-isolation-policy
	CreateNSIsolationPolicy(policyName, clusterName string, policyData utils2.NamespaceIsolationData) error

	// DeleteNSIsolationPolicy delete the ns-isolation-policy
	DeleteNSIsolationPolicy(policyName, clusterName string) error
}

PulsarAdmin is the interface that defines the functions to call pulsar admin

func NewDummyPulsarAdmin

func NewDummyPulsarAdmin(PulsarAdminConfig) (PulsarAdmin, error)

NewDummyPulsarAdmin is a dummy initialization function

func NewPulsarAdmin

func NewPulsarAdmin(conf PulsarAdminConfig) (PulsarAdmin, error)

NewPulsarAdmin initialize a pulsar admin client with configuration

type PulsarAdminClient

type PulsarAdminClient struct {
	// contains filtered or unexported fields
}

PulsarAdminClient define the client to call pulsar

func (*PulsarAdminClient) ApplyNamespace

func (p *PulsarAdminClient) ApplyNamespace(name string, params *NamespaceParams) error

ApplyNamespace creates a namespace with policies

func (*PulsarAdminClient) ApplyPulsarFunction added in v0.5.0

func (p *PulsarAdminClient) ApplyPulsarFunction(tenant, namespace, name, packageURL string, param *v1alpha1.PulsarFunctionSpec, changed bool) error

ApplyPulsarFunction creates or updates a pulsar function

func (*PulsarAdminClient) ApplyPulsarPackage added in v0.5.0

func (p *PulsarAdminClient) ApplyPulsarPackage(packageURL, filePath, description, contact string, properties map[string]string, changed bool) error

ApplyPulsarPackage creates or updates a pulsar package

func (*PulsarAdminClient) ApplyPulsarSink added in v0.5.0

func (p *PulsarAdminClient) ApplyPulsarSink(tenant, namespace, name, packageURL string, param *v1alpha1.PulsarSinkSpec, changed bool) error

ApplyPulsarSink creates or updates a pulsar sink

func (*PulsarAdminClient) ApplyPulsarSource added in v0.5.0

func (p *PulsarAdminClient) ApplyPulsarSource(tenant, namespace, name, packageURL string, param *v1alpha1.PulsarSourceSpec, changed bool) error

ApplyPulsarSource creates or updates a pulsar source

func (*PulsarAdminClient) ApplyTenant

func (p *PulsarAdminClient) ApplyTenant(name string, params *TenantParams) error

ApplyTenant creates or updates a tenant, if AllowdClusters is not provided, it will list all clusters in pular When updates a tenant, If AdminRoles is empty, the current set of roles won't be modified

func (*PulsarAdminClient) ApplyTopic

func (p *PulsarAdminClient) ApplyTopic(name string, params *TopicParams) (creationErr error, policyErr error)

ApplyTopic creates a topic with policies

func (*PulsarAdminClient) CheckClusterExist added in v0.3.0

func (p *PulsarAdminClient) CheckClusterExist(name string) (bool, error)

CheckClusterExist checks whether the cluster exists

func (*PulsarAdminClient) CheckPulsarFunctionExist added in v0.5.1

func (p *PulsarAdminClient) CheckPulsarFunctionExist(tenant, namespace, name string) (bool, error)

CheckPulsarFunctionExist check whether the function is created or not

func (*PulsarAdminClient) CheckPulsarPackageExist added in v0.5.1

func (p *PulsarAdminClient) CheckPulsarPackageExist(packageURL string) (bool, error)

CheckPulsarPackageExist check whether the package is created or not

func (*PulsarAdminClient) CheckPulsarSinkExist added in v0.5.1

func (p *PulsarAdminClient) CheckPulsarSinkExist(tenant, namespace, name string) (bool, error)

CheckPulsarSinkExist check whether the sink is created or not

func (*PulsarAdminClient) CheckPulsarSourceExist added in v0.5.1

func (p *PulsarAdminClient) CheckPulsarSourceExist(tenant, namespace, name string) (bool, error)

CheckPulsarSourceExist check whether the source is created or not

func (*PulsarAdminClient) Close

func (p *PulsarAdminClient) Close() error

Close do nothing for now

func (*PulsarAdminClient) CreateCluster added in v0.3.0

func (p *PulsarAdminClient) CreateCluster(name string, param *ClusterParams) error

CreateCluster creates pulsar cluster

func (*PulsarAdminClient) CreateNSIsolationPolicy added in v0.6.3

func (p *PulsarAdminClient) CreateNSIsolationPolicy(policyName, clusterName string, policyData utils.NamespaceIsolationData) error

CreateNSIsolationPolicy create a ns-isolation-policy

func (*PulsarAdminClient) DeleteCluster added in v0.3.0

func (p *PulsarAdminClient) DeleteCluster(name string) error

DeleteCluster deletes a pulsar cluster

func (*PulsarAdminClient) DeleteNSIsolationPolicy added in v0.6.3

func (p *PulsarAdminClient) DeleteNSIsolationPolicy(policyName, clusterName string) error

DeleteNSIsolationPolicy delete the ns-isolation-policy

func (*PulsarAdminClient) DeleteNamespace

func (p *PulsarAdminClient) DeleteNamespace(name string) error

DeleteNamespace deletes a specific namespace

func (*PulsarAdminClient) DeletePulsarFunction added in v0.5.0

func (p *PulsarAdminClient) DeletePulsarFunction(tenant, namespace, name string) error

DeletePulsarFunction deletes a pulsar function

func (*PulsarAdminClient) DeletePulsarPackage added in v0.5.0

func (p *PulsarAdminClient) DeletePulsarPackage(packageURL string) error

DeletePulsarPackage deletes a pulsar package

func (*PulsarAdminClient) DeletePulsarSink added in v0.5.0

func (p *PulsarAdminClient) DeletePulsarSink(tenant, namespace, name string) error

DeletePulsarSink deletes a pulsar sink

func (*PulsarAdminClient) DeletePulsarSource added in v0.5.0

func (p *PulsarAdminClient) DeletePulsarSource(tenant, namespace, name string) error

DeletePulsarSource deletes a pulsar source

func (*PulsarAdminClient) DeleteSchema added in v0.2.0

func (p *PulsarAdminClient) DeleteSchema(topic string) error

DeleteSchema deletes the schema associated with a given topic

func (*PulsarAdminClient) DeleteTenant

func (p *PulsarAdminClient) DeleteTenant(name string) error

DeleteTenant deletes a specific tenant

func (*PulsarAdminClient) DeleteTopic

func (p *PulsarAdminClient) DeleteTopic(name string) error

DeleteTopic deletes a specific topic

func (*PulsarAdminClient) GetNSIsolationPolicy added in v0.6.3

func (p *PulsarAdminClient) GetNSIsolationPolicy(policyName, clusterName string) (*utils.NamespaceIsolationData, error)

GetNSIsolationPolicy get the ns-isolation-policy

func (*PulsarAdminClient) GetNamespaceClusters added in v0.3.0

func (p *PulsarAdminClient) GetNamespaceClusters(completeNSName string) ([]string, error)

GetNamespaceClusters get the assigned clusters of the namespace to the local default cluster

func (*PulsarAdminClient) GetSchema added in v0.2.0

func (p *PulsarAdminClient) GetSchema(topic string) (*v1alpha1.SchemaInfo, error)

GetSchema get schema info for a given topic

func (*PulsarAdminClient) GetTenantAllowedClusters added in v0.5.7

func (p *PulsarAdminClient) GetTenantAllowedClusters(tenantName string) ([]string, error)

GetTenantAllowedClusters get the allowed clusters of the tenant

func (*PulsarAdminClient) GetTopicClusters added in v0.3.0

func (p *PulsarAdminClient) GetTopicClusters(name string, persistent *bool) ([]string, error)

GetTopicClusters get the assigned clusters of the topic to the local default cluster

func (*PulsarAdminClient) GrantPermissions

func (p *PulsarAdminClient) GrantPermissions(permission Permissioner) error

GrantPermissions grants permissions to multiple role with multiple actions on a namespace or topic, each role will be granted the same actions

func (*PulsarAdminClient) RevokePermissions

func (p *PulsarAdminClient) RevokePermissions(permission Permissioner) error

RevokePermissions revoke permissions from roles on a namespace or topic. it will revoke all actions which granted to a role on a namespace or topic

func (*PulsarAdminClient) SetNamespaceClusters added in v0.3.0

func (p *PulsarAdminClient) SetNamespaceClusters(completeNSName string, clusters []string) error

SetNamespaceClusters resets the assigned clusters of the namespace to the local default cluster

func (*PulsarAdminClient) SetTopicClusters added in v0.3.0

func (p *PulsarAdminClient) SetTopicClusters(name string, persistent *bool, clusters []string) error

SetTopicClusters resets the assigned clusters of the topic to the local default cluster

func (*PulsarAdminClient) UpdateCluster added in v0.3.0

func (p *PulsarAdminClient) UpdateCluster(name string, param *ClusterParams) error

UpdateCluster update pulsar cluster info

func (*PulsarAdminClient) UploadSchema added in v0.2.0

func (p *PulsarAdminClient) UploadSchema(topic string, params *SchemaParams) error

UploadSchema creates or updates a schema for a given topic

type PulsarAdminConfig

type PulsarAdminConfig struct {

	// WebServiceURL to connect to Pulsar.
	WebServiceURL string

	// Set the path to the trusted TLS certificate file
	TLSTrustCertsFilePath string
	// Configure whether the Pulsar client accept untrusted TLS certificate from broker (default: false)
	TLSAllowInsecureConnection bool

	TLSEnableHostnameVerification bool

	// Either Token or OAuth2 configuration must be provided
	// The Token used for authentication.
	Token string

	// OAuth2 related configuration used for authentication.
	IssuerEndpoint string
	ClientID       string
	Audience       string
	Key            string
	Scope          string

	PulsarAPIVersion *config.APIVersion
}

PulsarAdminConfig indicates the configurations which are needed to initialize the pulsar admin

type PulsarAdminCreator

type PulsarAdminCreator func(config PulsarAdminConfig) (PulsarAdmin, error)

PulsarAdminCreator is the function type to create a PulsarAdmin with config

type Reason

type Reason int

Reason indicates the status code

const (
	// ReasonUnauthorized means need to authenticate to perform the operation
	ReasonUnauthorized Reason = 401

	// ReasonForbidden means don't have admin permission for the operation
	ReasonForbidden Reason = 403

	// ReasonNotFound means a resource is not found in Pulsar
	ReasonNotFound Reason = 404

	// ReasonAlreadyExist means a resource already exist in Pulsar
	ReasonAlreadyExist Reason = 409

	// ReasonInvalidParameter means a resource already exist in Pulsar
	// Status code 412
	ReasonInvalidParameter Reason = 412

	// ReasonInternalServerError means Pulsar server fail to handle the request
	// Status code 500
	ReasonInternalServerError Reason = 500

	// ReasonUnknown means error reason is not clear
	ReasonUnknown Reason = 0
)

func ErrorReason

func ErrorReason(err error) Reason

ErrorReason returns the HTTP status code for the error

type SchemaParams added in v0.2.0

type SchemaParams struct {
	// Type determines how to interpret the schema data
	Type string `json:"type,omitempty"`
	// Schema is schema data
	Schema string `json:"schema,omitempty"`
	// Properties is a user defined properties as a string/string map
	Properties map[string]string `json:"properties,omitempty"`
}

SchemaParams indicates the parameters for uploading a schema

type TenantParams

type TenantParams struct {
	AdminRoles      []string
	AllowedClusters []string
	Changed         bool
}

TenantParams indicates the parameters for creating a tenant

type TopicParams

type TopicParams struct {
	Persistent                        *bool
	Partitions                        *int32
	MaxProducers                      *int32
	MaxConsumers                      *int32
	MessageTTL                        *utils.Duration
	MaxUnAckedMessagesPerConsumer     *int32
	MaxUnAckedMessagesPerSubscription *int32
	RetentionTime                     *utils.Duration
	RetentionSize                     *resource.Quantity
	BacklogQuotaLimitTime             *utils.Duration
	BacklogQuotaLimitSize             *resource.Quantity
	BacklogQuotaRetentionPolicy       *string
	ReplicationClusters               []string
	Deduplication                     *bool
}

TopicParams indicates the parameters for creating a topic

type TopicPermission

type TopicPermission struct {
	ResourceName string
	Roles        []string
	Actions      []string
}

TopicPermission is the parameters to grant permission for a topic

func (*TopicPermission) Grant

func (t *TopicPermission) Grant(client admin.Client) error

Grant implements the grant method for topic permission

func (*TopicPermission) Revoke

func (t *TopicPermission) Revoke(client admin.Client) error

Revoke implements the revoke method for topic permission

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL