couchdb

package
v0.0.0-...-95b87ed Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructMetadataDBName

func ConstructMetadataDBName(dbName string) string

func ConstructNamespaceDBName

func ConstructNamespaceDBName(chainName, namespace string) string

func CreateSystemDatabasesIfNotExist

func CreateSystemDatabasesIfNotExist(couchInstance *CouchInstance) error

func IsJSON

func IsJSON(s string) bool

Types

type AttachmentInfo

type AttachmentInfo struct {
	Name            string
	ContentType     string `json:"content_type"`
	Length          uint64
	AttachmentBytes []byte `json:"data"`
}

type Base64Attachment

type Base64Attachment struct {
	ContentType    string `json:"content_type"`
	AttachmentData string `json:"data"`
}

type BatchRetrieveDocMetadataResponse

type BatchRetrieveDocMetadataResponse struct {
	Rows []struct {
		ID          string `json:"id"`
		DocMetadata struct {
			ID      string `json:"_id"`
			Rev     string `json:"_rev"`
			Version string `json:"~version"`
		} `json:"doc"`
	} `json:"rows"`
}

type BatchUpdateResponse

type BatchUpdateResponse struct {
	ID     string `json:"id"`
	Error  string `json:"error"`
	Reason string `json:"reason"`
	Ok     bool   `json:"ok"`
	Rev    string `json:"rev"`
}

type Config

type Config struct {
	Address string

	Username string

	Password string

	MaxRetries int

	MaxRetriesOnStartup int

	RequestTimeout time.Duration

	InternalQueryLimit int

	MaxBatchUpdateSize int

	WarmIndexesAfterNBlocks int

	CreateGlobalChangesDB bool

	RedoLogPath string
}

type ConnectionInfo

type ConnectionInfo struct {
	Couchdb string `json:"couchdb"`
	Version string `json:"version"`
	Vendor  struct {
		Name string `json:"name"`
	} `json:"vendor"`
}

type CouchDBDef

type CouchDBDef struct {
	URL                   string
	Username              string
	Password              string
	MaxRetries            int
	MaxRetriesOnStartup   int
	RequestTimeout        time.Duration
	CreateGlobalChangesDB bool
}

func GetCouchDBDefinition

func GetCouchDBDefinition() *CouchDBDef

type CouchDatabase

type CouchDatabase struct {
	CouchInstance    *CouchInstance
	DBName           string
	IndexWarmCounter int
}

func CreateCouchDatabase

func CreateCouchDatabase(couchInstance *CouchInstance, dbName string) (*CouchDatabase, error)

func (*CouchDatabase) ApplyDatabaseSecurity

func (dbclient *CouchDatabase) ApplyDatabaseSecurity(databaseSecurity *DatabaseSecurity) error

func (*CouchDatabase) BatchRetrieveDocumentMetadata

func (dbclient *CouchDatabase) BatchRetrieveDocumentMetadata(keys []string) ([]*DocMetadata, error)

func (*CouchDatabase) BatchUpdateDocuments

func (dbclient *CouchDatabase) BatchUpdateDocuments(documents []*CouchDoc) ([]*BatchUpdateResponse, error)

func (*CouchDatabase) CreateDatabaseIfNotExist

func (dbclient *CouchDatabase) CreateDatabaseIfNotExist() error

func (*CouchDatabase) CreateIndex

func (dbclient *CouchDatabase) CreateIndex(indexdefinition string) (*CreateIndexResponse, error)

func (*CouchDatabase) DeleteDoc

func (dbclient *CouchDatabase) DeleteDoc(id, rev string) error

func (*CouchDatabase) DeleteIndex

func (dbclient *CouchDatabase) DeleteIndex(designdoc, indexname string) error

func (*CouchDatabase) DropDatabase

func (dbclient *CouchDatabase) DropDatabase() (*DBOperationResponse, error)

func (*CouchDatabase) EnsureFullCommit

func (dbclient *CouchDatabase) EnsureFullCommit() (*DBOperationResponse, error)

func (*CouchDatabase) GetDatabaseInfo

func (dbclient *CouchDatabase) GetDatabaseInfo() (*DBInfo, *DBReturn, error)

func (*CouchDatabase) GetDatabaseSecurity

func (dbclient *CouchDatabase) GetDatabaseSecurity() (*DatabaseSecurity, error)

func (*CouchDatabase) ListIndex

func (dbclient *CouchDatabase) ListIndex() ([]*IndexResult, error)

func (*CouchDatabase) QueryDocuments

func (dbclient *CouchDatabase) QueryDocuments(query string) ([]*QueryResult, string, error)

