Git Product home page Git Product logo

ant-1's Introduction

Ant GitHub release report card github issues github closed issues GoDoc view examples view Go网络编程群

Ant is a simple and flexible microservice framework based on Teleport.

简体中文

1. Install

go version ≥ 1.7
go get -u github.com/henrylee2cn/ant

2. Feature

  • Support auto service-discovery
  • Supports custom service linker
  • Support load balancing
  • Support NIO and connection pool
  • Support custom protocol
  • Support custom body codec
  • Support plug-in expansion
  • Support heartbeat mechanism
  • Detailed log information, support print input and output details
  • Support for setting slow operation alarm thresholds
  • Support for custom log
  • Support smooth shutdown and update
  • Support push handler
  • Support network list: tcp, tcp4, tcp6, unix, unixpacket and so on
  • Client support automatically redials after disconnection

3. Project Structure

(recommend)

├── README.md
├── main.go
├── api
│   ├── handlers.gen.go
│   ├── handlers.go
│   ├── router.gen.go
│   └── router.go
├── logic
│   └── xxx.go
├── sdk
│   ├── rpc.gen.go
│   ├── rpc.gen_test.go
│   ├── rpc.go
│   └── rpc_test.go
└── types
    ├── types.gen.go
    └── types.go

Desc:

  • add .gen suffix to the file name of the automatically generated file

4. Demo

  • server
package main

import (
	"github.com/henrylee2cn/ant"
	tp "github.com/henrylee2cn/teleport"
)

// Args args
type Args struct {
	A int
	B int `param:"<range:1:>"`
}

// P handler
type P struct {
	tp.PullCtx
}

// Divide divide API
func (p *P) Divide(args *Args) (int, *tp.Rerror) {
	return args.A / args.B, nil
}

func main() {
	srv := ant.NewServer(ant.SrvConfig{
		ListenAddress: ":9090",
	})
	srv.RoutePull(new(P))
	srv.Listen()
}
  • client
package main

import (
	"github.com/henrylee2cn/ant"
)

func main() {
	cli := ant.NewClient(
		ant.CliConfig{},
		ant.NewStaticLinker(":9090"),
	)
	defer	cli.Close()

	type Args struct {
		A int
		B int
	}

	var reply int
	rerr := cli.Pull("/p/divide", &Args{
		A: 10,
		B: 2,
	}, &reply).Rerror()
	if rerr != nil {
		ant.Fatalf("%v", rerr)
	}
	ant.Infof("10/2=%d", reply)
	rerr = cli.Pull("/p/divide", &Args{
		A: 10,
		B: 0,
	}, &reply).Rerror()
	if rerr == nil {
		ant.Fatalf("%v", rerr)
	}
	ant.Infof("test binding error: ok: %v", rerr)
}

More

5. Command

Command ant is deployment tools of ant microservice frameware.

  • Quickly create a ant project
  • Run ant project with hot compilation

1. Install

```sh
go install
```

2. Usage

  • new project
NAME:
   ant new - Create a new ant project

USAGE:
   ant new [options] [arguments...]
 or
   ant new {app_path} [options except -app_path] [arguments...]

OPTIONS:
   --app_path value, -a value  Specifies the path(relative/absolute) of the project
  • run project
NAME:
   ant run - Compile and run gracefully (monitor changes) an any existing go project

USAGE:
   ant run [options] [arguments...]
 or
   ant run [options except -app_path] [arguments...] {app_path}

OPTIONS:
   --watch_exts value, -x value  Specified to increase the listening file suffix (default: ".go", ".ini", ".yaml", ".toml", ".xml")
   --app_path value, -a value    Specifies the path(relative/absolute) of the project

ant command

6. Platform

Ants: a highly available microservice platform based on Ant and Teleport.

7. License

Ant is under Apache v2 License. See the LICENSE file for the full license text

ant-1's People

Contributors

andeya avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.