vine

package
v0.0.0-...-ba1c585 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package vine contains Vanadium's Implementation of Network Emulation (VINE). VINE provides the ability to dynamically specific a network topology (e.g. A can reach B, but A cannot reach C) with various network charcteristics (e.g. A can reach B with latency of 500ms). This can be useful for testing Vanadium applications under unpredictable and unfriendly network conditions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAddress       = verror.Register("v.io/x/ref/runtime/protocols/vine.InvalidAddress", verror.NoRetry, "{1:}{2:} invalid vine address {3}, address must be of the form 'network/address/tag'")
	ErrAddressNotReachable  = verror.Register("v.io/x/ref/runtime/protocols/vine.AddressNotReachable", verror.NoRetry, "{1:}{2:} address {3} not reachable")
	ErrNoRegisteredProtocol = verror.Register("v.io/x/ref/runtime/protocols/vine.NoRegisteredProtocol", verror.NoRetry, "{1:}{2:} no registered protocol {3}")
	ErrCantAcceptFromTag    = verror.Register("v.io/x/ref/runtime/protocols/vine.CantAcceptFromTag", verror.NoRetry, "{1:}{2:} can't accept connection from tag {3}")
)
View Source
var VineDesc rpc.InterfaceDesc = descVine

VineDesc describes the Vine interface.

Functions

func Init

func Init(ctx *context.T, name string, auth security.Authorizer, localTag string, discoveryTTL time.Duration) (*context.T, func(), error)

Init initializes the vine server mounted under name using auth as its authorization policy and registers the vine protocol. discoveryTTL specifies the ttl of scanned advertisings for the vine discovery plugin. The ctx returned from Init: (1) has localTag as the default localTag for dialers and acceptors. (2) has all addresses in the listenspec altered to listen on the vine protocol.

func NewErrAddressNotReachable

func NewErrAddressNotReachable(ctx *context.T, address string) error

NewErrAddressNotReachable returns an error with the ErrAddressNotReachable ID.

func NewErrCantAcceptFromTag

func NewErrCantAcceptFromTag(ctx *context.T, tag string) error

NewErrCantAcceptFromTag returns an error with the ErrCantAcceptFromTag ID.

func NewErrInvalidAddress

func NewErrInvalidAddress(ctx *context.T, address string) error

NewErrInvalidAddress returns an error with the ErrInvalidAddress ID.

func NewErrNoRegisteredProtocol

func NewErrNoRegisteredProtocol(ctx *context.T, protocol string) error

NewErrNoRegisteredProtocol returns an error with the ErrNoRegisteredProtocol ID.

func WithLocalTag

func WithLocalTag(ctx *context.T, tag string) *context.T

WithLocalTag returns a ctx that will have localTag as the default localTag for dialers and acceptors. This local tag will be inserted into any listening endpoints. i.e "net/address" -> "net/address/tag"

Types

type PeerBehavior

type PeerBehavior struct {
	// Reachable specifies whether the outgoing or incoming connection can be
	// dialed or accepted.
	// TODO(suharshs): Make this a user defined error which vine will return instead of a bool.
	Reachable bool
	// Discoverable specifies whether the Dialer can advertise a discovery packet
	// to the Acceptor. This is useful for emulating neighborhoods.
	// TODO(suharshs): Discoverable should always be bidirectional. It is unrealistic for
	// A to discover B, but not vice versa.
	Discoverable bool
}

PeerBehavior specifies characteristics of a connection.

func (PeerBehavior) VDLIsZero

func (x PeerBehavior) VDLIsZero() bool

func (*PeerBehavior) VDLRead

func (x *PeerBehavior) VDLRead(dec vdl.Decoder) error

func (PeerBehavior) VDLReflect

func (PeerBehavior) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/runtime/protocols/vine.PeerBehavior"`
})

func (PeerBehavior) VDLWrite

func (x PeerBehavior) VDLWrite(enc vdl.Encoder) error

type PeerKey

type PeerKey struct {
	Dialer   string
	Acceptor string
}

PeerKey is a key that represents a connection from a Dialer tag to an Acceptor tag.

func (PeerKey) VDLIsZero

func (x PeerKey) VDLIsZero() bool

func (*PeerKey) VDLRead

func (x *PeerKey) VDLRead(dec vdl.Decoder) error

func (PeerKey) VDLReflect

func (PeerKey) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/runtime/protocols/vine.PeerKey"`
})

func (PeerKey) VDLWrite

func (x PeerKey) VDLWrite(enc vdl.Encoder) error

type VineClientMethods

type VineClientMethods interface {
	// SetBehaviors sets the policy that the accepting vine service's process
	// will use on connections.
	// behaviors is a map from server tag to the desired connection behavior.
	// For example,
	//   client.SetBehaviors(map[PeerKey]PeerBehavior{PeerKey{"foo", "bar"}, PeerBehavior{Reachable: false}})
	// will cause all vine protocol dial calls from "foo" to "bar" to fail.
	SetBehaviors(_ *context.T, behaviors map[PeerKey]PeerBehavior, _ ...rpc.CallOpt) error
}

VineClientMethods is the client interface containing Vine methods.

Vine is the interface to a vine service that can dynamically change the network behavior of connection's on the vine service's process.

type VineClientStub

type VineClientStub interface {
	VineClientMethods
	rpc.UniversalServiceMethods
}

VineClientStub adds universal methods to VineClientMethods.

func VineClient

func VineClient(name string) VineClientStub

VineClient returns a client stub for Vine.

type VineServerMethods

type VineServerMethods interface {
	// SetBehaviors sets the policy that the accepting vine service's process
	// will use on connections.
	// behaviors is a map from server tag to the desired connection behavior.
	// For example,
	//   client.SetBehaviors(map[PeerKey]PeerBehavior{PeerKey{"foo", "bar"}, PeerBehavior{Reachable: false}})
	// will cause all vine protocol dial calls from "foo" to "bar" to fail.
	SetBehaviors(_ *context.T, _ rpc.ServerCall, behaviors map[PeerKey]PeerBehavior) error
}

VineServerMethods is the interface a server writer implements for Vine.

Vine is the interface to a vine service that can dynamically change the network behavior of connection's on the vine service's process.

type VineServerStub

type VineServerStub interface {
	VineServerStubMethods
	// Describe the Vine interfaces.
	Describe__() []rpc.InterfaceDesc
}

VineServerStub adds universal methods to VineServerStubMethods.

func VineServer

func VineServer(impl VineServerMethods) VineServerStub

VineServer returns a server stub for Vine. It converts an implementation of VineServerMethods into an object that may be used by rpc.Server.

type VineServerStubMethods

type VineServerStubMethods VineServerMethods

VineServerStubMethods is the server interface containing Vine methods, as expected by rpc.Server. There is no difference between this interface and VineServerMethods since there are no streaming methods.

Jump to

Keyboard shortcuts

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