Categorygithub.com/driftluo/tentacle-go
modulepackage
0.0.0-20221215093808-34879f388769
Repository: https://github.com/driftluo/tentacle-go.git
Documentation: pkg.go.dev

# README

tentacle-go

Tentacle-go implementation

The tentacle framework has been running in the production environment for a long time, this project is a verification project used to verify the feasibility of the multi-language implementation of the tentacle framework, while ensuring the performance of the implementation as much as possible, but will not do a wider range of performance optimization work.

Development status

At present, example can communicate normally with the Rust version

Usage

Example

$ go build example/tentacle_example/simple.go
$ ./simple server

On another terminal:

$ ./simple

Now you can see some data interaction information on the terminal.

Communicate with the Rust version implementation

$ git clone https://github.com/nervosnetwork/tentacle.git
$ RUST_LOG=simple=info,tentacle=debug cargo run --example simple --features molc -- server

On another terminal:

$ go build example/tentacle_example/simple.go
$ ./simple

Or, you can use Go's server to communicate with Rust's client

API

Most of the api implementations are similar to the Rust version, mainly considering the comparison of the production version, but the Go The implementation has been streamlined and adapted to the Go language.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

DefaultMeta make a default builder.
DefaultServiceBuilder create a default empty builder.
ExtractPeerID get peer id from multiaddr.
SelectVersion choose the highest version of the two sides, assume that slices are sorted.

# Constants

All try open all protocol, target is nil.
DialerError when dial remote error.
HandshakeError handshake error.
IoError IO error.
ListenClose a listener close.
ListenError when listen error.
ListenStarted a listener started.
Multi try open some protocol, target is []ProtocolID/[]SessionID.
MuxerError Multiplex protocol error.
PeerIDNotMatch when dial remote, peer id does not match.
ProtocolError Protocol error during interaction.
ProtocolHandleError protocol handle error, will cause memory leaks/abnormal CPU usage.
ProtocolSelectError Protocol select fail.
RepeatedConnection connected to the connected peer, inner type SessionID.
SessionClose a session close.
SessionOpen a session open.
SessionTimeout After initializing the connection, the session does not open any protocol, suspected fd attack.
Single try open one protocol, target is ProtocolID/SessionID.
TransportError transport error.

# Variables

DefaultBeforeReceive use by default, do nothing.
DefaultBeforeSend use by default, do nothing.
DefaultCodec use by default, is a LengthDelimitedCodec.
DefaultNameFn default protocol name.
ErrBrokenPipe service has been shutdown.
ErrDialTimeout dial timeout.
ErrHandshakeTimeout secio handshake timeout.
ErrListenerTimeout listen timeout.
ErrNotSupport protocol doesn't support.
ErrProtocolNotMatch is server don't support this protocol.
ErrVersionNotMatch is node can't support this version.

# Structs

DialerErrorInner when dial remote error.
ListenErrorInner when listen error.
MetaBuilder builder for protocol meta.
MuxerErrorInner multiplex protocol error.
ProtocolContext context with current protocol.
ProtocolContextRef context with current protocol and session.
ProtocolErrorInner protocol error during interaction.
ProtocolHandleErrorInner is inner msg of this error.
ProtocolInfo is the handshake message of open protocol.
ProtocolMeta define the minimum data required for a custom protocol.
ProtocolSelectErrorInner protocol select fail.
Service user handle.
ServiceBuilder builder for Service.
ServiceContext context with current service.
ServiceError error generated by the Service.
ServiceEvent event generated by the Service.
SessionContext context with current session.
SessionTimeoutInner after initializing the connection, the session does not open any protocol, suspected fd attack.
TargetProtocol when dial, specify which protocol want to open.
TargetSession when sending a message, select the specified session.

# Interfaces

Codec use on protocol stream to en/decode message.
When the negotiation is completed and the agreement is opened, will call the implementation, allow users to implement the read processing of the protocol by themselves Implementing this interface means that streaming reading directly from the underlying substream will become possible This interface implementation and the callback implementation are mutually exclusive, and will be checked during construction, if both exist, it will panic.
ServiceHandle is a handle to do something by service #### Behavior The handle that exists when the Service is created.
ServiceProtocol is Service level protocol handle #### Behavior Define the behavior of each custom protocol in each state.
SessionProtocol is Session level protocol handle.
SubstreamReadPart is the read part for the protocol side.

# Type aliases

BeforeReceive unified processing of messages before user received.
BeforeSend unified processing of messages before they are sent.
CodecFn generate a codec.
NameFn define protocol name, default is "/p2p/protocol_id" Used to interact with the remote service to determine whether the protocol is supported.
ProtocolID define the protocol id.
SelectFn is the function for protocol version select.
SessionID index of session.
SessionProtocolFn generate SessionProtocol.
SessionType Outbound or Inbound Outbound representing yourself as the active party means that you are the client side Inbound representing yourself as a passive recipient means that you are the server side.