network

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

网络领域组件编程规范

1.领域上下文。

2.对外暴露接口。

3.驱动组件约束接口。

4.公共数据结构。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Drivers

func Drivers() []string

Drivers returns a sorted list of the names of the registered drivers.

func Register

func Register(name string, f NewP2PServFunc)

Register makes a driver available by the provided name. If Register is called twice with the same name or if driver is nil,it panics.

Types

type Network

type Network interface {
	Start()
	Stop()

	SendMessage(xctx.XContext, *pb.XuperMessage, ...p2p.OptionFunc) error
	SendMessageWithResponse(xctx.XContext, *pb.XuperMessage,
		...p2p.OptionFunc) ([]*pb.XuperMessage, error)

	NewSubscriber(pb.XuperMessage_MessageType, interface{}, ...p2p.SubscriberOption) p2p.Subscriber
	Register(p2p.Subscriber) error
	UnRegister(p2p.Subscriber) error

	Context() *nctx.NetCtx
	PeerInfo() pb.PeerInfo
}

network对外提供的接口

func NewNetwork

func NewNetwork(ctx *nctx.NetCtx) (Network, error)

type NetworkImpl

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

如果有领域内公共逻辑,可以在这层扩展,对上层暴露高级接口 暂时没有特殊的逻辑,先简单透传,预留方便后续扩展

func (*NetworkImpl) Context

func (t *NetworkImpl) Context() *nctx.NetCtx

func (*NetworkImpl) NewSubscriber

func (t *NetworkImpl) NewSubscriber(typ pb.XuperMessage_MessageType, v interface{},
	opts ...p2p.SubscriberOption) p2p.Subscriber

func (*NetworkImpl) PeerInfo

func (t *NetworkImpl) PeerInfo() pb.PeerInfo

func (*NetworkImpl) Register

func (t *NetworkImpl) Register(sub p2p.Subscriber) error

func (*NetworkImpl) SendMessage

func (t *NetworkImpl) SendMessage(ctx xctx.XContext, msg *pb.XuperMessage, opts ...p2p.OptionFunc) error

func (*NetworkImpl) SendMessageWithResponse

func (t *NetworkImpl) SendMessageWithResponse(ctx xctx.XContext, msg *pb.XuperMessage,
	opts ...p2p.OptionFunc) ([]*pb.XuperMessage, error)

func (*NetworkImpl) Start

func (t *NetworkImpl) Start()

func (*NetworkImpl) Stop

func (t *NetworkImpl) Stop()

func (*NetworkImpl) UnRegister

func (t *NetworkImpl) UnRegister(sub p2p.Subscriber) error

type NewP2PServFunc

type NewP2PServFunc func() p2p.Server

创建P2PServer实例方法

Directories

Path Synopsis
明确定义该模块需要的上下文信息,方便代码阅读和理解
明确定义该模块需要的上下文信息,方便代码阅读和理解

Jump to

Keyboard shortcuts

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