notifier

package
v0.0.0-...-5951314 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventingAdminService = "eventingAdminPort"
	EventingAdminSSL     = "eventingSSL"
	DataService          = "kv"
	DataServiceSSL       = "kvSSL"
	MgmtService          = "mgmt"
	MgmtServiceSSL       = "mgmtSSL"
)
View Source
const (
	EncryptionLevel   = string("encryption level changed")
	CertificateChange = string("certificate changed")
	TLSConfigChange   = string("tls config changed")
)

Filter for tls changes This can't be used in interested event Client filter it out based on their needs

View Source
const (
	// EventKVTopologyChanges represents subscriber is interested in Eventing
	// topology changes
	EventKVTopologyChanges eventType = iota // Node

	// EventQueryTopologyChanges represents subscriber is interested in Query
	// topology changes
	EventQueryTopologyChanges // Node

	// EventEventingTopologyChanges represents subscriber is interested in Eventing
	// topology changes
	EventEventingTopologyChanges // Node

	// EventVbmapChanges represents subscriber is interested in vb map
	// changes. Filter should be provided when vb map for a particular bucket.
	// empty filter means changes to all the bucket
	EventVbmapChanges // *VBmap

	// EventBucketList represents subscriber is interested in bucket list changes
	EventBucketListChanges // map[string]string

	// EventBucketChanges represents subscriber is interested in bucket given in filter changes.
	// filter should be provided when bucket changes need to be observed for particular
	EventBucketChanges // Buckets

	// EventScopeOrCollectionChanges represents subscriber is interested in collection manifest id changes
	// Filter should be provided when collection manifest changes to be observe for particular
	// bucket. Empty means changes to all bucket
	EventScopeOrCollectionChanges // CollectionManifest

	// EventClusterCompatibilityChanges represents subscriber is interested in cluster compatibility
	// changes
	EventClusterCompatibilityChanges // ClusterCompatibility

	// EventTLSChanges represents subscriber is interested in changes in tls settings
	EventTLSChanges
)
View Source
const (
	// EventChangeAdded represents something added to the respective eventType
	EventChangeAdded transition = iota

	// EventChangeRemoved represents something is removed from the respective eventType
	EventChangeRemoved

	// EventTransition represents something is moved
	EventTransition
)
View Source
const (
	// NOT_OWNED is used to indicate that the vbucket is not owned by any node
	NOT_OWNED = -1
)
View Source
const (
	NodeStatusHealthy = "healthy"
)

Variables

View Source
var (
	ErrFilterNotFound    = errors.New("filter not present")
	ErrInvalidSubscriber = errors.New("not subscriber object")
)
View Source
var (
	ErrBucketDeleted = errors.New("Bucket doesn't exist")
)

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Name           string `json:"name"`
	BucketType     string `json:"bucketType"`
	UUID           string `json:"uuid"`
	StorageBackend string `json:"storageBackend"`
	NumVbucket     int    `json:"numVBuckets"`
}

Bucket represents a bucket in the cluster

func DiffBuckets

func DiffBuckets(A []*Bucket, B []*Bucket) []*Bucket

DiffBuckets returns buckets which are present in A but not in B based on bucket UUID

func (*Bucket) Copy

func (b *Bucket) Copy() *Bucket

Copy will deep copy the Bucket struct

func (*Bucket) String

func (b *Bucket) String() string

type ClientTlsConfig

type ClientTlsConfig struct {
	// UseClientCert is true when N2N encryption is all/strict and client auth type is hybrid/mandatory
	UseClientCert              bool
	ClientCertificate          *tls.Certificate
	ClientPrivateKeyPassphrase string
}

type Collection

type Collection struct {
	CID string
}

Collection represents the collection details

func (*Collection) Copy

func (collection *Collection) Copy() *Collection

Copy will deep copy the Collection struct

func (*Collection) String

func (c *Collection) String() string

type CollectionManifest

type CollectionManifest struct {
	MID    string
	Scopes map[string]*Scope
}

CollectionManifest represents the collection manifest

func DiffCollectionManifest

func DiffCollectionManifest(A *CollectionManifest, B *CollectionManifest) *CollectionManifest

DiffCollectionManifest returns collections which are in A but not in B. Uid field contains of As. This will also take care of recreated scope/collections in A

func (*CollectionManifest) Copy

func (manifest *CollectionManifest) Copy() *CollectionManifest

Copy will deep copy the CollectionManifest struct

func (*CollectionManifest) String

func (cm *CollectionManifest) String() string

type InterestedEvent

type InterestedEvent struct {
	// Event specifies which event type to be subscribed
	Event eventType

	// Filter specifies additional filtering of events
	// For those event type where filtering is not allowed Register will return error
	Filter string
}

InterestedEvent is passed to Subscriber for listening changes for events This will be returned in the WaitForEvent to differentiate between different events

func (InterestedEvent) String

func (i InterestedEvent) String() string

type Node

