globals

package
v0.0.0-...-bccea44 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

globals defines the global variables shared between primary and backup.

Index

Constants

This section is empty.

Variables

View Source
var (
	// The port of the replica.
	Port int

	// The Operation request ID.
	OpNum int

	// The current view number.
	ViewNum int

	// The current commit number.
	CommitNum int

	// The mode of the replica. Only monitor is supposed to change this.
	Mode string

	// The operation log.
	OpLog *oplog.OpRequestLog

	// The client table.
	ClientTable *table.ClientTable

	// The global cancellable context.
	CtxCancel context.Context

	// AllPorts is a map from id to port.
	AllPorts = map[int]int{}
)

Functions

func AllOtherPorts

func AllOtherPorts() []int

AllOtherPorts returns all the other replica ports except for that of the current node.

func GetOrCreateClient

func GetOrCreateClient(hostname string) (*rpc.Client, error)

GetOrCreateClient returns a cached rpc.Client or creates a new rpc.Client.

func Log

func Log(f, format string, args ...interface{})

Types

type MutexBool

type MutexBool struct {
	sync.Mutex
	V bool
}

MutexBool is a thread-safe bool.

func (*MutexBool) Locked

func (m *MutexBool) Locked(f func())

Locked locks the bool.

type MutexInt

type MutexInt struct {
	sync.Mutex
	V int
}

MutexInt is a thread-safe int.

func (*MutexInt) Locked

func (m *MutexInt) Locked(f func())

Locked locks the int.

type MutexString

type MutexString struct {
	sync.Mutex
	V string
}

MutexString is a thread-safe string.

func (*MutexString) Locked

func (m *MutexString) Locked(f func())

Locked locks the string.

Jump to

Keyboard shortcuts

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