Documentation ¶
Overview ¶
Package admin implements the functions to call pulsar admin
Index ¶
- Constants
- func IsAlreadyExist(err error) bool
- func IsInternalServerError(err error) bool
- func IsNotFound(err error) bool
- func IsPermissionNotFound(err error) bool
- type ClusterParams
- type DummyPulsarAdmin
- func (d *DummyPulsarAdmin) ApplyNamespace(name string, params *NamespaceParams) error
- func (d *DummyPulsarAdmin) ApplyTenant(name string, params *TenantParams) error
- func (d *DummyPulsarAdmin) ApplyTopic(name string, params *TopicParams) error
- func (d *DummyPulsarAdmin) CheckClusterExist(name string) (bool, error)
- func (d *DummyPulsarAdmin) Close() error
- func (d *DummyPulsarAdmin) CreateCluster(name string, param *ClusterParams) error
- func (d *DummyPulsarAdmin) DeleteCluster(name string) error
- func (d *DummyPulsarAdmin) DeleteNamespace(name string) error
- func (d *DummyPulsarAdmin) DeleteSchema(topic string) error
- func (d *DummyPulsarAdmin) DeleteTenant(name string) error
- func (d *DummyPulsarAdmin) DeleteTopic(name string) error
- func (d *DummyPulsarAdmin) GetNamespaceClusters(name string) ([]string, error)
- func (d *DummyPulsarAdmin) GetSchema(topic string) (*v1alpha1.SchemaInfo, error)
- func (d *DummyPulsarAdmin) GetTopicClusters(name string, persistent *bool) ([]string, error)
- func (d *DummyPulsarAdmin) GrantPermissions(p Permissioner) error
- func (d *DummyPulsarAdmin) RevokePermissions(p Permissioner) error
- func (d *DummyPulsarAdmin) SetNamespaceClusters(name string, clusters []string) error
- func (d *DummyPulsarAdmin) SetTopicClusters(name string, persistent *bool, clusters []string) error
- func (d *DummyPulsarAdmin) UpdateCluster(name string, param *ClusterParams) error
- func (d *DummyPulsarAdmin) UploadSchema(topic string, params *SchemaParams) error
- type NamespaceParams
- type NamespacePermission
- type Permissioner
- type PulsarAdmin
- type PulsarAdminClient
- func (p *PulsarAdminClient) ApplyNamespace(name string, params *NamespaceParams) error
- func (p *PulsarAdminClient) ApplyTenant(name string, params *TenantParams) error
- func (p *PulsarAdminClient) ApplyTopic(name string, params *TopicParams) error
- func (p *PulsarAdminClient) CheckClusterExist(name string) (bool, error)
- func (p *PulsarAdminClient) Close() error
- func (p *PulsarAdminClient) CreateCluster(name string, param *ClusterParams) error
- func (p *PulsarAdminClient) DeleteCluster(name string) error
- func (p *PulsarAdminClient) DeleteNamespace(name string) error
- func (p *PulsarAdminClient) DeleteSchema(topic string) error
- func (p *PulsarAdminClient) DeleteTenant(name string) error
- func (p *PulsarAdminClient) DeleteTopic(name string) error
- func (p *PulsarAdminClient) GetNamespaceClusters(completeNSName string) ([]string, error)
- func (p *PulsarAdminClient) GetSchema(topic string) (*v1alpha1.SchemaInfo, error)
- func (p *PulsarAdminClient) GetTopicClusters(name string, persistent *bool) ([]string, error)
- func (p *PulsarAdminClient) GrantPermissions(permission Permissioner) error
- func (p *PulsarAdminClient) RevokePermissions(permission Permissioner) error
- func (p *PulsarAdminClient) SetNamespaceClusters(completeNSName string, clusters []string) error
- func (p *PulsarAdminClient) SetTopicClusters(name string, persistent *bool, clusters []string) error
- func (p *PulsarAdminClient) UpdateCluster(name string, param *ClusterParams) error
- func (p *PulsarAdminClient) UploadSchema(topic string, params *SchemaParams) error
- type PulsarAdminConfig
- type PulsarAdminCreator
- type Reason
- type SchemaParams
- type TenantParams
- type TopicParams
- type TopicPermission
Constants ¶
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 ¶
IsAlreadyExist returns true if the error indicates the resource already exist
func IsInternalServerError ¶
IsInternalServerError returns true if the error indicates the resource already exist
func IsNotFound ¶
IsNotFound returns true if the error indicates the resource is not found on server
func IsPermissionNotFound ¶
IsPermissionNotFound returns true if the permission is not set
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(name string, params *NamespaceParams) error
ApplyNamespace is a fake implements of ApplyNamespace
func (*DummyPulsarAdmin) ApplyTenant ¶
func (d *DummyPulsarAdmin) ApplyTenant(name string, params *TenantParams) error
ApplyTenant is a fake implements of ApplyTenant
func (*DummyPulsarAdmin) ApplyTopic ¶
func (d *DummyPulsarAdmin) ApplyTopic(name string, params *TopicParams) error
ApplyTopic is a fake implements of ApplyTopic
func (*DummyPulsarAdmin) CheckClusterExist ¶ added in v0.3.0
func (d *DummyPulsarAdmin) CheckClusterExist(name string) (bool, error)
CheckClusterExist checks whether the cluster exists
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(name string, param *ClusterParams) error
CreateCluster is a fake implements of CreateCluster
func (*DummyPulsarAdmin) DeleteCluster ¶ added in v0.3.0
func (d *DummyPulsarAdmin) DeleteCluster(name string) error
DeleteCluster is a fake implements of DeleteCluster
func (*DummyPulsarAdmin) DeleteNamespace ¶
func (d *DummyPulsarAdmin) DeleteNamespace(name string) error
DeleteNamespace is a fake implements of DeleteNamespace
func (*DummyPulsarAdmin) DeleteSchema ¶ added in v0.2.0
func (d *DummyPulsarAdmin) DeleteSchema(topic string) error
DeleteSchema is a fake implements of DeleteSchema
func (*DummyPulsarAdmin) DeleteTenant ¶
func (d *DummyPulsarAdmin) DeleteTenant(name string) error
DeleteTenant is a fake implements of DeleteTenant
func (*DummyPulsarAdmin) DeleteTopic ¶
func (d *DummyPulsarAdmin) DeleteTopic(name string) error
DeleteTopic is a fake implements of DeleteTopic
func (*DummyPulsarAdmin) GetNamespaceClusters ¶ added in v0.3.0
func (d *DummyPulsarAdmin) GetNamespaceClusters(name string) ([]string, error)
GetNamespaceClusters is a fake implements of GetNamespaceClusters
func (*DummyPulsarAdmin) GetSchema ¶ added in v0.2.0
func (d *DummyPulsarAdmin) GetSchema(topic string) (*v1alpha1.SchemaInfo, error)
GetSchema is a fake implements of GetSchema
func (*DummyPulsarAdmin) GetTopicClusters ¶ added in v0.3.0
func (d *DummyPulsarAdmin) GetTopicClusters(name string, persistent *bool) ([]string, error)
GetTopicClusters is a fake implements of GetTopicClusters
func (*DummyPulsarAdmin) GrantPermissions ¶
func (d *DummyPulsarAdmin) GrantPermissions(p Permissioner) error
GrantPermissions is a fake implements of GrantPermissions
func (*DummyPulsarAdmin) RevokePermissions ¶
func (d *DummyPulsarAdmin) RevokePermissions(p Permissioner) error
RevokePermissions is a fake implements of RevokePermissions
func (*DummyPulsarAdmin) SetNamespaceClusters ¶ added in v0.3.0
func (d *DummyPulsarAdmin) SetNamespaceClusters(name string, clusters []string) error
SetNamespaceClusters is a fake implements of SetNamespaceClusters
func (*DummyPulsarAdmin) SetTopicClusters ¶ added in v0.3.0
func (d *DummyPulsarAdmin) SetTopicClusters(name string, persistent *bool, clusters []string) error
SetTopicClusters is a fake implements of SetTopicClusters
func (*DummyPulsarAdmin) UpdateCluster ¶ added in v0.3.0
func (d *DummyPulsarAdmin) UpdateCluster(name string, param *ClusterParams) error
UpdateCluster is a fake implements of UpdateCluster
func (*DummyPulsarAdmin) UploadSchema ¶ added in v0.2.0
func (d *DummyPulsarAdmin) UploadSchema(topic string, params *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 ReplicationClusters []string }
NamespaceParams indicates the parameters for creating a namespace
type NamespacePermission ¶
NamespacePermission is the parameters to grant permission for a namespace
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 // 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 wether the cluster is created or not CheckClusterExist(name string) (bool, error) }
PulsarAdmin is the interface that defines the functions to call pulsar admin
func NewDummyPulsarAdmin ¶
func NewDummyPulsarAdmin(config 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) 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) 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) 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) DeleteCluster ¶ added in v0.3.0
func (p *PulsarAdminClient) DeleteCluster(name string) error
DeleteCluster deletes a pulsar cluster
func (*PulsarAdminClient) DeleteNamespace ¶
func (p *PulsarAdminClient) DeleteNamespace(name string) error
DeleteNamespace deletes a specific namespace
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) 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) 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 }
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 ( 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 )ReasonUnauthorized
func ErrorReason ¶
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 ¶
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 }
TopicParams indicates the parameters for creating a topic
type TopicPermission ¶
TopicPermission is the parameters to grant permission for a topic