func (*CouchDatabase) ReadDoc

func (dbclient *CouchDatabase) ReadDoc(id string) (*CouchDoc, string, error)

func (*CouchDatabase) ReadDocRange

func (dbclient *CouchDatabase) ReadDocRange(startKey, endKey string, limit int32) ([]*QueryResult, string, error)

func (*CouchDatabase) SaveDoc

func (dbclient *CouchDatabase) SaveDoc(id string, rev string, couchDoc *CouchDoc) (string, error)

func (*CouchDatabase) WarmIndex

func (dbclient *CouchDatabase) WarmIndex(designdoc, indexname string) error

func (*CouchDatabase) WarmIndexAllIndexes

func (dbclient *CouchDatabase) WarmIndexAllIndexes() error

type CouchDoc

type CouchDoc struct {
	JSONValue   []byte
	Attachments []*AttachmentInfo
}

type CouchInstance

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

func CreateCouchInstance

func CreateCouchInstance(config *Config, metricsProvider metrics.Provider) (*CouchInstance, error)

func (*CouchInstance) HealthCheck

func (couchInstance *CouchInstance) HealthCheck(ctx context.Context) error

func (*CouchInstance) InternalQueryLimit

func (couchInstance *CouchInstance) InternalQueryLimit() int32

func (*CouchInstance) MaxBatchUpdateSize

func (couchInstance *CouchInstance) MaxBatchUpdateSize() int

func (*CouchInstance) URL

func (couchInstance *CouchInstance) URL() string

func (*CouchInstance) VerifyCouchConfig

func (couchInstance *CouchInstance) VerifyCouchConfig() (*ConnectionInfo, *DBReturn, error)

type CreateIndexResponse

type CreateIndexResponse struct {
	Result string `json:"result"`
	ID     string `json:"id"`
	Name   string `json:"name"`
}

type DBInfo

type DBInfo struct {
	DbName string `json:"db_name"`
	Sizes  struct {
		File     int `json:"file"`
		External int `json:"external"`
		Active   int `json:"active"`
	} `json:"sizes"`
	Other struct {
		DataSize int `json:"data_size"`
	} `json:"other"`
	DocDelCount       int    `json:"doc_del_count"`
	DocCount          int    `json:"doc_count"`
	DiskSize          int    `json:"disk_size"`
	DiskFormatVersion int    `json:"disk_format_version"`
	DataSize          int    `json:"data_size"`
	CompactRunning    bool   `json:"compact_running"`
	InstanceStartTime string `json:"instance_start_time"`
}

type DBOperationResponse

type DBOperationResponse struct {
	Ok bool
}

type DBReturn

type DBReturn struct {
	StatusCode int    `json:"status_code"`
	Error      string `json:"error"`
	Reason     string `json:"reason"`
}

type DatabaseSecurity

type DatabaseSecurity struct {
	Admins struct {
		Names []string `json:"names"`
		Roles []string `json:"roles"`
	} `json:"admins"`
	Members struct {
		Names []string `json:"names"`
		Roles []string `json:"roles"`
	} `json:"members"`
}

type DocID

type DocID struct {
	ID string `json:"_id"`
}

type DocMetadata

type DocMetadata struct {
	ID              string                     `json:"_id"`
	Rev             string                     `json:"_rev"`
	Version         string                     `json:"~version"`
	AttachmentsInfo map[string]*AttachmentInfo `json:"_attachments"`
}

type FileDetails

type FileDetails struct {
	Follows     bool   `json:"follows"`
	ContentType string `json:"content_type"`
	Length      int    `json:"length"`
}

type IndexResult

type IndexResult struct {
	DesignDocument string `json:"designdoc"`
	Name           string `json:"name"`
	Definition     string `json:"definition"`
}

type QueryResponse

type QueryResponse struct {
	Warning  string            `json:"warning"`
	Docs     []json.RawMessage `json:"docs"`
	Bookmark string            `json:"bookmark"`
}

type QueryResult

type QueryResult struct {
	ID          string
	Value       []byte
	Attachments []*AttachmentInfo
}

type RangeQueryResponse

type RangeQueryResponse struct {
	TotalRows int32 `json:"total_rows"`
	Offset    int32 `json:"offset"`
	Rows      []struct {
		ID    string `json:"id"`
		Key   string `json:"key"`
		Value struct {
			Rev string `json:"rev"`
		} `json:"value"`
		Doc json.RawMessage `json:"doc"`
	} `json:"rows"`
}

Jump to

Keyboard shortcuts

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