raft

package
v0.0.0-...-cd88b06 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2017 The GoStor Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2017 The GoStor Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Operation

type Operation struct {
	Type      string    `json:"type"`
	Namespace string    `json:"namespace"`
	Filename  string    `json:"name"`
	NewName   string    `json:"newname"`
	FileAttr  *fs.Attr  `json:"attr"`
	CreatedAt time.Time `json:"createdat"`
}

This command writes a value to a key.

func NewOperation

func NewOperation(t, n, f, nn string, attr *fs.Attr, created time.Time) *Operation

Creates a new operation command.

func (*Operation) Apply

func (o *Operation) Apply(server raft.Server) (interface{}, error)

Operate the file of the namespace.

func (*Operation) CommandName

func (o *Operation) CommandName() string

The name of the command in the log.

type RaftServer

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

func NewRaftServer

func NewRaftServer(peers []string, httpAddr string, dataDir string, pulseSeconds int, r *mux.Router, httpServer *http.Server, cache cache.Cache) (*RaftServer, error)

func (*RaftServer) Do

func (s *RaftServer) Do(command raft.Command) (interface{}, error)

func (*RaftServer) HandleFunc

func (s *RaftServer) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

This is a hack around Gorilla mux not providing the correct net/http HandleFunc() interface.

func (*RaftServer) Join

func (s *RaftServer) Join(peers []string) error

Join joins an existing cluster.

func (*RaftServer) Leader

func (s *RaftServer) Leader() (string, error)

func (*RaftServer) Peers

func (s *RaftServer) Peers() (members []string)

Jump to

Keyboard shortcuts

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