The heartbeat response based on the Go language

Source: Internet
Author: User
Tags install go
This is a created article in which the information may have evolved or changed.

When we use TCP IP communication, we need to use the heartbeat mechanism to determine the connection state between the server and the client, if the server's heartbeat timeout, and so on, will make a reconnection mechanism,

Based on this problem, I recommend to you today a Go language based heartbeat response mechanism, not much nonsense to say directly on code:

The source is here.

# Heartbeat The heartbeat timer

Heartbeat Introduction

Heartbeat is a go-based multi-task timed response callback

# # Install Go get-u github.com/noaway/heartbeat

Simple use of heartbeat

Create a task

Name, Spec: = "12138", 5HT, err: = Heartbeat. Newtast (name, spec) If err! = Nil {fmt. PRINTLN (Err)}//Run a new missionht. Start (func () error {//call The callback every 5 secondsfmt. PRINTLN (name) return nil})

The use of the method is very simple, as long as the description of the way to start the document can be, in the future development of the process will be added some automated features.

The source is here.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.