Documentation ¶
Index ¶
- Constants
- Variables
- type AnalyticsHookFunc
- type AnalyticsHookManager
- type AnalyticsService
- type Bucket
- type BucketStore
- type BucketType
- type Cluster
- type ClusterNode
- type ClusterNodeFeature
- type CollectionManifest
- func (m *CollectionManifest) AddCollection(scope, collection string, maxTTL uint32) (uint64, error)
- func (m *CollectionManifest) AddScope(scope string) (uint64, error)
- func (m *CollectionManifest) DropCollection(scope, collection string) (uint64, error)
- func (m *CollectionManifest) DropScope(scope string) (uint64, error)
- func (m *CollectionManifest) GetByID(collectionID uint32) (string, string)
- func (m *CollectionManifest) GetByName(scope, collection string) (uint64, uint32, error)
- func (m *CollectionManifest) GetManifest() (uint64, []CollectionManifestScope)
- type CollectionManifestCollection
- type CollectionManifestScope
- type CompressionMode
- type ConfigWatcher
- type ErrorMap
- type ErrorMapError
- type ErrorMapRetry
- type HTTPRequest
- type HTTPResponse
- type KvClient
- type KvHookFunc
- type KvHookManager
- type KvService
- type MgmtHookFunc
- type MgmtHookManager
- type MgmtService
- type NewBucketOptions
- type NewClusterOptions
- type NewNodeOptions
- type QueryHookFunc
- type QueryHookManager
- type QueryService
- type SearchHookFunc
- type SearchHookManager
- type SearchService
- type ServiceType
- type UpdateBucketOptions
- type UserManager
- type ViewHookFunc
- type ViewHookManager
- type ViewIndexManager
- type ViewService
Constants ¶
const ( BucketTypeMemcached = BucketType(1) BucketTypeCouchbase = BucketType(2) BucketTypeEphemeral = BucketType(3) BucketTypeMemcachedString = "memcached" BucketTypeCouchbaseString = "membase" BucketTypeEphemeralString = "ephemeral" )
The following lists the possible bucket types
const ( ClusterNodeFeatureDurations = "durations" ClusterNodeFeatureTLS = "tls" )
The following is a list of possible cluster features
const ( ServiceTypeMgmt = ServiceType(1) ServiceTypeKeyValue = ServiceType(2) ServiceTypeViews = ServiceType(3) ServiceTypeQuery = ServiceType(4) ServiceTypeSearch = ServiceType(5) ServiceTypeAnalytics = ServiceType(6) )
This represents the various service types that a particular node could have enabled.
Variables ¶
var ( ErrScopeExists = errors.New("scope already exists") ErrCollectionExists = errors.New("collection already exists") ErrScopeNotFound = errors.New("scope not found") ErrCollectionNotFound = errors.New("collection not found") )
A few errors that can be produced by collection manifest utilities.
Functions ¶
This section is empty.
Types ¶
type AnalyticsHookFunc ¶
type AnalyticsHookFunc func(source AnalyticsService, req *HTTPRequest, next func() *HTTPResponse) *HTTPResponse
AnalyticsHookFunc implements a hook for handling a query request. NOTE: It is safe and expected that a hook may alter the packet.
type AnalyticsHookManager ¶
type AnalyticsHookManager interface { // Child returns a child hook manager to this hook manager. Child() AnalyticsHookManager // Add adds a new hook at the end of the processing chain. Add(fn AnalyticsHookFunc) // Destroy removes all this managers hooks from the root manager. Destroy() }
AnalyticsHookManager implements a tree of hooks which can handle an analytics request.
type AnalyticsService ¶
type AnalyticsService interface { // Node returns the node which owns this service. Node() ClusterNode // Hostname returns the hostname where this service can be accessed. Hostname() string // ListenPort returns the port this service is listening on. ListenPort() int // ListenPortTLS returns the TLS port this service is listening on. ListenPortTLS() int // Close will shut down this service once it is no longer needed. Close() error // CheckAuthenticated verifies that the currently authenticated user has the specified permissions. CheckAuthenticated(permission mockauth.Permission, bucket, scope, collection string, request *HTTPRequest) bool }
AnalyticsService represents a analytics service running somewhere in the cluster.
type Bucket ¶
type Bucket interface { // ID returns the uuid of this bucket. ID() string // Name returns the name of this bucket Name() string // BucketType returns the type of bucket this is. BucketType() BucketType // NumReplicas returns the number of configured replicas for this bucket NumReplicas() uint // ConfigRev returns the current configuration revision for this bucket. ConfigRev() uint // CollectionManifest returns the collection manifest of this bucket. CollectionManifest() *CollectionManifest // Store returns the data-store for this bucket. Store() *mockdb.Bucket // UpdateVbMap will update the vbmap such that all vbuckets are assigned to the // specific nodes which are passed in. Note that this rebalance is guarenteed to // be very explicit such that vbNode = (vbId % numNode), and replicas are just ++. UpdateVbMap(nodeList []string) // GetVbServerInfo returns the vb nodes, then the vb map, then the ordered list of all nodes GetVbServerInfo(reqNode ClusterNode) ([]ClusterNode, [][]int, []ClusterNode) // VbucketOwnership returns the replica index associated with the provided node. // A response of -1 means it does not own any replicas for that vbucket. VbucketOwnership(node ClusterNode) []int // ViewIndexManager returns the view index manager for this bucket. ViewIndexManager() ViewIndexManager // Flush will remove all items from containing vbuckets and reset the high seq no. // Returning true if the flush was successful. Flush() // FlushEnabled returns whether or not flush is enabled for this bucket. FlushEnabled() bool // RamQuota returns the ram quota assigned to this bucket. RamQuota() uint64 // ReplicaIndexEnabled returns whether or not replica index is enabled for this bucket. ReplicaIndexEnabled() bool // Update updates the settings for this bucket. Update(opts UpdateBucketOptions) error // CompressionMode returns the compression mode used by this bucket. CompressionMode() CompressionMode }
Bucket represents an instance of a bucket.
type BucketStore ¶
type BucketType ¶
type BucketType uint
BucketType specifies the type of bucket
func BucketTypeFromString ¶
func BucketTypeFromString(bucketTypeString string) BucketType
func (BucketType) Name ¶
func (b BucketType) Name() string
type Cluster ¶
type Cluster interface { // ID returns the uuid of this cluster. ID() string // ConfigRev returns the current configuration revision for this cluster. ConfigRev() uint // AddNode will add a new node to a cluster. AddNode(opts NewNodeOptions) (ClusterNode, error) // AddBucket will add a new bucket to a cluster. AddBucket(opts NewBucketOptions) (Bucket, error) // DeleteBucket will remove a bucket from a cluster. DeleteBucket(name string) error // Nodes returns a list of all the nodes in this cluster. Nodes() []ClusterNode // GetBucket will return a specific bucket from the cluster. GetBucket(name string) Bucket // GetAllBuckets will return all buckets from the cluster. GetAllBuckets() []Bucket // ConnectionString returns the basic non-TLS connection string for this cluster. ConnectionString() string // MgmtHosts returns a list of non-TLS mgmt endpoints for this cluster. MgmtAddrs() []string // KvInHooks returns the hook manager for incoming kv packets. KvInHooks() KvHookManager // KvOutHooks returns the hook manager for outgoing kv packets. KvOutHooks() KvHookManager // MgmtHooks returns the hook manager for management requests. MgmtHooks() MgmtHookManager // Chrono returns the chrono object in use by the cluster. Chrono() *mocktime.Chrono // Users returns the user service for the cluster. Users() UserManager // AddConfigWatcher adds a watcher for any configs that come in. AddConfigWatcher(ConfigWatcher) // RemoveConfigWatcher remover a config watcher. RemoveConfigWatcher(ConfigWatcher) }
Cluster represents an instance of a mock cluster
type ClusterNode ¶
type ClusterNode interface { // ID returns the uuid of this node. ID() string // Cluster returns the Cluster this node is part of. Cluster() Cluster // KvService returns the kv service for this node. KvService() KvService // MgmtService returns the mgmt service for this node. MgmtService() MgmtService // ViewService returns the views service for this node. ViewService() ViewService // QueryService returns the query service for this node. QueryService() QueryService // SearchService returns the search service for this node. SearchService() SearchService // AnalyticsService returns the analytics service for this node. AnalyticsService() AnalyticsService // ErrorMap returns the error map for this node. ErrorMap() *ErrorMap // HostName returns the address for this node. Hostname() string }
ClusterNode specifies a node within a cluster instance.
type ClusterNodeFeature ¶
type ClusterNodeFeature string
ClusterNodeFeature specifies a specific cluster feature
type CollectionManifest ¶
type CollectionManifest struct { Rev uint64 Scopes map[uint32]*collectionManifestScopeEntry Collections map[uint32]*collectionManifestCollectionEntry // contains filtered or unexported fields }
CollectionManifest represents one version of a collection manifest
func NewCollectionManifest ¶
func NewCollectionManifest() *CollectionManifest
NewCollectionManifest creates a new collection manifest.
func (*CollectionManifest) AddCollection ¶
func (m *CollectionManifest) AddCollection(scope, collection string, maxTTL uint32) (uint64, error)
AddCollection adds a new collection to the manifest.
func (*CollectionManifest) AddScope ¶
func (m *CollectionManifest) AddScope(scope string) (uint64, error)
AddScope adds a new scope to the manifest.
func (*CollectionManifest) DropCollection ¶
func (m *CollectionManifest) DropCollection(scope, collection string) (uint64, error)
DropCollection removes a collection from the manifest.
func (*CollectionManifest) DropScope ¶
func (m *CollectionManifest) DropScope(scope string) (uint64, error)
DropScope removes a scope from the manifest.
func (*CollectionManifest) GetByID ¶
func (m *CollectionManifest) GetByID(collectionID uint32) (string, string)
GetByID returns the scope name and collection name for a particular ID. It returns two blank strings if the ID was not found.
func (*CollectionManifest) GetByName ¶
func (m *CollectionManifest) GetByName(scope, collection string) (uint64, uint32, error)
GetByName retrieves a collection uid by scope and collection name.
func (*CollectionManifest) GetManifest ¶
func (m *CollectionManifest) GetManifest() (uint64, []CollectionManifestScope)
GetManifest gets the current manifest represented as a list of scopes, including collections, and the manifest uid.
type CollectionManifestCollection ¶
CollectionManifestCollection represents a collection in a collection manifest.
type CollectionManifestScope ¶
type CollectionManifestScope struct { Name string UID uint32 Collections []CollectionManifestCollection }
CollectionManifestScope represents a scope in a collection manifest.
type CompressionMode ¶
type CompressionMode string
CompressionMode specifies the kind of compression to use for a bucket.
const ( // CompressionModeOff specifies to use no compression for a bucket. CompressionModeOff CompressionMode = "off" // CompressionModePassive specifies to use passive compression for a bucket. CompressionModePassive CompressionMode = "passive" // CompressionModeActive specifies to use active compression for a bucket. CompressionModeActive CompressionMode = "active" )
type ConfigWatcher ¶
type ConfigWatcher interface {
OnNewConfig(cfg uint)
}
type ErrorMap ¶
type ErrorMap struct { Version int `json:"version"` Revision int `json:"revision"` Errors map[string]ErrorMapError `json:"errors"` }
ErrorMap specifies a collection of ErrorMapErrors.
type ErrorMapError ¶
type ErrorMapError struct { Name string `json:"name"` Desc string `json:"desc"` Attrs []string `json:"attrs"` Retry *ErrorMapRetry `json:"retry,omitempty"` }
ErrorMapError specifies a specific error.
type ErrorMapRetry ¶
type ErrorMapRetry struct { Strategy string `json:"strategy"` Interval int `json:"interval"` After int `json:"after"` MaxDuration int `json:"max-duration"` Ceil int `json:"ceil,omitempty"` }
ErrorMapRetry specifies a specific error retry strategy.
type HTTPRequest ¶
type HTTPRequest struct { IsTLS bool Method string URL *url.URL Header http.Header Body io.Reader Form url.Values Context context.Context Flusher http.Flusher }
HTTPRequest encapsulates an HTTP request.
func (*HTTPRequest) PeekBody ¶
func (r *HTTPRequest) PeekBody() []byte
PeekBody will return the full body and swap the reader with a new one which will allow other users to continue to use it.
type HTTPResponse ¶
HTTPResponse encapsulates an HTTP response.
func (*HTTPResponse) PeekBody ¶
func (r *HTTPResponse) PeekBody() []byte
PeekBody will return the full body and swap the reader with a new one which will allow other users to continue to use it.
type KvClient ¶
type KvClient interface { // LocalAddr returns the local address of this client. LocalAddr() net.Addr // RemoteAddr returns the remote address of this client. RemoteAddr() net.Addr // IsTLS returns whether this client is connected via TLS IsTLS() bool // Source returns the KvService which owns this client. Source() KvService // ScramServer returns a SCRAM server object specific to this user. ScramServer() *scramserver.ScramServer // SetAuthenticatedUserName sets the name of the user who is authenticated. SetAuthenticatedUserName(userName string) // AuthenticatedUserName gets the name of the user who is authenticated. AuthenticatedUserName() string // CheckAuthenticated verifies that the currently authenticated user has the specified permissions. CheckAuthenticated(permission mockauth.Permission, collectionID uint32) bool // SetSelectedBucketName sets the currently selected bucket's name. SetSelectedBucketName(bucketName string) // SelectedBucketName returns the currently selected bucket's name. SelectedBucketName() string // SelectedBucket returns the currently selected bucket. SelectedBucket() Bucket // SetFeatures sets the list of support features for this client. SetFeatures(features []memd.HelloFeature) // HasFeature indicates whether or not this client supports a feature. HasFeature(feature memd.HelloFeature) bool // WritePacket tries to write data to the underlying connection. WritePacket(pak *memd.Packet) error // Close attempts to close the connection. Close() error }
KvClient represents all the state about a connected kv client.
type KvHookFunc ¶
KvHookFunc implements a hook for handling a kv packet. NOTE: It is safe and expected that a hook may alter the packet.
type KvHookManager ¶
type KvHookManager interface { // Child returns a child hook manager to this hook manager. Child() KvHookManager // Add adds a new hook at the end of the processing chain. Add(fn KvHookFunc) // Destroy removes all this managers hooks from the root manager. Destroy() }
KvHookManager implements a tree of hooks which can handle a kv packet.
type KvService ¶
type KvService interface { // Node returns the ClusterNode which owns this service. Node() ClusterNode // Hostname returns the hostname where this service can be accessed. Hostname() string // ListenPort returns the port this service is listening on. ListenPort() int // ListenPortTLS returns the TLS port this service is listening on. ListenPortTLS() int // GetAllClients returns a list of all the clients connected to this service. GetAllClients() []KvClient // Close will shut down this service once it is no longer needed. Close() error }
KvService represents an instance of the kv service.
type MgmtHookFunc ¶
type MgmtHookFunc func(source MgmtService, req *HTTPRequest, next func() *HTTPResponse) *HTTPResponse
MgmtHookFunc implements a hook for handling a mgmt request. NOTE: It is safe and expected that a hook may alter the packet.
type MgmtHookManager ¶
type MgmtHookManager interface { // Child returns a child hook manager to this hook manager. Child() MgmtHookManager // Add adds a new hook at the end of the processing chain. Add(fn MgmtHookFunc) // Destroy removes all this managers hooks from the root manager. Destroy() }
MgmtHookManager implements a tree of hooks which can handle a mgmt request.
type MgmtService ¶
type MgmtService interface { // Node returns the node which owns this service. Node() ClusterNode // Hostname returns the hostname where this service can be accessed. Hostname() string // ListenPort returns the port this service is listening on. ListenPort() int // ListenPortTLS returns the TLS port this service is listening on. ListenPortTLS() int // Close will shut down this service once it is no longer needed. Close() error // CheckAuthenticated verifies that the currently authenticated user has the specified permissions. CheckAuthenticated(permission mockauth.Permission, bucket, scope, collection string, request *HTTPRequest) bool }
MgmtService represents a management service running somewhere in the cluster.
type NewBucketOptions ¶
type NewBucketOptions struct { Name string Type BucketType NumReplicas uint FlushEnabled bool RamQuota uint64 ReplicaIndexEnabled bool CompressionMode CompressionMode }
NewBucketOptions allows you to specify initial options for a new bucket
type NewClusterOptions ¶
type NewClusterOptions struct { Chrono *mocktime.Chrono NumVbuckets uint InitialNode NewNodeOptions ReplicaLatency time.Duration PersistLatency time.Duration }
NewClusterOptions allows the specification of initial options for a new cluster.
type NewNodeOptions ¶
type NewNodeOptions struct { Features []ClusterNodeFeature Services []ServiceType }
NewNodeOptions allows the specification of initial options for a new node.
type QueryHookFunc ¶
type QueryHookFunc func(source QueryService, req *HTTPRequest, next func() *HTTPResponse) *HTTPResponse
QueryHookFunc implements a hook for handling a query request. NOTE: It is safe and expected that a hook may alter the packet.
type QueryHookManager ¶
type QueryHookManager interface { // Child returns a child hook manager to this hook manager. Child() QueryHookManager // Add adds a new hook at the end of the processing chain. Add(fn QueryHookFunc) // Destroy removes all this managers hooks from the root manager. Destroy() }
QueryHookManager implements a tree of hooks which can handle a query request.
type QueryService ¶
type QueryService interface { // Node returns the node which owns this service. Node() ClusterNode // Hostname returns the hostname where this service can be accessed. Hostname() string // ListenPort returns the port this service is listening on. ListenPort() int // ListenPortTLS returns the TLS port this service is listening on. ListenPortTLS() int // Close will shut down this service once it is no longer needed. Close() error // CheckAuthenticated verifies that the currently authenticated user has the specified permissions. CheckAuthenticated(permission mockauth.Permission, bucket, scope, collection string, request *HTTPRequest) bool }
QueryService represents a query service running somewhere in the cluster.
type SearchHookFunc ¶
type SearchHookFunc func(source SearchService, req *HTTPRequest, next func() *HTTPResponse) *HTTPResponse
SearchHookFunc implements a hook for handling a query request. NOTE: It is safe and expected that a hook may alter the packet.
type SearchHookManager ¶
type SearchHookManager interface { // Child returns a child hook manager to this hook manager. Child() SearchHookManager // Add adds a new hook at the end of the processing chain. Add(fn SearchHookFunc) // Destroy removes all this managers hooks from the root manager. Destroy() }
SearchHookManager implements a tree of hooks which can handle a search request.
type SearchService ¶
type SearchService interface { // Node returns the node which owns this service. Node() ClusterNode // Hostname returns the hostname where this service can be accessed. Hostname() string // ListenPort returns the port this service is listening on. ListenPort() int // ListenPortTLS returns the TLS port this service is listening on. ListenPortTLS() int // Close will shut down this service once it is no longer needed. Close() error // CheckAuthenticated verifies that the currently authenticated user has the specified permissions. CheckAuthenticated(permission mockauth.Permission, bucket, scope, collection string, request *HTTPRequest) bool }
SearchService represents a views service running somewhere in the cluster.
type UpdateBucketOptions ¶
type UpdateBucketOptions struct { NumReplicas uint FlushEnabled bool RamQuota uint64 ReplicaIndexEnabled bool CompressionMode CompressionMode }
UpdateBucketOptions allows you to specify options for updating a bucket
type UserManager ¶
type UserManager interface { // AddUser will add a new user to a cluster. UpsertUser(opts mockauth.UpsertUserOptions) error // GetUser will return a specific user from the cluster. GetUser(username string) *mockauth.User // GetAllUsers will return all of the users from the cluster. GetAllUsers() []*mockauth.User // DropUser will remove a specific user from the cluster. DropUser(username string) error // GetAllClusterRoles will return all roles from the cluster. GetAllClusterRoles() []*mockauth.ClusterRole }
UserManager represents information about the users of the cluster.
type ViewHookFunc ¶
type ViewHookFunc func(source ViewService, req *HTTPRequest, next func() *HTTPResponse) *HTTPResponse
ViewHookFunc implements a hook for handling a query request. NOTE: It is safe and expected that a hook may alter the packet.
type ViewHookManager ¶
type ViewHookManager interface { // Child returns a child hook manager to this hook manager. Child() ViewHookManager // Add adds a new hook at the end of the processing chain. Add(fn ViewHookFunc) // Destroy removes all this managers hooks from the root manager. Destroy() }
ViewHookManager implements a tree of hooks which can handle a view request.
type ViewIndexManager ¶
type ViewIndexManager interface { // UpsertDesignDocument creates or updates a design document. UpsertDesignDocument(name string, opts mockmr.UpsertDesignDocumentOptions) error // DropDesignDocument removes a design document. DropDesignDocument(name string) error // GetDesignDocument retrieves a single design document. GetDesignDocument(name string) (*mockmr.DesignDocument, error) // GetAllDesignDocuments retrieves all design documents. GetAllDesignDocuments() []*mockmr.DesignDocument // Execute executes a query. Execute(opts mockmr.ExecuteOptions) (int, *mockmr.ExecuteResults, error) }
ViewIndexManager represents information about the view indexes of a bucket.
type ViewService ¶
type ViewService interface { // Node returns the node which owns this service. Node() ClusterNode // Hostname returns the hostname where this service can be accessed. Hostname() string // ListenPort returns the port this service is listening on. ListenPort() int // ListenPortTLS returns the TLS port this service is listening on. ListenPortTLS() int // Close will shut down this service once it is no longer needed. Close() error // CheckAuthenticated verifies that the currently authenticated user has the specified permissions. CheckAuthenticated(permission mockauth.Permission, bucket, scope, collection string, request *HTTPRequest) bool }
ViewService represents a views service running somewhere in the cluster.
Source Files ¶
- analyticshookmanager.go
- analyticsservice.go
- bucket.go
- bucketstore.go
- cluster.go
- clusterfeatures.go
- clusternode.go
- collectionmanifest.go
- config.go
- errmap.go
- http.go
- kvclient.go
- kvhookmanager.go
- kvservice.go
- mgmthookmanager.go
- mgmtservice.go
- queryhookmanager.go
- queryservice.go
- searchhookmanager.go
- searchservice.go
- servicetype.go
- userservice.go
- viewhookmanager.go
- viewservice.go