backend

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package backend provides the backend implementation of the Yorkie. This package is responsible for managing the database and other resources required to run Yorkie.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Config *Config

	DB           database.Database
	Coordinator  sync.Coordinator
	Metrics      *prometheus.Metrics
	Background   *background.Background
	Housekeeping *housekeeping.Housekeeping

	AuthWebhookCache *cache.LRUExpireCache[string, *types.AuthWebhookResponse]
	// contains filtered or unexported fields
}

Backend manages Yorkie's backend such as Database and Coordinator. And it has the server status such as the information of this Server.

func New

func New(
	conf *Config,
	mongoConf *mongo.Config,
	etcdConf *etcd.Config,
	housekeepingConf *housekeeping.Config,
	clusterAddr string,
	metrics *prometheus.Metrics,
) (*Backend, error)

New creates a new instance of Backend.

func (*Backend) Members

func (b *Backend) Members() map[string]*sync.ServerInfo

Members returns the members of this cluster.

func (*Backend) Shutdown

func (b *Backend) Shutdown() error

Shutdown closes all resources of this instance.

type Config

type Config struct {
	// AdminUser is the name of the default admin user who has full permissions.
	// Set once on first-run. Default is "admin".
	AdminUser string `yaml:"AdminUser"`

	// AdminPassword is the password of the default admin. Default is "admin".
	AdminPassword string `yaml:"AdminPassword"`

	// SecretKey is the secret key for signing authentication tokens.
	SecretKey string `yaml:"SecretKey"`

	// AdminTokenDuration is the duration of the admin token. Default is "7d".
	AdminTokenDuration string `yaml:"AdminTokenDuration"`

	// UseDefaultProject is whether to use the default project. Even if public
	// key is not provided from the client, the default project will be used. If
	// we are using server as single-tenant mode, this should be set to true.
	UseDefaultProject bool `yaml:"UseDefaultProject"`

	// ClientDeactivateThreshold is deactivate threshold of clients in specific project for housekeeping.
	ClientDeactivateThreshold string `yaml:"ClientDeactivateThreshold"`

	// SnapshotThreshold is the threshold that determines if changes should be
	// sent with snapshot when the number of changes is greater than this value.
	SnapshotThreshold int64 `yaml:"SnapshotThreshold"`

	// SnapshotInterval is the interval of changes to create a snapshot.
	SnapshotInterval int64 `yaml:"SnapshotInterval"`

	// SnapshotWithPurgingChanges is whether to delete previous changes when the snapshot is created.
	SnapshotWithPurgingChanges bool `yaml:"SnapshotWithPurgingChages"`

	// AuthWebhookMaxRetries is the max count that retries the authorization webhook.
	AuthWebhookMaxRetries uint64 `yaml:"AuthWebhookMaxRetries"`

	// AuthWebhookMaxWaitInterval is the max interval that waits before retrying the authorization webhook.
	AuthWebhookMaxWaitInterval string `yaml:"AuthWebhookMaxWaitInterval"`

	// AuthWebhookCacheSize is the cache size of the authorization webhook.
	AuthWebhookCacheSize int `yaml:"AuthWebhookCacheSize"`

	// AuthWebhookCacheAuthTTL is the TTL value to set when caching the authorized result.
	AuthWebhookCacheAuthTTL string `yaml:"AuthWebhookCacheAuthTTL"`

	// AuthWebhookCacheUnauthTTL is the TTL value to set when caching the unauthorized result.
	AuthWebhookCacheUnauthTTL string `yaml:"AuthWebhookCacheUnauthTTL"`
}

Config is the configuration for creating a Backend instance.

func (*Config) ParseAdminTokenDuration added in v0.2.15

func (c *Config) ParseAdminTokenDuration() time.Duration

ParseAdminTokenDuration returns admin token duration.

func (*Config) ParseAuthWebhookCacheAuthTTL

func (c *Config) ParseAuthWebhookCacheAuthTTL() time.Duration

ParseAuthWebhookCacheAuthTTL returns TTL for authorized cache.

func (*Config) ParseAuthWebhookCacheUnauthTTL

func (c *Config) ParseAuthWebhookCacheUnauthTTL() time.Duration

ParseAuthWebhookCacheUnauthTTL returns TTL for unauthorized cache.

func (*Config) ParseAuthWebhookMaxWaitInterval

func (c *Config) ParseAuthWebhookMaxWaitInterval() time.Duration

ParseAuthWebhookMaxWaitInterval returns max wait interval.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates this config.

Directories

Path Synopsis
Package background provides the background service.
Package background provides the background service.
Package database provides the database interface for the Yorkie backend.
Package database provides the database interface for the Yorkie backend.
memory
Package memory implements the database interface using in-memory database.
Package memory implements the database interface using in-memory database.
mongo
Package mongo implements database interfaces using MongoDB.
Package mongo implements database interfaces using MongoDB.
Package housekeeping provides the housekeeping service.
Package housekeeping provides the housekeeping service.
Package sync provides the synchronization primitives for the server.
Package sync provides the synchronization primitives for the server.
etcd
Package etcd provides etcd implementation of the sync.
Package etcd provides etcd implementation of the sync.
memory
Package memory provides the memory implementation of the sync package.
Package memory provides the memory implementation of the sync package.

Jump to

Keyboard shortcuts

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