{"id":13753926,"url":"https://github.com/xiaoenai/tp-micro","last_synced_at":"2026-01-12T02:04:40.232Z","repository":{"id":57486911,"uuid":"117789520","full_name":"xiaoenai/tp-micro","owner":"xiaoenai","description":"TP-Micro is a highly available microservice platform based on teleport.","archived":false,"fork":false,"pushed_at":"2024-07-04T09:02:42.000Z","size":10653,"stargazers_count":210,"open_issues_count":5,"forks_count":54,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-12-17T08:58:34.121Z","etag":null,"topics":["golang","microservice","teleport"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xiaoenai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-01-17T05:37:38.000Z","updated_at":"2025-11-01T09:30:58.000Z","dependencies_parsed_at":"2023-07-14T02:10:25.966Z","dependency_job_id":"c79cd44f-a0f5-4152-9916-6f1135e445ed","html_url":"https://github.com/xiaoenai/tp-micro","commit_stats":null,"previous_names":["xiaoenai/ants"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/xiaoenai/tp-micro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoenai%2Ftp-micro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoenai%2Ftp-micro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoenai%2Ftp-micro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoenai%2Ftp-micro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiaoenai","download_url":"https://codeload.github.com/xiaoenai/tp-micro/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoenai%2Ftp-micro/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28331520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","microservice","teleport"],"created_at":"2024-08-03T09:01:35.112Z","updated_at":"2026-01-12T02:04:40.188Z","avatar_url":"https://github.com/xiaoenai.png","language":"Go","readme":"# TP-Micro [![GitHub release](https://img.shields.io/github/release/xiaoenai/tp-micro.svg?style=flat-square)](https://github.com/xiaoenai/tp-micro/releases) [![report card](https://goreportcard.com/badge/github.com/xiaoenai/tp-micro?style=flat-square)](http://goreportcard.com/report/xiaoenai/tp-micro) [![github issues](https://img.shields.io/github/issues/xiaoenai/tp-micro.svg?style=flat-square)](https://github.com/xiaoenai/tp-micro/issues?q=is%3Aopen+is%3Aissue) [![github closed issues](https://img.shields.io/github/issues-closed-raw/xiaoenai/tp-micro.svg?style=flat-square)](https://github.com/xiaoenai/tp-micro/issues?q=is%3Aissue+is%3Aclosed) [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/xiaoenai/tp-micro) [![view examples](https://img.shields.io/badge/learn%20by-examples-00BCD4.svg?style=flat-square)](https://github.com/xiaoenai/tp-micro/tree/v3/examples) [![view erpc](https://img.shields.io/badge/based%20on-erpc-00BCD4.svg?style=flat-square)](https://github.com/henrylee2cn/erpc) [![view Go网络编程群](https://img.shields.io/badge/官方QQ群-Go网络编程(42730308)-27a5ea.svg?style=flat-square)](http://jq.qq.com/?_wv=1027\u0026k=fzi4p1)\n\n\nTP-Micro master(v6) is a simple, powerful micro service framework based on [eRPC v6](https://github.com/henrylee2cn/erpc/tree/master).\n\n[简体中文](https://github.com/xiaoenai/tp-micro/blob/master/README_ZH.md)\n\n![tp-micro flow chart](https://github.com/xiaoenai/tp-micro/raw/master/doc/tp-micro_flow_chart.png)\n\n## Install\n\n\n```\ngo version ≥ 1.12\n```\n\n```sh\ngo get -u -f -d github.com/xiaoenai/tp-micro/...\ncd $GOPATH/src/github.com/xiaoenai/tp-micro/cmd/micro\ngo install\n```\n\n## Feature\n\n- Support auto service-discovery\n- Supports custom service linker\n- Support load balancing\n- Support Asynchronous multiplexing IO\n- Support custom protocol\n- Support custom body codec\n- Support plug-in expansion\n- Support heartbeat mechanism\n- Detailed log information, support print input and output details\n- Support for setting slow operation alarm thresholds\n- Support for custom log\n- Support smooth shutdown and update\n- Support push handler\n- Support network list: `tcp`, `tcp4`, `tcp6`, `unix`, `unixpacket` and so on\n- Client support automatically redials after disconnection\n- Circuit breaker for overload protection\n\n## Example\n\n- server\n\n```go\npackage main\n\nimport (\n    micro \"github.com/xiaoenai/tp-micro/v6\"\n    \"github.com/henrylee2cn/erpc/v6\"\n)\n\n// Arg arg\ntype Arg struct {\n    A int\n    B int `param:\"\u003crange:1:\u003e\"`\n}\n\n// P handler\ntype P struct {\n    erpc.CallCtx\n}\n\n// Divide divide API\nfunc (p *P) Divide(arg *Arg) (int, *erpc.Status) {\n    return arg.A / arg.B, nil\n}\n\nfunc main() {\n    srv := micro.NewServer(micro.SrvConfig{\n        ListenAddress: \":9090\",\n    })\n    srv.RouteCall(new(P))\n    srv.ListenAndServe()\n}\n```\n\n- client\n\n```go\npackage main\n\nimport (\n    micro \"github.com/xiaoenai/tp-micro/v6\"\n    \"github.com/henrylee2cn/erpc/v6\"\n)\n\nfunc main() {\n    cli := micro.NewClient(\n        micro.CliConfig{},\n        micro.NewStaticLinker(\":9090\"),\n    )\n    defer cli.Close()\n\n    type Arg struct {\n        A int\n        B int\n    }\n\n    var result int\n    stat := cli.Call(\"/p/divide\", \u0026Arg{\n        A: 10,\n        B: 2,\n    }, \u0026result).Status()\n    if stat != nil {\n        erpc.Fatalf(\"%v\", stat)\n    }\n    erpc.Infof(\"10/2=%d\", result)\n    stat = cli.Call(\"/p/divide\", \u0026Arg{\n        A: 10,\n        B: 0,\n    }, \u0026result).Status()\n    if stat == nil {\n        erpc.Fatalf(\"%v\", stat)\n    }\n    erpc.Infof(\"test binding error: ok: %v\", stat)\n}\n```\n\n[More Examples](https://github.com/xiaoenai/tp-micro/tree/v3/examples)\n\n## Learn `micro` Command\n\nCommand micro is deployment tools of tp-micro frameware.\n\n- Quickly create a tp-micro project\n- Run tp-micro project with hot compilation\n\n### Generate project\n\n`micro gen` command help:\n\n```\nNAME:\n     micro gen - Generate a tp-micro project\n\nUSAGE:\n     micro gen [command options] [arguments...]\n\nOPTIONS:\n     --template value, -t value    The template for code generation(relative/absolute)\n     --app_path value, -p value  The path(relative/absolute) of the project\n```\n\nexample: `micro gen -p ./myapp` or default `micro gen myapp`\n\n- The initial template file `__tp-micro__tpl__.go`:\n\n```go\n// package __TPL__ is the project template\npackage __TPL__\n\n// __API_CALL__ register CALL router:\n//  /home\n//  /math/divide\ntype __API_CALL__ interface {\n    Home(*struct{}) *HomeResult\n    Math\n}\n\n// __API_PUSH__ register PUSH router:\n//  /stat\ntype __API_PUSH__ interface {\n    Stat(*StatArg)\n}\n\n// __MYSQL_MODEL__ create mysql model\ntype __MYSQL_MODEL__ struct {\n    User\n    Log\n    Device\n}\n\n// __MONGO_MODEL__ create mongodb model\ntype __MONGO_MODEL__ struct {\n    Meta\n}\n\n// Math controller\ntype Math interface {\n    // Divide handler\n    Divide(*DivideArg) *DivideResult\n}\n\n// HomeResult home result\ntype HomeResult struct {\n    Content string // text\n}\n\ntype (\n    // DivideArg divide api arg\n    DivideArg struct {\n        // dividend\n        A float64\n        // divisor\n        B float64 `param:\"\u003crange: 0.01:100000\u003e\"`\n    }\n    // DivideResult divide api result\n    DivideResult struct {\n        // quotient\n        C float64\n    }\n)\n\n// StatArg stat handler arg\ntype StatArg struct {\n    Ts int64 // timestamps\n}\n\n// User user info\ntype User struct {\n    Id   int64  `key:\"pri\"`\n    Name string `key:\"uni\"`\n    Age  int32\n}\n\ntype Log struct {\n    Text string\n}\n\ntype Device struct {\n    UUID string `key:\"pri\"`\n}\n\ntype Meta struct {\n    Hobby []string\n    Tags  []string\n}\n```\n\n- The template generated by `micro gen` command.\n\n```\n├── README.md\n├── __tp-micro__gen__.lock\n├── __tp-micro__tpl__.go\n├── api\n│   ├── handler.go\n│   ├── pull_handler.gen.go\n│   ├── push_handler.gen.go\n│   ├── router.gen.go\n│   └── router.go\n├── args\n│   ├── const.gen.go\n│   ├── const.go\n│   ├── type.gen.go\n│   ├── type.go\n│   └── var.go\n├── config\n│   └── config.yaml\n├── config.go\n├── doc\n│   ├── APIDoc.md\n│   ├── README.md\n│   └── databases.md\n├── log\n│   └── PID\n├── logic\n│   ├── model\n│   │   ├── init.go\n│   │   ├── mongo_meta.gen.go\n│   │   ├── mysql_device.gen.go\n│   │   ├── mysql_log.gen.go\n│   │   └── mysql_user.gen.go\n│   └── tmp_code.gen.go\n├── main.go\n├── rerrs\n│   └── rerrs.go\n└── sdk\n    ├── rpc.gen.go\n    ├── rpc.gen_test.go\n    ├── rpc.go\n    └── rpc_test.go\n```\n\n**Desc:**\n\n- This `micro gen` command only covers files with the \".gen.go\" suffix if the `__tp-micro__gen__.lock` file exists\n- Add `.gen` suffix to the file name of the automatically generated file, DO NOT EDIT!\n- `.tmp` is temporary code used to ensure successful compilation!\u003cbr\u003eIt will be overwritten when `micro gen` is run!\u003cbr\u003eWhen the project is completed, it should be removed!\n- The type of handler's parameter and result must be struct!\n- You can modify the created template file `__tp-micro__tpl__.go`, and run the `micro gen` command again to update the project\n\n[Generated Default Sample](https://github.com/xiaoenai/tp-micro/tree/v3/examples/project)\n\n### Create README.md(only)\n\n`micro newdoc` command help:\n\n```\nNAME:\n   micro newdoc - Generate a tp-micro project README.md\n\nUSAGE:\n   micro newdoc [command options] [arguments...]\n\nOPTIONS:\n   --app_path value, -p value  The path(relative/absolute) of the project\n```\n\n### Run project\n\n`micro run` command help:\n\n```\nNAME:\n     micro run - Compile and run gracefully (monitor changes) an any existing go project\n\nUSAGE:\n     micro run [options] [arguments...]\n or\n     micro run [options except -app_path] [arguments...] {app_path}\n\nOPTIONS:\n     --watch_exts value, -x value  Specified to increase the listening file suffix (default: \".go\", \".ini\", \".yaml\", \".toml\", \".xml\")\n     --notwatch value, -n value    Not watch files or directories\n     --app_path value, -p value    The path(relative/absolute) of the project\n```\n\nexample: `micro run -x .yaml -p myapp` or `micro run`\n\n### Add model\n\nAdd mysql model struct code to project template.\n\n`micro tpl` command help:\n\n ```\n NAME:\n   micro tpl - Add mysql model struct code to project template\n\nUSAGE:\n   micro tpl [command options] [arguments...]\n\nOPTIONS:\n   --app_path value, -p value      The path(relative/absolute) of the project\n   --host value                    mysql host ip (default: \"localhost\")\n   --port value                    mysql host port (default: \"3306\")\n   --username value, --user value  mysql username (default: \"root\")\n   --password value, --pwd value   mysql password\n   --db value                      mysql database (default: \"test\")\n   --table value                   mysql table\n   --ssh_user value                ssh user\n   --ssh_host value                ssh host ip\n   --ssh_port value                ssh host port\n ```\n\n\n[More Micro Command](https://github.com/xiaoenai/tp-micro/tree/master/cmd/micro)\n\n## Usage\n\n### Peer(server or client) Demo\n\n```go\n// Start a server\nvar peer1 = erpc.NewPeer(erpc.PeerConfig{\n    ListenAddress: \"0.0.0.0:9090\", // for server role\n})\npeer1.Listen()\n\n...\n\n// Start a client\nvar peer2 = erpc.NewPeer(erpc.PeerConfig{})\nvar sess, err = peer2.Dial(\"127.0.0.1:8080\")\n```\n\n### Call-Controller-Struct API template\n\n```go\ntype Aaa struct {\n    erpc.CallCtx\n}\nfunc (x *Aaa) XxZz(arg *\u003cT\u003e) (\u003cT\u003e, *erpc.Status) {\n    ...\n    return r, nil\n}\n```\n\n- register it to root router:\n\n```go\n// register the call route: /aaa/xx_zz\npeer.RouteCall(new(Aaa))\n\n// or register the call route: /xx_zz\npeer.RouteCallFunc((*Aaa).XxZz)\n```\n\n### Call-Handler-Function API template\n\n```go\nfunc XxZz(ctx erpc.CallCtx, arg *\u003cT\u003e) (\u003cT\u003e, *erpc.Status) {\n    ...\n    return r, nil\n}\n```\n\n- register it to root router:\n\n```go\n// register the call route: /xx_zz\npeer.RouteCallFunc(XxZz)\n```\n\n### Push-Controller-Struct API template\n\n```go\ntype Bbb struct {\n    erpc.PushCtx\n}\nfunc (b *Bbb) YyZz(arg *\u003cT\u003e) *erpc.Status {\n    ...\n    return nil\n}\n```\n\n- register it to root router:\n\n```go\n// register the push route: /bbb/yy_zz\npeer.RoutePush(new(Bbb))\n\n// or register the push route: /yy_zz\npeer.RoutePushFunc((*Bbb).YyZz)\n```\n\n### Push-Handler-Function API template\n\n```go\n// YyZz register the route: /yy_zz\nfunc YyZz(ctx erpc.PushCtx, arg *\u003cT\u003e) *erpc.Status {\n    ...\n    return nil\n}\n```\n\n- register it to root router:\n\n```go\n// register the push route: /yy_zz\npeer.RoutePushFunc(YyZz)\n```\n\n### Unknown-Call-Handler-Function API template\n\n```go\nfunc XxxUnknownCall (ctx erpc.UnknownCallCtx) (interface{}, *erpc.Status) {\n    ...\n    return r, nil\n}\n```\n\n- register it to root router:\n\n```go\n// register the unknown call route: /*\npeer.SetUnknownCall(XxxUnknownCall)\n```\n\n### Unknown-Push-Handler-Function API template\n\n```go\nfunc XxxUnknownPush(ctx erpc.UnknownPushCtx) *erpc.Status {\n    ...\n    return nil\n}\n```\n\n- register it to root router:\n\n```go\n// register the unknown push route: /*\npeer.SetUnknownPush(XxxUnknownPush)\n```\n\n### The mapping rule of struct(func) name to URI path:\n\n- `AaBb` -\u003e `/aa_bb`\n- `Aa_Bb` -\u003e `/aa/bb`\n- `aa_bb` -\u003e `/aa/bb`\n- `Aa__Bb` -\u003e `/aa_bb`\n- `aa__bb` -\u003e `/aa_bb`\n- `ABC_XYZ` -\u003e `/abc/xyz`\n- `ABcXYz` -\u003e `/abc_xyz`\n- `ABC__XYZ` -\u003e `/abc_xyz`\n\n### Plugin Demo\n\n```go\n// NewIgnoreCase Returns a ignoreCase plugin.\nfunc NewIgnoreCase() *ignoreCase {\n    return \u0026ignoreCase{}\n}\n\ntype ignoreCase struct{}\n\nvar (\n    _ erpc.PostReadCallHeaderPlugin = new(ignoreCase)\n    _ erpc.PostReadPushHeaderPlugin = new(ignoreCase)\n)\n\nfunc (i *ignoreCase) Name() string {\n    return \"ignoreCase\"\n}\n\nfunc (i *ignoreCase) PostReadCallHeader(ctx erpc.ReadCtx) *erpc.Status {\n    // Dynamic transformation path is lowercase\n    ctx.UriObject().Path = strings.ToLower(ctx.UriObject().Path)\n    return nil\n}\n\nfunc (i *ignoreCase) PostReadPushHeader(ctx erpc.ReadCtx) *erpc.Status {\n    // Dynamic transformation path is lowercase\n    ctx.UriObject().Path = strings.ToLower(ctx.UriObject().Path)\n    return nil\n}\n```\n\n### Register above handler and plugin\n\n```go\n// add router group\ngroup := peer.SubRoute(\"test\")\n// register to test group\ngroup.RouteCall(new(Aaa), NewIgnoreCase())\npeer.RouteCallFunc(XxZz, NewIgnoreCase())\ngroup.RoutePush(new(Bbb))\npeer.RoutePushFunc(YyZz)\npeer.SetUnknownCall(XxxUnknownCall)\npeer.SetUnknownPush(XxxUnknownPush)\n```\n\n### Config\n\n```go\n// SrvConfig server config\ntype SrvConfig struct {\n    Network           string        `yaml:\"network\"              ini:\"network\"              comment:\"Network; tcp, tcp4, tcp6, unix or unixpacket\"`\n    ListenAddress     string        `yaml:\"listen_address\"       ini:\"listen_address\"       comment:\"Listen address; for server role\"`\n    TlsCertFile       string        `yaml:\"tls_cert_file\"        ini:\"tls_cert_file\"        comment:\"TLS certificate file path\"`\n    TlsKeyFile        string        `yaml:\"tls_key_file\"         ini:\"tls_key_file\"         comment:\"TLS key file path\"`\n    DefaultSessionAge time.Duration `yaml:\"default_session_age\"  ini:\"default_session_age\"  comment:\"Default session max age, if less than or equal to 0, no time limit; ns,µs,ms,s,m,h\"`\n    DefaultContextAge time.Duration `yaml:\"default_context_age\"  ini:\"default_context_age\"  comment:\"Default CALL or PUSH context max age, if less than or equal to 0, no time limit; ns,µs,ms,s,m,h\"`\n    SlowCometDuration time.Duration `yaml:\"slow_comet_duration\"  ini:\"slow_comet_duration\"  comment:\"Slow operation alarm threshold; ns,µs,ms,s ...\"`\n    DefaultBodyCodec  string        `yaml:\"default_body_codec\"   ini:\"default_body_codec\"   comment:\"Default body codec type id\"`\n    PrintDetail       bool          `yaml:\"print_detail\"         ini:\"print_detail\"         comment:\"Is print body and metadata or not\"`\n    CountTime         bool          `yaml:\"count_time\"           ini:\"count_time\"           comment:\"Is count cost time or not\"`\n    EnableHeartbeat   bool          `yaml:\"enable_heartbeat\"     ini:\"enable_heartbeat\"     comment:\"enable heartbeat\"`\n}\n\n// CliConfig client config\ntype CliConfig struct {\n    Network             string               `yaml:\"network\"                ini:\"network\"                comment:\"Network; tcp, tcp4, tcp6, unix or unixpacket\"`\n    LocalIP             string               `yaml:\"local_ip\"               ini:\"local_ip\"               comment:\"Local IP\"`\n    TlsCertFile         string               `yaml:\"tls_cert_file\"          ini:\"tls_cert_file\"          comment:\"TLS certificate file path\"`\n    TlsKeyFile          string               `yaml:\"tls_key_file\"           ini:\"tls_key_file\"           comment:\"TLS key file path\"`\n    DefaultSessionAge   time.Duration        `yaml:\"default_session_age\"    ini:\"default_session_age\"    comment:\"Default session max age, if less than or equal to 0, no time limit; ns,µs,ms,s,m,h\"`\n    DefaultContextAge   time.Duration        `yaml:\"default_context_age\"    ini:\"default_context_age\"    comment:\"Default CALL or PUSH context max age, if less than or equal to 0, no time limit; ns,µs,ms,s,m,h\"`\n    DefaultDialTimeout  time.Duration        `yaml:\"default_dial_timeout\"   ini:\"default_dial_timeout\"   comment:\"Default maximum duration for dialing; for client role; ns,µs,ms,s,m,h\"`\n    RedialTimes         int                  `yaml:\"redial_times\"           ini:\"redial_times\"           comment:\"The maximum times of attempts to redial, after the connection has been unexpectedly broken; for client role\"`\n    Failover            int                  `yaml:\"failover\"               ini:\"failover\"               comment:\"The maximum times of failover\"`\n    SlowCometDuration   time.Duration        `yaml:\"slow_comet_duration\"    ini:\"slow_comet_duration\"    comment:\"Slow operation alarm threshold; ns,µs,ms,s ...\"`\n    DefaultBodyCodec    string               `yaml:\"default_body_codec\"     ini:\"default_body_codec\"     comment:\"Default body codec type id\"`\n    PrintDetail         bool                 `yaml:\"print_detail\"           ini:\"print_detail\"           comment:\"Is print body and metadata or not\"`\n    CountTime           bool                 `yaml:\"count_time\"             ini:\"count_time\"             comment:\"Is count cost time or not\"`\n    HeartbeatSecond     int                  `yaml:\"heartbeat_second\"       ini:\"heartbeat_second\"       comment:\"When the heartbeat interval(second) is greater than 0, heartbeat is enabled; if it's smaller than 3, change to 3 default\"`\n    SessMaxQuota        int                  `yaml:\"sess_max_quota\"         ini:\"sess_max_quota\"         comment:\"The maximum number of sessions in the connection pool\"`\n    SessMaxIdleDuration time.Duration        `yaml:\"sess_max_idle_duration\" ini:\"sess_max_idle_duration\" comment:\"The maximum time period for the idle session in the connection pool; ns,µs,ms,s,m,h\"`\n    CircuitBreaker      CircuitBreakerConfig `yaml:\"circuit_breaker\" ini:\"circuit_breaker\" comment:\"Circuit breaker config\"`\n}\n\n// CircuitBreakerConfig circuit breaker config\ntype CircuitBreakerConfig struct {\n    Enable          bool          `yaml:\"enable\" ini:\"enable\" comment:\"Whether to use circuit breaker\"`\n    ErrorPercentage int           `yaml:\"error_percentage\" ini:\"error_percentage\" comment:\"break linker when the error rate exceeds the threshold during a statistical period; default 50\"`\n    BreakDuration   time.Duration `yaml:\"break_duration\" ini:\"break_duration\" comment:\"The period of one-cycle break in milliseconds; must ≥ 1ms\"`\n}\n```\n\n#### Param-Tags\n\ntag   |   key    | required |     value     |   desc\n------|----------|----------|---------------|----------------------------------\nparam |   meta    | no |  (name e.g.`param:\"\u003cmeta:id\u003e\"`)  | It indicates that the parameter is from the meta.\nparam |   swap    | no |   name (e.g.`param:\"\u003cswap:id\u003e\"`)  | It indicates that the parameter is from the context swap.\nparam |   desc   |      no      |     (e.g.`param:\"\u003cdesc:id\u003e\"`)   | Parameter Description\nparam |   len    |      no      |   (e.g.`param:\"\u003clen:3:6\u003e\"`)  | Length range [a,b] of parameter's value\nparam |   range  |      no      |   (e.g.`param:\"\u003crange:0:10\u003e\"`)   | Numerical range [a,b] of parameter's value\nparam |  nonzero |      no      |    -    | Not allowed to zero\nparam |  regexp  |      no      |   (e.g.`param:\"\u003cregexp:^\\\\w+$\u003e\"`)  | Regular expression validation\nparam |   stat   |      no      |(e.g.`param:\"\u003cstat:100002:wrong password format\u003e\"`)| Custom error code and message\n\nNOTES:\n\n* `param:\"-\"` means ignore\n* Encountered untagged exportable anonymous structure field, automatic recursive resolution\n* Parameter name is the name of the structure field converted to snake format\n* If the parameter is not from `meta` or `swap`, it is the default from the body\n\n#### Field-Types\n\nbase    |   slice    | special\n--------|------------|------------\nstring  |  []string  | [][]byte\nbyte    |  []byte    | [][]uint8\nuint8   |  []uint8   | struct\nbool    |  []bool    |\nint     |  []int     |\nint8    |  []int8    |\nint16   |  []int16   |\nint32   |  []int32   |\nint64   |  []int64   |\nuint8   |  []uint8   |\nuint16  |  []uint16  |\nuint32  |  []uint32  |\nuint64  |  []uint64  |\nfloat32 |  []float32 |\nfloat64 |  []float64 |\n\n#### Example\n\n```go\npackage main\n\nimport (\n    \"github.com/henrylee2cn/erpc/v6\"\n    micro \"github.com/xiaoenai/tp-micro/v6\"\n)\n\ntype (\n    // Arg arg\n    Arg struct {\n        A int\n        B int `param:\"\u003crange:1:100\u003e\"`\n        Query\n        XyZ string `param:\"\u003cmeta\u003e\u003cnonzero\u003e\u003cstat: 100002: Parameter cannot be empty\u003e\"`\n    }\n    Query struct {\n        X string `param:\"\u003cmeta\u003e\"`\n    }\n)\n\n// P handler\ntype P struct {\n    erpc.CallCtx\n}\n\n// Divide divide API\nfunc (p *P) Divide(arg *Arg) (int, *erpc.Status) {\n    erpc.Infof(\"query arg x: %s, xy_z: %s\", arg.Query.X, arg.XyZ)\n    return arg.A / arg.B, nil\n}\n\nfunc main() {\n    srv := micro.NewServer(micro.SrvConfig{\n        ListenAddress:   \":9090\",\n        EnableHeartbeat: true,\n    })\n    group := srv.SubRoute(\"/static\")\n    group.RouteCall(new(P))\n    srv.ListenAndServe()\n}\n```\n\n[Detail Example](https://github.com/xiaoenai/tp-micro/tree/master/examples/binder)\n\n### Optimize\n\n- SetMessageSizeLimit sets max packet size.\n  If maxSize\u003c=0, set it to max uint32.\n\n```go\nfunc SetMessageSizeLimit(maxMessageSize uint32)\n```\n\n- SetSocketKeepAlive sets whether the operating system should send\n  keepalive messages on the connection.\n\n```go\nfunc SetSocketKeepAlive(keepalive bool)\n```\n\n- SetSocketKeepAlivePeriod sets period between keep alives.\n\n```go\nfunc SetSocketKeepAlivePeriod(d time.Duration)\n```\n\n- SetSocketNoDelay controls whether the operating system should delay\n  packet transmission in hopes of sending fewer packets (Nagle's\n  algorithm).  The default is true (no delay), meaning that data is\n  sent as soon as possible after a Write.\n\n```go\nfunc SetSocketNoDelay(_noDelay bool)\n```\n\n- SetSocketReadBuffer sets the size of the operating system's\n  receive buffer associated with the connection.\n\n```go\nfunc SetSocketReadBuffer(bytes int)\n```\n\n- SetSocketWriteBuffer sets the size of the operating system's\n  transmit buffer associated with the connection.\n\n```go\nfunc SetSocketWriteBuffer(bytes int)\n```\n\n[More Usage](https://github.com/henrylee2cn/erpc)\n\n## License\n\nMicro is under Apache v2 License. See the [LICENSE](https://github.com/xiaoenai/tp-micro/raw/master/LICENSE) file for the full license text\n","funding_links":[],"categories":["teleport"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoenai%2Ftp-micro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiaoenai%2Ftp-micro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoenai%2Ftp-micro/lists"}