aqua

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: MIT Imports: 3 Imported by: 0

README

Aquaman

996.icu

中间件管理器

简介

集于单个进程中的中间件管理,定义所需中间件,注册到管理器中,即可使用

使用

package main

import (
	aqua "github.com/Justyer/Aquaman"
	plg "github.com/Justyer/Aquaman/plugin"
)

func main() {
	// 新建中间件节点
	fetch_node := aqua.NewMWNode("fetch", plg.NewFetch, 1, 100)
	download_node := aqua.NewMWNode("download", plg.NewDownload, 1, 100)
	transfer_node := aqua.NewMWNode("transfer", plg.NewTransfer, 1, 100)

	// 将中间件插入到前一个中间件上
	fetch_node.NextNode(download_node)
	download_node.NextNode(transfer_node)

	// 注册业务线
	mwm.Register(fetch_node)

	// 启动相应业务线
	mwm.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Carrior

type Carrior struct {
	Data []byte
}

载体

type Chan

type Chan struct {
	CHL     chan *Carrior
	CHL2    chan *Carrior
	CHL_USE bool
}

func NewChan

func NewChan() *Chan

func (*Chan) Active

func (c *Chan) Active() chan *Carrior

func (*Chan) Close

func (c *Chan) Close()

func (*Chan) Free

func (c *Chan) Free() chan *Carrior

func (*Chan) Init

func (c *Chan) Init(chl_size int)

func (*Chan) Pop

func (c *Chan) Pop(f func(*Carrior))

有问题,暂停使用

func (*Chan) Push

func (c *Chan) Push(e *Carrior)

func (*Chan) SetFree

func (c *Chan) SetFree(cr chan *Carrior)

func (*Chan) Switch

func (c *Chan) Switch()

type MWHandler

type MWHandler func() MiddleManager

type MWNode

type MWNode struct {
	Name         string
	Create       MWHandler
	GRT_NUM      int
	CHL_SIZE     int
	ClosedGRTNum int64
	Instances    []MiddleManager
	Next         *MWNode
}

单个中间件及配置

func NewMWNode

func NewMWNode(mn string, f MWHandler, num int, size int) *MWNode

func (*MWNode) NextNode

func (n *MWNode) NextNode(mwn *MWNode)

type MiddleManager

type MiddleManager interface {
	SetMWNode(mwn *MWNode)
	SetInChan(in *Chan)
	SetOutChan(out *Chan)
	GetInChan() *Chan
	GetOutChan() *Chan
	Run(int)
}

type MiddlewareManager

type MiddlewareManager struct {
	TXL *MWNode
	// contains filtered or unexported fields
}

中间件管理器

func NewMWManager

func NewMWManager() *MiddlewareManager

func (*MiddlewareManager) ChangeChanBufferSize

func (mgr *MiddlewareManager) ChangeChanBufferSize(mn string, chl_size int) error

修改缓冲区大小

func (*MiddlewareManager) DropMW

func (mgr *MiddlewareManager) DropMW(mn string) error

拔出某个中间件

func (*MiddlewareManager) InsertMWBack

func (mgr *MiddlewareManager) InsertMWBack(mn string, nn *MWNode) error

在某个中间件的前面插入添加的中间件

func (*MiddlewareManager) MWIter

func (mgr *MiddlewareManager) MWIter(ii string)

遍历当前业务线的中间件组成

func (*MiddlewareManager) Register

func (mgr *MiddlewareManager) Register(mwn *MWNode)

注册业务线

func (*MiddlewareManager) Run added in v0.2.0

func (mgr *MiddlewareManager) Run()

根据业务线名字执行任务

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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