client

package
v0.0.0-...-4b7bac6 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientImpl

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

func NewClientImpl

func NewClientImpl(name string, clientHost string, clientPort string, serverHost string, c pb.MaintainerClient) ClientImpl

NewClientImpl is a tool to get a client

func (*ClientImpl) ChangeStatus

func (c *ClientImpl) ChangeStatus(ctx context.Context, token string) error

ChangeStatus will change the ownership of key

func (*ClientImpl) Query

func (c *ClientImpl) Query(ctx context.Context, token string) (string, error)

Query first query from local, if it does not exist, it will sync from others

func (*ClientImpl) Set

func (c *ClientImpl) Set(token string, value string)

func (*ClientImpl) Start

func (c *ClientImpl) Start(ctx context.Context, wg *sync.WaitGroup) error

Start Server

type ClientStateImpl

type ClientStateImpl struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ClientStateImpl maintains state which stores keys you hold

func NewClientStateImpl

func NewClientStateImpl() *ClientStateImpl

NewClientStateImpl is a support function

func (*ClientStateImpl) Add

func (s *ClientStateImpl) Add(token string, version uint64, status enum.Policy) bool

Add a token

func (*ClientStateImpl) Delete

func (s *ClientStateImpl) Delete(token string)

Delete by token

func (*ClientStateImpl) GetStatus

func (s *ClientStateImpl) GetStatus(token string) enum.Policy

GetStatus by token return Policy

func (*ClientStateImpl) GetVersion

func (s *ClientStateImpl) GetVersion(token string) uint64

GetVersion by token

func (*ClientStateImpl) Query

func (s *ClientStateImpl) Query(token string) bool

Query by token

type StorageImpl

type StorageImpl struct {
	sync.Mutex
	// contains filtered or unexported fields
}

StorageImpl is an type of storage using simple map and Mutex

func NewStorageImpl

func NewStorageImpl() *StorageImpl

func (*StorageImpl) Delete

func (s *StorageImpl) Delete(token string) error

Delete will delete key in map

func (*StorageImpl) Get

func (s *StorageImpl) Get(token string) (string, error)

Get value by key

func (*StorageImpl) Set

func (s *StorageImpl) Set(token string, value string)

Set key

type SyncRPCServer

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

SyncRPCServer implement method

func (*SyncRPCServer) Sync

func (s *SyncRPCServer) Sync(ctx context.Context, in *pb.SyncRequest) (*pb.SyncReply, error)

Sync data to other client

type UserClientImpl

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

UserClientImpl use context and RPC to implement UserClient

func NewUserClientImpl

func NewUserClientImpl(name string, clientHost string, clientPort string, serverHost string, c pb.MaintainerClient) *UserClientImpl

NewUserClientImpl is an support function for other package

func (*UserClientImpl) Close

func (c *UserClientImpl) Close()

Close use cancel function and wait all routine over

func (*UserClientImpl) Get

func (c *UserClientImpl) Get(token string) (string, error)

Get value by key

func (*UserClientImpl) Set

func (c *UserClientImpl) Set(token string, value string) error

Set value

func (*UserClientImpl) Start

func (c *UserClientImpl) Start() error

Start will init context and start statusClient

Jump to

Keyboard shortcuts

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