Documentation ¶
Index ¶
- func QuitHandler(w http.ResponseWriter, r *http.Request)
- func RaftAdminHandler(r *raft.Raft, s *raft.Storage) http.Handler
- func ReadOnlyHandler(w http.ResponseWriter, r *http.Request, h ROHandler)
- func SummaryString(obs prometheus.Observer) string
- type AutoConfig
- type FineGrainedLock
- type LockManager
- type OpFailure
- type OpMetric
- type ROHandler
- type RaftReconfig
- type Semaphore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QuitHandler ¶
func QuitHandler(w http.ResponseWriter, r *http.Request)
QuitHandler will shut down a process. Should be used for testing only.
func RaftAdminHandler ¶
RaftAdminHandler is an http.Handler for raft admin tasks. Currently it defines one sub-route:
/last_snapshot - serves the most recent snapshot directly from disk
func ReadOnlyHandler ¶
func ReadOnlyHandler(w http.ResponseWriter, r *http.Request, h ROHandler)
ReadOnlyHandler implements /readonly for the master and curator. GET requests return the current read-only state, POST requests like /readonly?mode=true or false change it. If this node is not the raft leader, it will return a redirect to what it thinks the current leader is.
func SummaryString ¶
func SummaryString(obs prometheus.Observer) string
Types ¶
type AutoConfig ¶
type AutoConfig struct {
// contains filtered or unexported fields
}
AutoConfig controls the membership of a raft cluster based on commands delivered over http and service membership information observed from discovery.
By default, an AutoConfig doesn't do anything. To install http handlers, use HTTPHandlers. To watch for changes from discovery, call WatchDiscovery.
func NewAutoConfig ¶
func NewAutoConfig(spec string, handler RaftReconfig) *AutoConfig
NewAutoConfig creates an AutoConfig. spec should be empty to disable discovery, or a string of the form "cluster/service/user=n", where n is the expected number of members.
func (*AutoConfig) HTTPHandlers ¶
func (ac *AutoConfig) HTTPHandlers() *http.ServeMux
HTTPHandlers returns a handler for reconfig endpoints. The paths handled are:
/add?node=host:port adds a new node /remove?node=host:port removes a node /initial proposes initial configuration from discovery /initial?members=a,b,c proposes initial configuration with explicit hosts /inject_update?members=a,b,c inject fake discovery update (for testing)
func (*AutoConfig) WatchDiscovery ¶
func (ac *AutoConfig) WatchDiscovery() error
WatchDiscovery starts a goroutine to watch for changes to this service in discovery.
type FineGrainedLock ¶
type FineGrainedLock struct {
// contains filtered or unexported fields
}
FineGrainedLock implements LockManager.
func (*FineGrainedLock) LockBlob ¶
func (f *FineGrainedLock) LockBlob(blobID core.BlobID)
LockBlob locks a blob.
func (*FineGrainedLock) LockTract ¶
func (f *FineGrainedLock) LockTract(tractID core.TractID)
LockTract locks a tract.
func (*FineGrainedLock) UnlockBlob ¶
func (f *FineGrainedLock) UnlockBlob(blobID core.BlobID)
UnlockBlob unlocks a blob.
func (*FineGrainedLock) UnlockTract ¶
func (f *FineGrainedLock) UnlockTract(tractID core.TractID)
UnlockTract unlocks a tract
type LockManager ¶
type LockManager interface { // LockBlock acquires a lock of exclusive access to a given blob. LockBlob(core.BlobID) // UnlockBlob releases the lock on a given blob. UnlockBlob(core.BlobID) // LockTract acquires a lock of exclusive access to a given tract. LockTract(core.TractID) // UnlockTract releases the lock on a given tract. UnlockTract(core.TractID) }
LockManager provides exclusive access to a given blob or tract. We use leader continuity check to guard against conflict changes from different nodes, but within a same node we still need lock to guard against conflict changes from different goroutines.
func NewFineGrainedLock ¶
func NewFineGrainedLock() LockManager
NewFineGrainedLock creates a new FineGrainedLock.
type OpFailure ¶
type OpFailure struct {
// contains filtered or unexported fields
}
OpFailure is used by failure service and maps operation names to their registered failure errors.
type OpMetric ¶
type OpMetric struct {
// contains filtered or unexported fields
}
OpMetric is a wrapper around metric objects that helps with tracking counts and latencies for "operations". Operations for the purpose can be either things done by a server on behalf of a client (e.g. handling an RPC), or chunks of work initiated internally.
OpMetric will create three metric sets:
- A CounterSet with the given name, label "result", and any additional labels. Using Start/End will increment this counter with "result"="all". Additionally you can call Failed or TooBusy on the op object to increment the counters with "result"="failed" and "too_busy".
- A SketchSet with the given name + "_latency" and any additional labels. Using Start/End will add latencies to this sketch set, only if TooBusy/Failed was not called before End.
- A IntGaugeSet with the given name + "_pending" and any additional labels. Using Start/End will ensure that this metric reflects the number of pending operations.
Suggested usage:
h.opMetricInstance = NewOpMetric("my_server_ops", "op")
func (h *myHandler) someOpHandler() { op := h.opMetricInstance.Start("some_op") defer op.End() ... if queueTooBig { op.TooBusy() } if err != nil { op.Failed() } return err }
func NewOpMetric ¶
NewOpMetric returns a new op metric.
func (*OpMetric) Start ¶
Start marks that a new operation has started and begins measuring the latency.
type ROHandler ¶
type ROHandler interface { ID() string LeaderID() string ReadOnlyMode() (bool, core.Error) SetReadOnlyMode(bool) core.Error }
ROHandler is a subset of the master or curator state handler that's needed for controlling read-only mode.
type RaftReconfig ¶
type RaftReconfig interface { // ID returns the Raft ID of the node. ID() string // LeaderID returns the Raft ID of the leader. LeaderID() string // AddNode addes a node to the cluster. AddNode(string) error // RemoveNode removes a node from the cluster. RemoveNode(string) error // GetMembership gets the current membership of the raft cluster. GetMembership() []string // ProposeInitialMembership proposes an initial configuration. ProposeInitialMembership([]string) error }
RaftReconfig is the interface used by AutoConfig to reconfigure a cluster.
type Semaphore ¶
type Semaphore chan struct{}
Semaphore implementation using Go channel.
func NewSemaphore ¶
NewSemaphore creates a new semaphore with 'max' number of permits.
func (Semaphore) Acquire ¶
func (s Semaphore) Acquire()
Acquire tries to acquire a permit from the semaphore, blocking until one becomes available.
func (Semaphore) TryAcquire ¶
TryAcquire tries to acquire a permit from the semaphore. It succeeds if and only if one is available at the invocation time.