All Projects → sahildua2305 → go-eventserver

sahildua2305 / go-eventserver

Licence: GPL-3.0 license
A socket server which reads events from an event source and forwards them to the user clients when appropriate

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to go-eventserver

Oksocket
An blocking socket client for Android applications.
Stars: ✭ 2,359 (+13005.56%)
Mutual labels:  socket, tcp, tcp-server, socket-server
edu cpp IOCP
IOCP 실습
Stars: ✭ 49 (+172.22%)
Mutual labels:  tcp, tcp-server, socket-server
Socketify
Raw TCP and UDP Sockets API on Desktop Browsers
Stars: ✭ 67 (+272.22%)
Mutual labels:  socket, tcp, tcp-server
workerman
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols. PHP>=5.4.
Stars: ✭ 10,005 (+55483.33%)
Mutual labels:  socket, tcp, socket-server
Workerman
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols. PHP>=5.3.
Stars: ✭ 9,617 (+53327.78%)
Mutual labels:  socket, tcp, socket-server
Tinytcpserver
A small tcp server working under Mono or .NET (4.0) and provides hooks for handling data exchange with clients (works under mono and .net). Behaviour/protocol/reaction could be specified via custom C# script.
Stars: ✭ 14 (-22.22%)
Mutual labels:  socket, tcp, tcp-server
tcp-net
Build tcp applications in a stable and elegant way
Stars: ✭ 42 (+133.33%)
Mutual labels:  socket, tcp, tcp-server
EasyFileTransfer
An easy way to transfer file with any size on network with tcp protocol.
Stars: ✭ 30 (+66.67%)
Mutual labels:  socket, tcp, tcp-server
Bizsocket
异步socket,对一些业务场景做了支持
Stars: ✭ 469 (+2505.56%)
Mutual labels:  socket, tcp, tcp-server
Godsharp.socket
An easy-to-use .NET socket server and client.
Stars: ✭ 35 (+94.44%)
Mutual labels:  socket, tcp, tcp-server
Deta cache
缓存cache服务器
Stars: ✭ 106 (+488.89%)
Mutual labels:  socket, tcp, tcp-server
Socketpushclient
最近项目中要求做推送,基于内网的。由于工期不是很紧,需求不是很严格,所以放弃了使用三方的推送框架,基于Socket自己写了消息推送功能(服务端+android端)。服务器端使用java,客户端使用Android。本人是做Android开发的,所以demo重点介绍客户端的一些代码,包括Socket的TCP长连接及发消息,Service如何不被轻易杀死,通过aidl实现界面实时与Service的通信,可以在界面上控制Socket的连接与断开以及发消息,并采用了Parcelable对象实现aidl传参
Stars: ✭ 129 (+616.67%)
Mutual labels:  socket, tcp
com2us cppNetStudy work
컴투스 C++ 네트워크 스터디 개인 작업 저장소
Stars: ✭ 32 (+77.78%)
Mutual labels:  socket, tcp-server
Jstp
Fast RPC for browser and Node.js based on TCP, WebSocket, and MDSF
Stars: ✭ 132 (+633.33%)
Mutual labels:  socket, tcp
Kalm.js
The socket manager
Stars: ✭ 155 (+761.11%)
Mutual labels:  socket, tcp
Async Sockets Cpp
Simple thread-based asynchronous TCP & UDP Socket classes in C++.
Stars: ✭ 127 (+605.56%)
Mutual labels:  socket, tcp
Nettychat
基于Netty+TCP+Protobuf实现的Android IM库,包含Protobuf序列化、TCP拆包与粘包、长连接握手认证、心跳机制、断线重连机制、消息重发机制、读写超时机制、离线消息、线程池等功能。
Stars: ✭ 1,979 (+10894.44%)
Mutual labels:  socket, tcp
Zero
A Lightweight Socket Service with heartbeat, Can be easily used in TCP server development.
Stars: ✭ 161 (+794.44%)
Mutual labels:  socket, tcp-server
Zserver4d
ZServer4D 是一套从商业项目剥离而出的云服务器中间件,可以承载百万级的分布式负载服务,并且支持IoT及内网穿透
Stars: ✭ 199 (+1005.56%)
Mutual labels:  socket, tcp
Socket
Non-blocking socket and TLS functionality for PHP based on Amp.
Stars: ✭ 122 (+577.78%)
Mutual labels:  socket, tcp

