jcbmock

package
v9.1.10 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CFailover represents a command code to send FAILOVER to the mock.
	CFailover CmdCode = "FAILOVER"

	// CRespawn represents a command code to send RESPAWN to the mock.
	CRespawn = "RESPAWN"

	// CHiccup represents a command code to send HICCUP to the mock.
	CHiccup = "HICCUP"

	// CTruncate represents a command code to send TRUNCATE to the mock.
	CTruncate = "TRUNCATE"

	// CMockinfo represents a command code to send MOCKINFO to the mock.
	CMockinfo = "MOCKINFO"

	// CPersist represents a command code to send PERSIST to the mock.
	CPersist = "PERSIST"

	// CCache represents a command code to send CACHE to the mock.
	CCache = "CACHE"

	// CUnpersist represents a command code to send UNPERSIST to the mock.
	CUnpersist = "UNPERSIST"

	// CUncache represents a command code to send UNCACHE to the mock.
	CUncache = "UNCACHE"

	// CEndure represents a command code to send ENDURE to the mock.
	CEndure = "ENDURE"

	// CPurge represents a command code to send PURGE to the mock.
	CPurge = "PURGE"

	// CKeyinfo represents a command code to send KEYINFO to the mock.
	CKeyinfo = "KEYINFO"

	// CTimeTravel represents a command code to send TIME_TRAVEL to the mock.
	CTimeTravel = "TIME_TRAVEL"

	// CHelp represents a command code to send HELP to the mock.
	CHelp = "HELP"

	// COpFail represents a command code to send OPFAIL to the mock.
	COpFail = "OPFAIL"

	// CSetCCCP represents a command code to SET_CCCP the mock.
	CSetCCCP = "SET_CCCP"

	// CGetMcPorts represents a command code to GET_MCPORTS the mock.
	CGetMcPorts = "GET_MCPORTS"

	// CRegenVBCoords represents a command code to REGEN_VBCOORDS the mock.
	CRegenVBCoords = "REGEN_VBCOORDS"

	// CResetQueryState represents a command code to RESET_QUERYSTATE the mock.
	CResetQueryState = "RESET_QUERYSTATE"

	// CStartCmdLog represents a command code to START_CMDLOG the mock.
	CStartCmdLog = "START_CMDLOG"

	// CStopCmdLog represents a command code to STOP_CMDLOG the mock.
	CStopCmdLog = "STOP_CMDLOG"

	// CGetCmdLog represents a command code to GET_CMDLOG the mock.
	CGetCmdLog = "GET_CMDLOG"

	// CStartRetryVerify represents a command code to START_RETRY_VERIFY the mock.
	CStartRetryVerify = "START_RETRY_VERIFY"

	// CCheckRetryVerify represents a command code to CHECK_RETRY_VERIFY the mock.
	CCheckRetryVerify = "CHECK_RETRY_VERIFY"

	// CSetEnhancedErrors represents a command code to SET_ENHANCED_ERRORS the mock.
	CSetEnhancedErrors = "SET_ENHANCED_ERRORS"

	// CSetCompression represents a command code to SET_COMPRESSION the mock.
	CSetCompression = "SET_COMPRESSION"

	// CSetSASLMechanisms represents a command code to SET_SASL_MECHANISMS the mock.
	CSetSASLMechanisms = "SET_SASL_MECHANISMS"
)

Variables

This section is empty.

Functions

func GetMockPath

func GetMockPath() (path string, err error)

GetMockPath ensures that the mock path is available

Types

type BucketSpec

type BucketSpec struct {
	// Type of the bucket
	Type BucketType
	// Name of the bucket
	Name string
	// Password for the bucket (empty means no password)
	Password string
}

BucketSpec describes the specification of a bucket.

type BucketType

type BucketType int

BucketType represents the type of bucket to use.

const (
	// BCouchbase represents to use a couchbase bucket.
	BCouchbase BucketType = 0

	// BMemcached represents to use a memcached bucket.
	BMemcached = iota
)

type CmdCode

type CmdCode string

CmdCode represents a command code to send to Couchbase Mock.

type Command

type Command interface {
	Encode() []byte
	Set(key string, value interface{})
}

Command is used to specify a command to run.

func NewCommand

func NewCommand(code CmdCode, body map[string]interface{}) Command

NewCommand returns a new command for a given command code and body.

type Mock

type Mock struct {

	// List of ports for the bucket
	EntryPort uint16
	// contains filtered or unexported fields
}

Mock is used for mocking a Couchbase Server cluster.

func NewMock

func NewMock(path string, nodes uint, replicas uint, vbuckets uint, specs ...BucketSpec) (m *Mock, err error)

NewMock creates and runs a new mock instance The path is the path to the mock jar. nodes is the total number of cluster nodes (and thus the number of mock threads) replicas is the number of replica nodes (subset of the number of nodes) for each couchbase bucket. vbuckets is the number of vbuckets to use for each couchbase bucket specs should be a list of specifications of buckets to use..

func (*Mock) Close

func (m *Mock) Close()

Close closes the mock and kills the underlying process

func (*Mock) Control

func (m *Mock) Control(c Command) (r Response)

Control sends a control command to the mock.

func (*Mock) MemcachedPorts

func (m *Mock) MemcachedPorts() (out []uint16)

MemcachedPorts returns the list of memcached ports that this mock is listening on.

func (*Mock) Version

func (m *Mock) Version() string

Version returns the version of this mock.

type Response

type Response struct {
	Payload map[string]interface{}
}

Response is the result of running a command.

func (*Response) Success

func (r *Response) Success() bool

Success returns whether or not the command was successful.

Jump to

Keyboard shortcuts

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