mock

package
v0.0.0-...-bc5e729 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2017 License: MPL-2.0 Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMeta = &Meta{data: map[string]string{}}

DefaultMeta for default mock meta

View Source
var DefaultWatchPeriod = time.Millisecond * 500

DefaultWatchPeriod for value changing period

Functions

func HostOfURL

func HostOfURL(rawurl string) string

HostOfURL must get the host from the given url

Types

type HTTPGetter

type HTTPGetter interface {
	Get(url string) (resp *http.Response, err error)
}

HTTPGetter for mock http.Get

func HTTPGetterCluster

func HTTPGetterCluster(getterMap map[string]HTTPGetter) HTTPGetter

HTTPGetterCluster combine getters into one getter

func MakeHTTPGetter

func MakeHTTPGetter(url string, response string, err error, delay time.Duration) HTTPGetter

MakeHTTPGetter makes a HTTPGetter using the given params

type HTTPGetterFunc

type HTTPGetterFunc func(url string) (resp *http.Response, err error)

HTTPGetterFunc implements HTTPGetter

func (HTTPGetterFunc) Get

func (f HTTPGetterFunc) Get(url string) (resp *http.Response, err error)

Get implements HTTPGetter

type HTTPPoster

type HTTPPoster interface {
	Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)
}

HTTPPoster fot mock http.Post

func HTTPPosterCluster

func HTTPPosterCluster(posterMap map[string]HTTPPoster) HTTPPoster

HTTPPosterCluster combine poster into one poster

func MakeHTTPPoster

func MakeHTTPPoster(url string, response string, err error, delay time.Duration) HTTPPoster

MakeHTTPPoster makes a HTTPPoster using the given params

type HTTPPosterFunc

type HTTPPosterFunc func(url string, contentType string, body io.Reader) (resp *http.Response, err error)

HTTPPosterFunc implements HTTPPoster

func (HTTPPosterFunc) Post

func (f HTTPPosterFunc) Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)

Post implements HTTPPoster

type Meta

type Meta struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Meta a meta.Meta mock

func (*Meta) Get

func (m *Meta) Get(key string) (string, error)

Get gets the value of the given key

func (*Meta) Put

func (m *Meta) Put(key string, value string) error

Put the key/value pair

func (*Meta) WatchModify

func (m *Meta) WatchModify(key string, do func())

WatchModify watch the modification event of the value the given key and execute the do

type RPCClient

type RPCClient interface {
	Call(serviceMethod string, args interface{}, reply interface{}) error
}

RPCClient defines a client to

type RPCClientFunc

type RPCClientFunc func(serviceMethod string, args interface{}, reply interface{}) error

RPCClientFunc defines Call method of RPCClient interface

func (RPCClientFunc) Call

func (f RPCClientFunc) Call(serviceMethod string, args interface{}, reply interface{}) error

Call implements RPCClient interface

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store mocks the db/node.Store

func NewStore

func NewStore() *Store

NewStore returns a new Store

func (*Store) Add

func (s *Store) Add(key, value string) error

Add adds key/value, via distributed consensus.

func (*Store) Get

func (s *Store) Get(key string) (string, error)

Get returns the value for the given key.

func (*Store) Join

func (s *Store) Join(addr string) error

Join joins the node, reachable at addr, to the cluster.

func (*Store) Leader

func (s *Store) Leader() string

Leader returns the leader address

func (*Store) Open

func (s *Store) Open(singleMode bool) error

Open opens a store in a single mode or not

func (*Store) Peers

func (s *Store) Peers() ([]string, error)

Peers returns the store peers

func (*Store) SetLeader

func (s *Store) SetLeader(leader string)

SetLeader set the leader for testing

func (*Store) Stats

func (s *Store) Stats() map[string]string

Stats return the stats as a map[string]string

Jump to

Keyboard shortcuts

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