go-eventserver

EventServer is a socket server which reads events from an event source and forwards them to the user clients when appropriate.

Check the section Implementation Details below for more details.

Quick Start

Make sure you have a working Go environment.

Dependencies

  • Golang 1.8 or later
  • make (optional)

Steps to install and run the server

  1. Clone the repository into your GOPATH
  2. Go to the project directory: cd $GOPATH/src/github.com/sahildua2305/go-eventserver
  3. Modify ./config/config.json file to configure the event source and user client ports as you want.
  4. Run the event server: make run
  5. The event server will show give output like below:
INFO: 2017/12/17 15:00:46 eventserver.go:508: Loaded the event server config
INFO: 2017/12/17 15:00:46 eventserver.go:83: Listening for event source on port: 9090
INFO: 2017/12/17 15:00:46 eventserver.go:91: Listening for user clients on port: 9099
INFO: 2017/12/17 15:00:46 eventserver.go:515: Started the event server

The server is now running and listening on ports mentioned in your config.json file.

Note: If you don't have make, you can build the binary using:

$ go build .

And then run the binary using:

$ ./go-eventserver

Running tests

To run tests for the entire package:

$ make test

To run the tests with coverage:

$ make test-cover

To run the benchmark tests for the package:

$ make test-bench

Code formatting

To format the code during development:

$ make fmt

By default, the above command is of dry nature. It only shows the changes that gofmt tool suggests.

To actually make the changes, you need to run:

$ make fmt-wet

To run golint on the source code:

$ make lint

Quick test program

To test the event server with a test program that comes with this repository, run the following command in another terminal:

$ make harness

This script will initialize a test program which starts sending events.

Note: The test program uses port 9090 for event source and 9099 for user clients by default. If you want to use different ports, you can set the following environment variables: eventListenerPort and clientListenerPort.

Running in Production

To run EventServer in production, you can install the versioned binary file and run it with the corresponding ./config/config.json file.

Event Server accepts the following command line argument(s):

  -config string
      config file to load (default "./config/config.json")

To run the compiled binary in production with custom config file:

$ ./go-eventserver -config "/path/to/config/file"

The configuration file in production can be served using some configuration management tool like Puppet or Chef.

It's recommended to run the binary wrapped in a service using tools like - supervisord or serviced.

Server Configuration

You can configure the following parameters of the server by specifying them in config.json file:

  • eventListenerPort - The port used by the event source.
  • clientListenerPort - The port used to register clients.

Implementation Details

  • event source: It will send a stream of events which may or may not require clients to be notified.
  • user clients: Each one representing a specific user, these wait for notifications for events which would be relevant to the user they represent.

The Events

There are five possible events. The table below describe payloads sent by the event source and what they represent:

Payload Sequence # Type From User Id To User Id
666|F|60|50 666 Follow 60 50
1|U|12|9 1 Unfollow 12 9
542532|B 542532 Broadcast - -
43|P|32|56 43 Private Msg 32 56
634|S|32 634 Status Update 32 -

Please check instructions.md to read more about these event types.

Events can come out of order, but clients will always receive the events in the right order of sequence number.

Scope of Improvement

  • Logging: Logging can be improved. Right now, only the info logs are being sent to stdout and the error logs are being sent to stderr. The current implementation uses the built-in "log" package. We can use some more mature logging module which can support the levelled logging to support different log levels like - debug, info, warn, error, fatal.
  • Monitoring: The current implementation does not have any kind of monitoring around the system. We should have some monitoring to measure how many events we are serving, what kind of clients are connecting and if everything is going alright with our server. We can use go-metrics package. We can keep these monitoring metrics in graphite and then use some tools like Bosun to enable alerts in undesirable situations.
  • Sequence persistence: We can implement the offset management similar to how Kafka handles it in order to solve the following problems:
    • Make the server recover from the sequence number where it stopped earlier. For example - in case something goes wrong with the server and it stops in the middle, what happens with the events that it already had received?
    • Support the scenario when an event source ends the message streams and want to start sending events again? Two possibilities - do we start processing from the sequence number where we left or do we start from 1?
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].