示例#1
0
	"crypto/tls"
	"errors"
	"io"
	"net"
	netrpc "net/rpc"
	"strings"
	"sync"
	"time"

	"github.com/stackengine/selog"
	"github.com/stackengine/serpc"
	"github.com/stackengine/ssltls"
)

var (
	sLog = selog.Register("svcrpc", 0)

	ErrAlreadyRegistered = errors.New("RPC Endpoint already registered")
	ErrMissingObject     = errors.New("Register needs an Object pointer ")
	ErrNoServer          = errors.New("No RPC server present ")
	ErrMissingName       = errors.New("name must have a value ")

	lck        sync.Mutex
	registered = make(map[string]interface{})
)

// This is only for testing.
func Nuke() {
	registered = make(map[string]interface{})
}
示例#2
0
	"crypto/tls"
	"fmt"
	"io"
	"net"
	netrpc "net/rpc"
	"strings"
	"sync"
	"sync/atomic"
	"time"

	"github.com/stackengine/selog"
	"github.com/stackengine/serpc"
	"github.com/stackengine/ssltls"
)

var sLog = selog.Register("clntrpc", 0)

type NewClientCodec func(conn io.ReadWriteCloser) netrpc.ClientCodec

type Conn struct {
	sync.Mutex

	addr           net.Addr
	key            string
	lastUsed       time.Time
	newClientCodec NewClientCodec
	net_con        net.Conn
	pool           *ConnPool
	refCount       int32
	rpc_clnt       *netrpc.Client
	shutdown       int32
示例#3
0
package rpc_stream

import (
	"errors"
	"fmt"
	"net"
	"strings"
	"sync"

	"github.com/stackengine/selog"
)

var (
	sLog = selog.Register("rpc_stream", 0)

	ErrMissingServFunc  = errors.New("Proto struct is missing serv function")
	ErrMissingName      = errors.New("Proto needs a name")
	ErrAlreadyExists    = errors.New("Proto already exists")
	ErrBadVersions      = errors.New("Mux version unsupported")
	ErrProtoUnsupported = errors.New("Proto not supported")
	ErrNoProto          = errors.New("Add must have a proto")
)

type MuxVersion uint8

const (
	UnknownVersion MuxVersion = iota
	Mux_v1
	Mux_v2
)