grpc

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: AGPL-3.0 Imports: 15 Imported by: 2

Documentation

Overview

Package grpc provides grpc utilities.

Index

Constants

This section is empty.

Variables

View Source
var DefaultWebRTCConfiguration = webrtc.Configuration{
	ICEServers: []webrtc.ICEServer{
		{
			URLs: []string{"stun:global.stun.twilio.com:3478"},
		},
	},
}

DefaultWebRTCConfiguration is the default configuration to use.

View Source
var UnimplementedError = status.Error(codes.Unimplemented, codes.Unimplemented.String())

UnimplementedError is returned any time a gRPC method is unimplemented.

Functions

func Dial

func Dial(ctx context.Context, address string, logger logging.Logger, opts ...rpc.DialOption) (rpc.ClientConn, error)

Dial dials a gRPC server. `ctx` can be used to set a timeout/deadline for Dial. However, the signaling server may have other timeouts which may prevent the full timeout from being respected.

func InferSignalingServerAddress

func InferSignalingServerAddress(address string) (string, bool, bool)

InferSignalingServerAddress returns the appropriate WebRTC signaling server address if it can be detected. Returns the address, if the endpoint is secure, and if found. TODO(RSDK-235): remove hard coding of signaling server address and prefer SRV lookup instead.

Types

type ForeignResource

type ForeignResource struct {
	resource.Named
	resource.TriviallyCloseable
	// contains filtered or unexported fields
}

An ForeignResource is used to dynamically invoke RPC calls to resources that have their RPC information dervied on demand.

func NewForeignResource

func NewForeignResource(name resource.Name, conn rpc.ClientConn) *ForeignResource

NewForeignResource returns an ForeignResource for the given resource name and connection serving it.

func (*ForeignResource) NewStub

func (res *ForeignResource) NewStub() grpcdynamic.Stub

NewStub returns a new gRPC client stub used to communicate with the resource.

func (*ForeignResource) Reconfigure added in v0.2.36

func (res *ForeignResource) Reconfigure(ctx context.Context, deps resource.Dependencies, conf resource.Config) error

Reconfigure always fails.

type OnTrackCB added in v0.24.0

type OnTrackCB func(tr *webrtc.TrackRemote, r *webrtc.RTPReceiver)

OnTrackCB is the signature of the OnTrack callback function a resource may register with a SharedConn which supports WebRTC.

type ReconfigurableClientConn added in v0.21.2

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

ReconfigurableClientConn allows for the underlying client connections to be swapped under the hood.

func (*ReconfigurableClientConn) Close added in v0.21.2

func (c *ReconfigurableClientConn) Close() error

Close attempts to close the underlying client connection if there is one.

func (*ReconfigurableClientConn) Invoke added in v0.21.2

func (c *ReconfigurableClientConn) Invoke(
	ctx context.Context,
	method string,
	args, reply interface{},
	opts ...googlegrpc.CallOption,
) error

Invoke invokes using the underlying client connection. In the case of c.conn being closed in the middle of an Invoke call, it is expected that c.conn can handle that and return a well-formed error.

func (*ReconfigurableClientConn) NewStream added in v0.21.2

NewStream creates a new stream using the underlying client connection. In the case of c.conn being closed in the middle of a NewStream call, it is expected that c.conn can handle that and return a well-formed error.

func (*ReconfigurableClientConn) PeerConn added in v0.24.0

func (c *ReconfigurableClientConn) PeerConn() *webrtc.PeerConnection

PeerConn returns the backing PeerConnection object, if applicable. Nil otherwise.

func (*ReconfigurableClientConn) ReplaceConn added in v0.21.2

func (c *ReconfigurableClientConn) ReplaceConn(conn rpc.ClientConn)

ReplaceConn replaces the underlying client connection with the connection passed in. This does not close the old connection, the caller is expected to close it if needed.

type SharedConn added in v0.24.0

type SharedConn struct {
	*ReconfigurableClientConn
	// contains filtered or unexported fields
}

SharedConn wraps both a GRPC connection & (optionally) a peer connection & controls access to both. For modules, the grpc connection is over a Unix socket. The WebRTC `PeerConnection` is made separately. The `SharedConn` continues to implement the `rpc.ClientConn` interface by pairing up the two underlying connections a client may want to communicate over.

func NewSharedConn added in v0.24.0

func NewSharedConn(conn *ReconfigurableClientConn, peerConn *webrtc.PeerConnection, logger logging.Logger) *SharedConn

NewSharedConn returns a SharedConnection which manages access to both a grpc client conntection & (optionally) a webrtc peer connection.

func (*SharedConn) AddOnTrackSub added in v0.24.0

func (sc *SharedConn) AddOnTrackSub(name resource.Name, onTrackCB OnTrackCB)

AddOnTrackSub adds an OnTrack subscription for the resource.

func (*SharedConn) Close added in v0.24.0

func (sc *SharedConn) Close() error

Close closes a shared connection.

func (*SharedConn) PeerConn added in v0.24.0

func (sc *SharedConn) PeerConn() *webrtc.PeerConnection

PeerConn returns the PeerConnection.

func (*SharedConn) RemoveOnTrackSub added in v0.24.0

func (sc *SharedConn) RemoveOnTrackSub(name resource.Name)

RemoveOnTrackSub removes an OnTrack subscription for the resource.

Jump to

Keyboard shortcuts

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