conpool

package
v0.0.0-...-9648343 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package conpool implements connection pooling based on assigning a context (typically, a channel) to a specific connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Con

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

Con is a single, reusable connection.

func (*Con) Connected

func (c *Con) Connected()

func (*Con) Disconnected

func (c *Con) Disconnected(err error)

func (*Con) ID

func (c *Con) ID() int

func (*Con) Message

func (c *Con) Message(msg *ircon.Message)

func (*Con) Send

func (c *Con) Send(s string)

func (*Con) Targets

func (c *Con) Targets() (r []string)

type Message

type Message = ircon.Message

type MessageHandler

type MessageHandler interface {
	Connected(c *Con)
	Message(c *Con, msg *ircon.Message)
	Disconnected(c *Con, err error)
}

A MessageHandler handles messages in the context of a connection, taking care not to block unnecessarily long.

type Pool

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

Pool is a pool of zero or more connections. Accessing the connection pool is not concurrency safe.

func New

func New(login, oauth string, mh MessageHandler) *Pool

func (*Pool) Assign

func (cp *Pool) Assign(cname string) *Con

Assign assigns a target to a connection.

func (*Pool) ConForTarget

func (cp *Pool) ConForTarget(target string) *Con

ConForTarget returns a connection session that (ideally) relates to the given target.

func (*Pool) Remove

func (cp *Pool) Remove(cname string) (*Con, bool)

Jump to

Keyboard shortcuts

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