internal

package
v0.0.0-...-f3666bb Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2016 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PipeChannelBuffSize int = 10
	PipeAcksMaxSize     int = 100
)

Variables

View Source
var (
	ErrVersionNotSupported       = grpc.Errorf(codes.Aborted, "version not supported")
	ErrSessionLoss         error = grpc.Errorf(codes.InvalidArgument, "session loss")
	ErrChannelLoss         error = grpc.Errorf(codes.InvalidArgument, "channel loss")
	ErrSessionInvaild      error = grpc.Errorf(codes.PermissionDenied, "session invaild")
	ErrChannelInvaild      error = grpc.Errorf(codes.PermissionDenied, "channel invaild")
	ErrAckTimeout          error = grpc.Errorf(codes.Canceled, "ack timeout")
)

Functions

func IoExchange

func IoExchange(a, b io.ReadWriteCloser, done chan struct{}) (err error)

Types

type AgentClientState

type AgentClientState int
const (
	Idle    AgentClientState = iota
	Offline                  //connecting
	//	Online		//need login
	Logoff
	Logon
	Die
)

type Client

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

func NewClient

func NewClient(target string, opts ...grpc.DialOption) (client *Client, err error)

func (*Client) Close

func (client *Client) Close() (err error)

func (*Client) CloseWithError

func (client *Client) CloseWithError(err error) error

func (*Client) Dial

func (client *Client) Dial(network, address string) (conn net.Conn, err error)

func (*Client) Err

func (client *Client) Err() (err error)

func (*Client) Multiplexing

func (client *Client) Multiplexing() int32

func (*Client) Ping

func (client *Client) Ping() (err error)

func (*Client) State

func (client *Client) State() AgentClientState

func (*Client) Wait

func (client *Client) Wait(ctx context.Context) (err error)

blocks until the client is logon or ctx is done

func (*Client) WaitForStateChange

func (client *Client) WaitForStateChange(ctx context.Context, sourceState AgentClientState) (state AgentClientState, err error)

blocks until the state change, or context is done

type ClientConn

type ClientConn struct {
	agent.AgentClient
	// contains filtered or unexported fields
}

func Dial

func Dial(target string, opts ...grpc.DialOption) (cc *ClientConn, err error)

func (*ClientConn) Close

func (cc *ClientConn) Close() (err error)

func (*ClientConn) Fork

func (cc *ClientConn) Fork() *ClientConn

func (*ClientConn) Ref

func (cc *ClientConn) Ref() int32

func (*ClientConn) State

func (cc *ClientConn) State() (grpc.ConnectivityState, error)

func (*ClientConn) WaitForStateChange

func (cc *ClientConn) WaitForStateChange(ctx context.Context, sourceState grpc.ConnectivityState) (grpc.ConnectivityState, error)

type Server

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

func NewServer

func NewServer() *Server

func (*Server) Connect

func (srv *Server) Connect(ctx context.Context, req *agent.ConnectRequest) (reply *agent.ConnectReply, err error)

func (*Server) Exchange

func (srv *Server) Exchange(stream agent.Agent_ExchangeServer) (err error)

bidirection stream procedure client must ack

func (*Server) Heartbeat

func (srv *Server) Heartbeat(ctx context.Context, ping *agent.Ping) (pong *agent.Pong, err error)

call procedure

func (*Server) Hello

func (srv *Server) Hello(ctx context.Context, req *agent.HelloRequest) (reply *agent.HelloReply, err error)

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe(network, address string, opts ...grpc.ServerOption) (err error)

type Session

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

type StreamPipe

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

wrap grpc stream as net.Conn

func NewStreamPipe

func NewStreamPipe(stream agentStream) *StreamPipe

func (*StreamPipe) Attach

func (pipe *StreamPipe) Attach(cc *ClientConn)

func (*StreamPipe) Close

func (pipe *StreamPipe) Close() (err error)

func (*StreamPipe) CloseWithError

func (pipe *StreamPipe) CloseWithError(err error) error

func (*StreamPipe) Err

func (pipe *StreamPipe) Err() (err error)

func (*StreamPipe) LocalAddr

func (pipe *StreamPipe) LocalAddr() net.Addr

func (*StreamPipe) Read

func (pipe *StreamPipe) Read(buf []byte) (n int, err error)

unsafe

func (*StreamPipe) RemoteAddr

func (pipe *StreamPipe) RemoteAddr() net.Addr

func (*StreamPipe) SetDeadline

func (pipe *StreamPipe) SetDeadline(t time.Time) error

func (*StreamPipe) SetReadDeadline

func (pipe *StreamPipe) SetReadDeadline(t time.Time) error

func (*StreamPipe) SetWriteDeadline

func (pipe *StreamPipe) SetWriteDeadline(t time.Time) error

func (*StreamPipe) Write

func (pipe *StreamPipe) Write(buf []byte) (n int, err error)

unsafe

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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