wsp

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONNECTING = iota
	IDLE
	RUNNING
)

Status of a Connection

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client connects to one or more Server using HTTP websockets. The Server can then send HTTP requests to execute.

func NewClient

func NewClient(cfg *Config, api *api.Api, stream *stream.Stream, adaptors *adaptors.Adaptors, jwtManager jwt_manager.JwtManager) *Client

NewClient creates a new Client.

func (*Client) Shutdown

func (c *Client) Shutdown()

Shutdown the Proxy

func (*Client) Start

func (c *Client) Start(ctx context.Context)

Start the Proxy

type Config

type Config struct {
	ID           string
	Targets      []string
	PoolIdleSize int
	PoolMaxSize  int
	SecretKey    string
}

type Connection

type Connection struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

Connection handle a single websocket (HTTP/TCP) connection to an Server

func NewConnection

func NewConnection(pool *Pool,
	api *api.Api,
	stream *stream.Stream) *Connection

NewConnection create a Connection object

func (*Connection) Close

func (c *Connection) Close()

Close close the ws/tcp connection and remove it from the pool

func (*Connection) Connect

func (c *Connection) Connect(ctx context.Context) (err error)

Connect to the IsolatorServer using a HTTP websocket

func (*Connection) WriteMessage added in v0.14.0

func (c *Connection) WriteMessage(messageType int, data []byte) (err error)

type Pool

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

Pool manage a pool of connection to a remote Server

func NewPool

func NewPool(client *Client, target string,
	secretKey string,
	api *api.Api,
	stream *stream.Stream,
	adaptors *adaptors.Adaptors,
	jwtManager jwt_manager.JwtManager) *Pool

NewPool creates a new Pool

func (*Pool) GetUser

func (p *Pool) GetUser(accessToken string) (user *m.User, err error)

func (*Pool) Shutdown

func (p *Pool) Shutdown()

Shutdown close all connection in the pool

func (*Pool) Size

func (p *Pool) Size() (poolSize *PoolSize)

Size return the current state of the pool

func (*Pool) Start

func (p *Pool) Start(ctx context.Context)

Start connect to the remote Server

type PoolSize

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

PoolSize represent the number of open connections per status

func (*PoolSize) String

func (poolSize *PoolSize) String() string

type Status

type Status struct {
	Connecting int
	Idle       int
	Running    int
	Total      int
}

Jump to

Keyboard shortcuts

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