type Node struct {
	ThisNode             bool
	Status               string
	NodeUUID             string
	ClusterCompatibility *Version

	// Services provides the services to port mapping
	Services map[string]int

	// Contains the dns/ip address
	HostName         string
	ExternalHostName string
	NodeEncryption   bool
}

Node specifies details of the node

func DiffNodes

func DiffNodes(A []*Node, B []*Node) []*Node

DiffNodes returns node which are present in A but not in B based on node uuid

func (*Node) Copy

func (n *Node) Copy() *Node

Copy will deep copy the Node struct

func (*Node) String

func (n *Node) String() string

type NodeAddress

type NodeAddress struct {
	NonSSLAddress string
	SSLAddress    string
}

func (*NodeAddress) String

func (na *NodeAddress) String() string

type Observer

type Observer interface {
	// GetSubscriberObject returns a empty subscriber interface
	GetSubscriberObject() Subscriber

	// RegisterForEvents subscribes for receiving changes for interestedEvent
	// It can be called multiple times to register for different events
	// It will return Current state of the interested event
	RegisterForEvents(Subscriber, InterestedEvent) (interface{}, error)

	// DeregisterEvent removes InterestedEvent from Subscriber
	// These events won't be given in WaitForEvent once this function completes
	DeregisterEvent(Subscriber, InterestedEvent)

	// GetCurrentState returns the current state of the InterestedEvent
	// returns error if InterestEvent doesn't exist
	GetCurrentState(InterestedEvent) (interface{}, error)

	// Block till we sync with the ns_server
	WaitForConnect(ctx context.Context)
}

func NewObserver

func NewObserver(settings *TLSClusterConfig, restAddress string, isIpv4 bool) (Observer, error)

NewObserver creates a new observer if not already created on default pool which can be used to create subscriber

func NewObserverForPool

func NewObserverForPool(settings *TLSClusterConfig, poolName, restAddress string, isIpv4 bool) (Observer, error)

NewObserverForPool creates a new observer on a given pool which can be used to create subscriber

type Scope

type Scope struct {
	SID         string
	Collections map[string]*Collection
}

Scope represents scope details

func (*Scope) Copy

func (scope *Scope) Copy() *Scope

Copy will deep copy the Scope struct

func (*Scope) String

func (s *Scope) String() string

type Subscriber

type Subscriber interface {
	// WaitForEvent is a blocking call. It will be blocked till
	// some change event is called
	// nil Transition event suggest no more event coming for this subscriber
	// Its good practice to delete all the subscribed events when
	// TransitionEvent is nil
	WaitForEvent() <-chan *TransitionEvent
}

Subscriber is returned by Observer interface to wait for any changes it will return any changes in the cluster which it subscribed

type TLSClusterConfig

type TLSClusterConfig struct {
	SslCAFile      string
	SslCertFile    string
	SslKeyFile     string
	ClientKeyFile  string
	ClientCertFile string
}

type TlsConfig

type TlsConfig struct {
	Config             *tls.Config
	EncryptData        bool
	DisableNonSSLPorts bool
	ClientTlsConfig
}

func (*TlsConfig) Copy

func (config *TlsConfig) Copy() *TlsConfig

func (*TlsConfig) String

func (t *TlsConfig) String() string

type TransitionEvent

type TransitionEvent struct {
	Event InterestedEvent

	CurrentState interface{}
	Transition   map[transition]interface{}

	// If filter is deleted then this will be set to true
	Deleted bool
}

func (*TransitionEvent) String

func (t *TransitionEvent) String() string

type VBmap

type VBmap struct {
	// ServerList represents kv node address
	ServerList []NodeAddress

	// VbToKv is the mapping of vb to active kvnode index
	// kvNode address can be found out by ServerList
	// If VbToKv doesn't contain vb then that vb isn't
	// active on any kv node.
	VbToKv map[uint16]int
}

VBmap represents vbucket to kv mapping

func DiffVBMap

func DiffVBMap(A *VBmap, B *VBmap) *VBmap

DiffVBMap returns VBmap in which ServerList is of A And VbToKv contains vb to kv index whose nodes got changed

func NewVbucketMap

func NewVbucketMap(terseBytes []byte, isIpv4 bool) *VBmap

func (*VBmap) Copy

func (vbMap *VBmap) Copy() *VBmap

Copy will deep copy the VBmap struct

func (*VBmap) String

func (vm *VBmap) String() string

type Version

type Version struct {
	Minor        int
	Major        int
	MpVersion    int
	IsEnterprise bool
}

Version represents version of the node

func FrameCouchbaseVersionShort

func FrameCouchbaseVersionShort(ver string) (version *Version)

func VersionFromString

func VersionFromString(ver string) *Version

Required string is evt-[shortversion]-[buildNumber]-[enterprise]

func (Version) Compare

func (v1 Version) Compare(v2 Version) bool

v1 <= v2

func (*Version) CompatVersion

func (v *Version) CompatVersion() *Version

func (*Version) Copy

func (ver *Version) Copy() *Version

Copy will deep copy the Version struct

func (Version) Equals

func (v1 Version) Equals(v2 *Version) bool

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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