예제 #1
0
파일: server.go 프로젝트: stackengine/serpc
	"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
파일: client.go 프로젝트: stackengine/serpc
	"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
파일: stream.go 프로젝트: stackengine/serpc
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
)