options

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: BSD-3-Clause Imports: 3 Imported by: 57

Documentation

Overview

Package options defines common options recognized by vanadium implementations.

Below are the common options required of all vanadium implementations. Let's say we have functions MyFuncA and MyFuncB in package demo:

package demo
func MyFuncA(a, b, c int, opts ...MyFuncAOpt)
func MyFuncB(opts ...MyFuncBOpt)

type MyFuncAOpt interface {
  DemoMyFuncAOpt()
}
type MyFuncBOpt interface {
  DemoMyFuncBOpt()
}

The MyFuncAOpt interface is used solely to constrain the types of options that MyFuncA accepts, and ditto for MyFuncBOpt and MyFuncB. In order to enable an option to be accepted by a particular function, you simply add a no-op function definition with the appropriate name. An example:

type Foo int
func (Foo) DemoMyFuncAOpt() {}
func (Foo) DemoMyFuncBOpt() {}

type Bar string
func (Bar) DemoMyFuncBOpt() {}

Foo is accepted by both demo.MyFuncA and demo.MyFuncB, while Bar is only accepted by demo.MyFuncB. The methods defined for each option essentially act as annotations telling us which functions will accept them.

Go stipulates that methods may only be attached to named types, and the type may not be an interface. E.g.

// BAD: can't attach methods to named interfaces.
type Bad interface{}
func (Bad) DemoMyFuncAOpt() {}

// GOOD: wrap the interface in a named struct.
type Good struct { val interface{} }

func (Good) DemoMyFuncAOpt() {}

These options can then be passed to the function as so:

MyFuncA(a, b, c, Foo(1), Good{object})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelTimeout

type ChannelTimeout time.Duration

ChannelTimeout is the amount of time before we notice that a channel is not responsive and close it. Note that ChannelTimeout(0) is the same as not setting a timeout.

func (ChannelTimeout) RPCCallOpt

func (ChannelTimeout) RPCCallOpt()

func (ChannelTimeout) RPCServerOpt

func (ChannelTimeout) RPCServerOpt()

type ConnectionTimeout

type ConnectionTimeout time.Duration

ConnectionTimeout is the amount of time we will try establishing a connection to the remote end during an RPC. Zero means only use cached connections and do not attempt to retry if no connection exists in the cache.

func (ConnectionTimeout) RPCCallOpt

func (ConnectionTimeout) RPCCallOpt()

type IsLeaf

type IsLeaf bool

Create a server that will be used to serve a leaf service.

func (IsLeaf) RPCServerOpt

func (IsLeaf) RPCServerOpt()

type LameDuckTimeout

type LameDuckTimeout time.Duration

LameDuckTimeout specifies the time to wait for all server operations to complete after Stop is called.

func (LameDuckTimeout) RPCServerOpt

func (LameDuckTimeout) RPCServerOpt()

type NameResolutionAuthorizer

type NameResolutionAuthorizer struct{ security.Authorizer }

NameResolutionAuthorizer encapsulates the authorization policy used by a client to authorize mounttable servers before sending them a name resolution request. By specifying this policy, clients avoid revealing the names they are interested in resolving to unauthorized mounttables.

If no such option is provided, then runtime implementations are expected to default to security.EndpointAuthorizer.

func (NameResolutionAuthorizer) NSOpt

func (NameResolutionAuthorizer) NSOpt()

func (NameResolutionAuthorizer) RPCCallOpt

func (NameResolutionAuthorizer) RPCCallOpt()

type NoRetry

type NoRetry struct{}

When NoRetry is specified, the client will not retry calls that fail but would normally be retried.

func (NoRetry) NSOpt

func (NoRetry) NSOpt()

func (NoRetry) RPCCallOpt

func (NoRetry) RPCCallOpt()

type Preresolved

type Preresolved struct {
	Resolution *naming.MountEntry
}

Preresolved specifies that the RPC call should not further Resolve the name. If a MountEntry is provided, use it. Otherwise use the name passed in the RPC call. If the name is relative, it will be made global using the roots in the namespace.

func (Preresolved) NSOpt

func (Preresolved) NSOpt()

func (Preresolved) RPCCallOpt

func (Preresolved) RPCCallOpt()

type ServerAuthorizer

type ServerAuthorizer struct{ security.Authorizer }

ServerAuthorizer encapsulates the authorization policy used by a client to authorize the end server of an RPC.

This policy is applied before the client sends information about itself (public key, blessings, the RPC request) to the server. Thus, if a server does not satisfy this policy then the client will abort the request.

Authorization of other servers communicated with in the process of contacting the end server are controlled by other options, like NameResolutionAuthorizer.

Runtime implementations are expected to use security.EndpointAuthorizer if no explicit ServerAuthorizer has been provided for the call.

func (ServerAuthorizer) RPCCallOpt

func (ServerAuthorizer) RPCCallOpt()

type ServerPeers

type ServerPeers []security.BlessingPattern

ServerPeers is the set of peers to whom a process (a "server") accepting network connections must reveal its blessings.

If this option is not provided, then the server's blessings will be revealed to all processes (clients) from whom the server accepts network connections.

NOTE: This is an experimental option and may go away at any time.

func (ServerPeers) RPCServerOpt

func (ServerPeers) RPCServerOpt()

type ServesMountTable

type ServesMountTable bool

Create a server that will be used to serve a MountTable. This server cannot be used for any other purpose.

func (ServesMountTable) RPCServerOpt

func (ServesMountTable) RPCServerOpt()

Jump to

Keyboard shortcuts

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