Categorygithub.com/apache/getty
modulepackage
0.9.3
Repository: https://github.com/apache/getty.git
Documentation: pkg.go.dev

# README

getty

a netty like asynchronous network I/O library

INTRO

Getty is a asynchronous network I/O library in golang. Getty is based on "ngo" whose author is sanbit. Getty works on tcp/udp/websocket network protocol and supplies a uniform interface.

In getty there are two goroutines in one connection(session), one reads tcp stream/udp packet/websocket package, the other handles logic process and writes response into network write buffer. If your logic process may take a long time, you should start a new logic process goroutine by yourself in codec.go:(Codec)OnMessage.

You can also handle heartbeat logic in codec.go:(Codec):OnCron. If you use tcp/udp, you should send hearbeat package by yourself, and then invoke session.go:(Session)UpdateActive to update its active time. Please check whether the tcp session has been timeout or not in codec.go:(Codec)OnCron by session.go:(Session)GetActive.

Whatever if you use websocket, you do not need to care about hearbeat request/response because Getty do this task in session.go:(Session)handleLoop by sending/received websocket ping/pong frames. You just need to check whether the websocket session has been timeout or not in codec.go:(Codec)OnCron by session.go:(Session)GetActive.

You can get code example in https://github.com/AlexStocks/getty-examples.

RPC

A open source, Go based, RPC framework.

Feature list:

  • 1 Transport: TCP(√), UDP, Websocket
  • 2 Codec: ProtoBuf(√), JSON(√)
  • 3 Service Discovery: Service Publish(X), Service Watch(X), Service Notify(X)
  • 4 Registry: ZooKeeper(X), Etcd(x)
  • 5 Strategy: Failover(√), Failfast(√)
  • 6 Load Balance: Random(X), RoundRobin(X)
  • 7 Metrics: Invoke Statistics(x), User Auth(x)

Code example:

The rpc dir of getty-examples shows how to build rpc client/rpc server.

LICENCE

Apache License 2.0

# Packages

Package rpc is a generated protocol buffer package.

# Functions

No description provided by the author
No description provided by the author
NewTcpClient function builds a tcp client.
NewTCServer builds a tcp server.
NewUdpClient function builds a connected udp client.
NewUDPEndPoint builds a unconnected udp server.
NewWsClient function builds a ws client.
NewWSSClient function builds a wss client.
NewWSServer builds a websocket server.
NewWSSServer builds a secure websocket server.
@num is connection number.
@addr server listen address.
@cert is client certificate file.
@addr is server address.
@cert: server certificate file.
@path: websocket request url path.
@key: server private key(contains its public key).
@cert is the root certificate file to verify the legitimacy of server.

# Constants

9.
1.
-2.
0.
No description provided by the author
-1.
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
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
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

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
No description provided by the author

# Structs

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

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
EventListener is used to process pkg that received from remote session.
Reader is used to unmarshal a complete pkg from buffer.
tcp package handler interface.
No description provided by the author
No description provided by the author
Writer is used to marshal pkg and write to session.

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
NewSessionCallback will be invoked when server accepts a new client connection or client connects to server successfully.
No description provided by the author