servers

package
v0.3.1-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIVersion is the version of serving APIs.
	APIVersion = "v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPServer

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

HTTPServer is a http type server.

func NewHTTPServer

func NewHTTPServer(cache *caches.Cache, options *Options) (*HTTPServer, error)

NewHTTPServer returns a http server holder.

func (*HTTPServer) Run

func (hs *HTTPServer) Run() error

Run runs the server and returns an error if something wrong.

type Options

type Options struct {

	// Address is the address used to listen.
	Address string

	// Port is the port used to listen.
	Port int

	// ServerType is the type of server.
	ServerType string

	// VirtualNodeCount is the number of virtual nodes, which is set to consistent hash.
	VirtualNodeCount int

	// UpdateCircleDuration is the duration between two circle updating operations.
	// The unit is second.
	UpdateCircleDuration int

	// cluster is all nodes in cluster that will be joined.
	Cluster []string
}

Options is the options of servers.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns a default options.

type Server

type Server interface {

	// Run runs a server and returns ann error if something wrong.
	Run() error
}

Server is an interface of servers.

func NewServer

func NewServer(cache *caches.Cache, options Options) (Server, error)

NewServer returns a server of serverType.

type TCPClient

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

TCPClient is a tcp client for tcp server.

func NewTCPClient

func NewTCPClient(address string) (*TCPClient, error)

NewTCPClient returns a tcp client holder connected to address. Returns an error if failed.

func (*TCPClient) Close

func (tc *TCPClient) Close() (err error)

Close closes this client and returns an error if failed.

func (*TCPClient) Delete

func (tc *TCPClient) Delete(key string) error

Delete deletes the value of key and returns an error if failed.

func (*TCPClient) Get

func (tc *TCPClient) Get(key string) ([]byte, error)

Get returns the value of key and an error if failed.

func (*TCPClient) Nodes

func (tc *TCPClient) Nodes() ([]string, error)

Nodes returns the nodes of cluster and an error if failed.

func (*TCPClient) Set

func (tc *TCPClient) Set(key string, value []byte, ttl int64) error

Set adds the key and value with given ttl to cache. Returns an error if failed.

func (*TCPClient) Status

func (tc *TCPClient) Status() (*caches.Status, error)

Status returns the status of cache and an error if failed.

type TCPServer

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

TCPServer is a tcp type server.

func NewTCPServer

func NewTCPServer(cache *caches.Cache, options *Options) (*TCPServer, error)

NewTCPServer returns a tcp server holder.

func (*TCPServer) Close

func (ts *TCPServer) Close() error

Close closes the server and releases resources.

func (*TCPServer) Run

func (ts *TCPServer) Run() error

Run runs the server and returns an error if something wrong.

Jump to

Keyboard shortcuts

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