manager

package
v1.13.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDialAddressPrefix

func GetDialAddressPrefix(mode modes.DaprMode) string

GetDialAddressPrefix returns a dial prefix for a gRPC client connections for a given DaprMode. This is used on non-Windows hosts.

Types

type AppChannelConfig

type AppChannelConfig struct {
	Port                 int
	MaxConcurrency       int
	TracingSpec          config.TracingSpec
	EnableTLS            bool
	MaxRequestBodySizeMB int
	ReadBufferSizeKB     int
	BaseAddress          string
}

AppChannelConfig contains the configuration for the app channel.

type ConnCreatorFn

type ConnCreatorFn = func() (grpc.ClientConnInterface, error)

ConnCreatorFn is a function that returns a gRPC connection

type ConnectionPool

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

ConnectionPool holds a pool of connections to the same address.

func NewConnectionPool

func NewConnectionPool(maxConnIdle time.Duration, minActiveConns int) *ConnectionPool

NewConnectionPool creates a new ConnectionPool object.

func (*ConnectionPool) Destroy

func (p *ConnectionPool) Destroy(conn grpc.ClientConnInterface)

Destroy a connection, forcibly removing it from the pool

func (*ConnectionPool) DestroyAll

func (p *ConnectionPool) DestroyAll()

DestroyAll closes all connections in the poll.

func (*ConnectionPool) Get

func (p *ConnectionPool) Get(createFn func() (grpc.ClientConnInterface, error)) (conn grpc.ClientConnInterface, err error)

Get takes a connection from the pool or, if no connection exists, creates a new one using createFn, then stores it and returns it.

func (*ConnectionPool) Purge

func (p *ConnectionPool) Purge()

Purge connections that have been idle for longer than maxConnIdle. Note that this method should not be called by multiple goroutines at the same time.

func (*ConnectionPool) Register

func (p *ConnectionPool) Register(conn grpc.ClientConnInterface)

Register a new connection.

func (*ConnectionPool) Release

func (p *ConnectionPool) Release(conn grpc.ClientConnInterface)

Release is called when the method has finished using the connection. This decrements the reference counter for the connection.

func (*ConnectionPool) Share

Share takes a connection from the pool and increments its reference count. The result can be nil if no available connection can be found.

type Manager

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

Manager is a wrapper around gRPC connection pooling.

func NewManager

func NewManager(sec security.Handler, mode modes.DaprMode, channelConfig *AppChannelConfig) *Manager

NewManager returns a new grpc manager.

func (*Manager) Close

func (g *Manager) Close() error

func (*Manager) GetAppChannel

func (g *Manager) GetAppChannel() (channel.AppChannel, error)

GetAppChannel returns a connection to the local channel. If there's no active connection to the app, it creates one.

func (*Manager) GetAppClient

func (g *Manager) GetAppClient() (grpc.ClientConnInterface, error)

GetAppClient returns the gRPC connection to the local app. If there's no active connection to the app, it creates one.

func (*Manager) GetGRPCConnection

func (g *Manager) GetGRPCConnection(
	parentCtx context.Context,
	address string,
	id string,
	namespace string,
	customOpts ...grpc.DialOption,
) (conn *grpc.ClientConn, teardown func(destroy bool), err error)

GetGRPCConnection returns a new grpc connection for a given address and inits one if doesn't exist.

func (*Manager) SetAppClientConn

func (g *Manager) SetAppClientConn(conn grpc.ClientConnInterface)

SetAppClientConn is used by tests to override the default connection

func (*Manager) StartCollector

func (g *Manager) StartCollector()

StartCollector starts a background goroutine that periodically watches for expired connections and purges them.

type RemoteConnectionPool

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

RemoteConnectionPool is used to hold connections to remote addresses.

func NewRemoteConnectionPool

func NewRemoteConnectionPool() *RemoteConnectionPool

NewRemoteConnectionPool creates a new RemoteConnectionPool object.

func (*RemoteConnectionPool) Destroy

func (p *RemoteConnectionPool) Destroy(address string, conn grpc.ClientConnInterface)

Destroy a connection, forcibly removing ti from the pool

func (*RemoteConnectionPool) Get

func (p *RemoteConnectionPool) Get(address string, createFn func() (grpc.ClientConnInterface, error)) (conn grpc.ClientConnInterface, err error)

Get takes a connection from the pool or, if no connection exists, creates a new one using createFn, then stores it and returns it.

func (*RemoteConnectionPool) Purge

func (p *RemoteConnectionPool) Purge()

Purge connections that have been idle for longer than maxConnIdle. Note that this method should not be called by multiple goroutines at the same time.

func (*RemoteConnectionPool) Register

func (p *RemoteConnectionPool) Register(address string, conn grpc.ClientConnInterface)

Register a new connection.

func (*RemoteConnectionPool) Release

func (p *RemoteConnectionPool) Release(address string, conn grpc.ClientConnInterface)

Release is called when the method has finished using the connection. This decrements the reference counter for the connection.

func (*RemoteConnectionPool) Share

Share takes a connection from the pool and increments its reference count. The result can be nil if no available connection can be found.

Jump to

Keyboard shortcuts

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