dispatch

package
v1.1.2-pre Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package dispatch 通讯层,应用层发出请求通过通讯层的抽象。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {

	// Start 启动
	// 会根据不同的dispatch调用不同的初始化,例如link会调Link,set会调Listen
	Start(addr string) error

	// Send 发送一个帧
	// 发送一个帧出去,在不同的集群模式下有不同的表现
	// - default:
	// 发送到服务中心
	// - other:
	// 未实现
	Send(frame frame.Frame) error

	// SendTo 发送帧到指定连接
	SendTo(connID string, f frame.Frame) error

	// Close 释放资源
	Close()

	// Hook 对某些地方进行hook
	// 目前可以hook的:
	// - close
	Hook(typ string, hookFunc interface{})

	// Handle 对某些地方添加一个handle func来处理一些情况。
	// example:
	// dp.Handle("request",func(f *frame.Response) { fmt.Println(f) })
	// 目前可以handle的:
	// - frame
	// - proxy
	// - ctrl
	Handle(typ string, handleFunc interface{})

	// Upgrade 将连接进行升级
	Upgrade(connID string, addr string) error
}

Dispatcher 通讯层的对外暴露的接口

func NewLinkedByDefaultCluster

func NewLinkedByDefaultCluster() Dispatcher

NewByDefaultCluster 在default cluster模式下创建一个dispatch

func NewSetByDefaultCluster

func NewSetByDefaultCluster() Dispatcher

NewSetByDefaultCluster 在default cluster模式下创建一个dispatch

Directories

Path Synopsis
Package conn 底层的连接的抽象
Package conn 底层的连接的抽象
Package frame 用于在通讯层使用的frame
Package frame 用于在通讯层使用的frame

Jump to

Keyboard shortcuts

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