1. 命令行

2. micro cli

micro climicro 工具包中的一个命令行接口.

2.1. 开始

2.2. 安装

go get github.com/micro/micro/v2

2.3. 交互模式

使用 cli 作为交互式提示符

micro cli

在交互模式中使用以下命令删除 micro

2.4. 示例用法

2.4.1. 列出服务

micro list services

2.4.2. 列出服务

micro get service go.micro.srv.example

输出

go.micro.srv.example

go.micro.srv.example-fccbb6fb-0301-11e5-9f1f-68a86d0d36b6    [::]    62421

2.4.3. 调用服务

micro call go.micro.srv.example Example.Call '{"name": "John"}'

输出

{
    "msg": "go.micro.srv.example-fccbb6fb-0301-11e5-9f1f-68a86d0d36b6: Hello John"
}

2.4.4. 服务运行状况

micro health go.micro.srv.example

输出

node        address:port        status
go.micro.srv.example-fccbb6fb-0301-11e5-9f1f-68a86d0d36b6        [::]:62421        ok

2.4.5. 注册/注销

micro register service '{"name": "foo", "version": "bar", "nodes": [{"id": "foo-1", "address": "127.0.0.1", "port": 8080}]}'
micro deregister service '{"name": "foo", "version": "bar", "nodes": [{"id": "foo-1", "address": "127.0.0.1", "port": 8080}]}'

2.5. 代理远程环境

使用 micro proxy

在针对远程环境进行开发时, 您可能无法直接访问服务发现, 这使得使用 CLI 变得困难. micro proxy 为此诸如此类问题提供了 http 代理解决方案.

在远程环境中运行代理

micro proxy

设置环境变量 MICRO_PROXY_ADDRESS, 以便 cli 知道使用代理

MICRO_PROXY_ADDRESS=staging.micro.mu:8081 micro list services

2.6. 使用

NAME:
   micro - A cloud-native toolkit

USAGE:
   micro [global options] command [command options] [arguments...]

VERSION:
   0.8.0

COMMANDS:
    api        Run the micro API
    bot        Run the micro bot
    registry    Query registry
    call    Call a service or function
    query    Deprecated: Use call instead
    stream    Create a service or function stream
    health    Query the health of a service
    stats    Query the stats of a service
    list    List items in registry
    register    Register an item in the registry
    deregister    Deregister an item in the registry
    get        Get item from registry
    proxy    Run the micro proxy
    new        Create a new micro service by specifying a directory path relative to your $GOPATH
    web        Run the micro web app

results matching ""

    No results matching ""