Giter Site home page Giter Site logo

micro / micro Goto Github PK

View Code? Open in Web Editor NEW
12.0K 319.0 1.0K 20.49 MB

API first development platform

Home Page: https://micro.dev

License: Apache License 2.0

Go 96.67% Dockerfile 0.11% Shell 1.04% Makefile 0.24% PowerShell 0.23% JavaScript 1.57% CSS 0.14%
micro go

micro's Introduction

Micro

Go Report Card Go.Dev reference Apache License

Micro is an API first development platform. It addresses the core requirements for building services in the cloud by providing a set of APIs which act as the building blocks of any platform. Micro deals with the complexity of distributed systems and provides simpler programmable abstractions for developers to build on.

Overview

Architecture

Below are the core components that make up Micro

Server

Micro is built as a microkernel architecture. It abstracts away the complexity of the underlying infrastructure by providing a set of building block services composed as a single logical server for the end user to consume.

The server consists of the following services

  • Auth - Authentication and authorization out of the box using JWT tokens and rule based access control.
  • Broker - Ephemeral pubsub messaging for asynchronous communication and distributing notifications
  • Config - Dynamic configuration and secrets management for service level config without reload
  • Events - Event streaming with ordered messaging, replay from offsets and persistent storage
  • Network - service-to-service networking and control plane for all internal request traffic
  • Runtime - Service lifecycle and process management with support for source to running auto build
  • Registry - Centralised service discovery and API endpoint explorer with feature rich metadata
  • Store - Key-Value storage with TTL expiry and persistent crud to keep microservices stateless

API

The server embeds a HTTP API (on port 8080) which can be used to make requests as simple JSON. The API automatically maps HTTP Paths and POST requests to internal RPC service names and endpoints.

Proxy

Additionally there's a gRPC proxy (on port 8081) which used to make requests via the CLI or externally. The proxy is identity aware which means it can be used to gatekeep remote access to Micro running anywhere.

Framework

Micro comes with a built in Go framework for service based development. The framework lets you write services without piecing together endless lines of boilerplate code. Configured and initialised by default, import it and get started.

Command Line

The command line interface includes dynamic command mapping for all services running on the platform. It turns any service instantly into a CLI command along with flag parsing for inputs. Includes support for environments, namespaces, creating and running services, status info and logs.

Remote Environments

Micro bakes in the concept of Environments. Run your server locally for development and in the cloud for production, seamlessly switch between them using the CLI command micro env set [environment].

Install

From Source

make build

Prebuilt Binaries

Windows

powershell -Command "iwr -useb https://raw.githubusercontent.com/micro/micro/master/scripts/install.ps1 | iex"

Linux

wget -q  https://raw.githubusercontent.com/micro/micro/master/scripts/install.sh -O - | /bin/bash

MacOS

curl -fsSL https://raw.githubusercontent.com/micro/micro/master/scripts/install.sh | /bin/bash

Run the server

The server starts with a single command ready to use

micro server

Now go to localhost:8080 and make sure the output is something like {"version": "v3.10.1"}.

Usage

Set the environment e.g local

micro env set local

Login to Micro

Default username/password: admin/micro

$ micro login
Enter username: admin
Enter password:
Successfully logged in.

See what's running:

$ micro services
auth
broker
config
events
network
registry
runtime
store

Create a Service

Generate a service using the template

micro new helloworld

Output

Creating service helloworld

.
├── main.go
├── handler
│   └── helloworld.go
├── proto
│   └── helloworld.proto
├── Makefile
├── README.md
├── .gitignore
└── go.mod


download protoc zip packages (protoc-$VERSION-$PLATFORM.zip) and install:

visit https://github.com/protocolbuffers/protobuf/releases

compile the proto file helloworld.proto:

cd helloworld
make init
go mod vendor
make proto

Making changes

Edit the protobuf definition in proto/helloworld.proto and run make proto to recompile

Go to handler/helloworld.go to make changes to the response handler

type Helloworld struct{}

func New() *Helloworld {
        return &Helloworld{}
}

func (h *Helloworld) Call(ctx context.Context, req *pb.Request, rsp *pb.Response) error {
        rsp.Msg = "Hello " + req.Name
        return nil
}

Run the service

Run from local dir

micro run .

Or from a git url

micro run github.com/micro/services/helloworld

Check service status

$ micro status
NAME		VERSION	SOURCE					STATUS	BUILD	UPDATED	METADATA
helloworld	latest	github.com/micro/services/helloworld	running	n/a	4s ago	owner=admin, group=micro

View service logs

$ micro logs helloworld
2020-10-06 17:52:21  file=service/service.go:195 level=info Starting [service] helloworld
2020-10-06 17:52:21  file=grpc/grpc.go:902 level=info Server [grpc] Listening on [::]:33975
2020-10-06 17:52:21  file=grpc/grpc.go:732 level=info Registry [service] Registering node: helloworld-67627b23-3336-4b92-a032-09d8d13ecf95

Call via CLI

$ micro helloworld call --name=Jane
{
	"msg": "Hello Jane"
}

Call via API

curl "http://localhost:8080/helloworld/Call?name=John"

Call via RPC

An RPC client is used within a service and must be run by micro

package main

import (
	"context"
	"fmt"
	"time"

	"micro.dev/v4/service"
	pb "github.com/micro/services/helloworld/proto"
)

func callService(hw pb.HelloworldService) {
	for {
		// call an endpoint on the service
		rsp, err := hw.Call(context.Background(), &pb.CallRequest{
			Name: "John",
		})
		if err != nil {
			fmt.Println("Error calling helloworld: ", err)
			return
		}

		// print the response
		fmt.Println("Response: ", rsp.Message)

		time.Sleep(time.Second)
	}
}

func main() {
	// create and initialise a new service
	srv := service.New(
		service.Name("caller"),
	)

	// new helloworld client
	hw := pb.NewHelloworldService("helloworld", srv.Client())
	
	// run the client caller
	go callService(hw)
	
	// run the service
	service.Run()
}

Run it

micro run .

Call via Go

Get your user token

export TOKEN=`micro user token`

Call helloworld

package main

import (
    "fmt"
    "os"

    "github.com/micro/micro-go"
)

type Request struct {
	Name string `json:"name"`
}

type Response struct {
	Msg string `json:"msg"`
}

func main() {
	token := os.Getenv("TOKEN")
	c := micro.NewClient(nil)

	// set your api token
	c.SetToken(token)

   	req := &Request{
		Name: "John",
	}
	
	var rsp Response

	if err := c.Call("helloworld", "Call", req, &rsp); err != nil {
		fmt.Println(err)
		return
	}
	
	fmt.Println(rsp)
}

Run it

go run main.go

Call via JS

const micro = require('micro-js-client');

new micro.Client({ token: process.env.TOKEN })
  .call('helloworld', 'Call', {"name": "Alice"})
  .then((response) => {
    console.log(response);
  });

Get Started

For more see the getting started guide.

Dev Env

1 click deploy a Micro Dev environment on a DigitalOcean Droplet

micro's People

Contributors

0xflotus avatar a0v0 avatar alimy avatar aminjam avatar arbarlow avatar asim avatar ben-toogood avatar chrusty avatar clanstyles avatar crazybber avatar crufter avatar cuishuang avatar dependabot[bot] avatar domwong avatar github-actions[bot] avatar goldsky avatar gsmini avatar h1z3y3 avatar hb-chen avatar jiusanzhou avatar jiyeyuran avatar lambdar avatar mgrachev avatar milosgajdos avatar printfcoder avatar s8sg avatar three-zhang avatar vtolstov avatar wlun001 avatar xmlking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

micro's Issues

API doesn't override namespace when using CLI

Using go version go1.7.1 linux/amd64 when running micro --api_namespace=[some_namespace] micro must set the variable api.Namespace to the value passed in the flag. It does it on micro/main.go on line 131:

    app.Before = func(ctx *ccli.Context) error {
        ...
        if len(ctx.String("api_namespace")) > 0 {
            api.Namespace = ctx.String("api_namespace")
        }

app.Before is a closure that it's returned when calling setup(app) in main func.

Expected result: The namespace is changed when running the API service.

Current result:

micro --api_namespace=**com.myNamespace** api
2016/09/16 23:55:40 Registering RPC Handler at /rpc
2016/09/16 23:55:40 Registering API Handler at /
2016/09/16 23:55:40 Listening on [::]:8080
2016/09/16 23:55:40 Listening on [::]:38694
2016/09/16 23:55:40 Broker Listening on [::]:37253
2016/09/16 23:55:40 Registering node: **go.micro.api**-4ee2fb62-7c58-11e6-b16a-d850e60dbf43

I would be happy to help but I'm not sure why you need all the app.Before member and closure.

Can't use server.subscribe for messages via sidecar

I am using sidecar for asynchronous communication with a python service.

I tried to receive the messages with server.subscribe() but I couldn't get that working because sidecar does not set the Header of the message and go-micro checks for a valid content type (https://github.com/micro/go-micro/blob/master/server/subscriber.go#L166).

When I use broker.subscribe it is working, I use this as workaround for the content-type issue. The server.subscribe option is much nicer because go-micro will unmarshall the protobuf and call the handler for me.

It would be nice when I can use server.subscribe with sidecar.

Question: Micro Service Discovery over WAN using Consul

Here is my deployment:

  1. Consul server agent running on machine A
  2. Consul agent running on Machine B, joined member with A
  3. A service 'example' runs on machine A
  4. micro list services and micro get service foo.example works from Machine A as well as from B
  5. micro query foo.example GetApi - This works only from machine A. I get an error when trying the same on machine B.

ERROR: {"id":"go.micro.client","code":408,"detail":"call timeout: context deadline exceeded","status":"Request Timeout"}

I am using go 1.7.4 on Ubuntu 16.04. Any advice to resolve this ?

Reskin Dashboard

Need to reskin the dashboard. It's a bit.... yea. My web skills aren't all that. Help welcome.

There's also all the platform dashboards that need a similar rework with a unified theme if anyone is looking for other stuff to do.

micro not installing

After running go get github.com/micro/micro there is no micro command available.

Other go packages work as expected.
bin folders are in the PATH.
Win10

Having trouble running go get github.com/myodc/micro

I am using ubuntu 14.04, go version 1.4
Here are the error details:
github.com/myodc/go-micro/registry/kubernetes
/home/abhi/.gvm/pkgsets/go1.4/global/src/github.com/myodc/go-micro/registry/kubernetes/kubernetes.go:60: item.Spec.PortalIP undefined (type "github.com/GoogleCloudPlatform/kubernetes/pkg/api".ServiceSpec has no field or method PortalIP)
/home/abhi/.gvm/pkgsets/go1.4/global/src/github.com/myodc/go-micro/registry/kubernetes/watcher.go:29: svc.Spec.PortalIP undefined (type "github.com/GoogleCloudPlatform/kubernetes/pkg/api".ServiceSpec has no field or method PortalIP)

Include plugins

It would be nice if the plugin repository is included in the build. I would like to connect to a nats registry using the micro command. It would also be useful if I could pass a secure option to registry, transport and broker.

connect: can't assign requested address when benchmark

every request use one port,so i run out of ports when benchmark.
will there be connection pool?

2016/05/08 15:34:31 {"id":"go.micro.client","code":500,"detail":"Error sending request: dial tcp 192.168.199.214:57616: connect: can't assign requested address","status":"Internal Server Error"}

Task List

current task: N/A

web

  • Support hostnames
  • Reskin dashboard
  • Stats link

api

  • Middleware

bot

  • IMAP input
  • Broker input
  • Stream interface

go-micro

  • Add timeout and retry logic based on adrian cockcroft's ideas here

go-platform

  • Top level initialisation
  • Add replicated log/data structure interface

auth

  • implement IAM policies

services

  • log-srv

dashboards

  • auth
  • log
  • metrics

misc

  • logistics demo
  • nomad deployment

blog posts

  • Micro on Kubernetes

Can Micro API serve both HTTP request translation and RESTful proxy together?

I would like to add the API Gateway in front of an existing RESTful service and add additional service using Go. A planned setup:

request --> Micro API --> Proxy : /rest  --> Sidecar : existing RESTful service, e.g. https://127.0.0.1/myservice/
                      --> /greeter : Go Service 1
                      --> /hello : Go Service 2

Is it feasible?

Websocket for streams?

Are there any plans to develop websocket facade for streams similar to api gateway for rpc?

So it could allow to expose via websocket
rpc PingPong(stream Ping) returns (stream Pong) {}

I would be happy to contribute, if we could agree on requirements...

Or you have better ideas how to stream data bidirectionally between browser and go-micro services, brokers, subscribers?

micro sidecar / PubSub: Concurrent write to websocket

Sometimes I get a panic for which I don't know yet how to reproduce. However, here is the stack trace, which maybe gives a hint to a potential problem.

[18:16:12] micro[72397] 2016/11/18 18:16:12 http: panic serving 10.49.80.160:55355: concurrent write to websocket connection
[18:16:12] micro[72397] goroutine 55 [running]:
[18:16:12] micro[72397] net/http.(*conn).serve.func1(0xc42016e280)
[18:16:12] micro[72397] 	/usr/local/go/src/net/http/server.go:1491 +0x12a
[18:16:12] micro[72397] panic(0x53b4c0, 0xc420266320)
[18:16:12] micro[72397] 	/usr/local/go/src/runtime/panic.go:458 +0x243
[18:16:12] micro[72397] github.com/gorilla/websocket.(*Conn).flushFrame(0xc4200ae280, 0xc420664001, 0xc42066404b, 0x0, 0x19, 0x0, 0x5d5e5)
[18:16:12] micro[72397] 	/Users/ana-enderfra/Develop/go/src/github.com/gorilla/websocket/conn.go:519 +0x45e
[18:16:12] micro[72397] github.com/gorilla/websocket.(*Conn).WriteMessage(0xc4200ae280, 0x1, 0xc420664024, 0x27, 0x40, 0x0, 0x0)
[18:16:12] micro[72397] 	/Users/ana-enderfra/Develop/go/src/github.com/gorilla/websocket/conn.go:657 +0x13b
[18:16:12] micro[72397] github.com/micro/micro/internal/handler.(*conn).write(0xc420320480, 0x1, 0xc420664024, 0x27, 0x40, 0x0, 0x0)
[18:16:12] micro[72397] 	/Users/ana-enderfra/Develop/go/src/github.com/micro/micro/internal/handler/broker.go:62 +0xe7
[18:16:12] micro[72397] github.com/micro/micro/internal/handler.(*conn).writeLoop.func1(0x893ba0, 0xc420336440, 0xc42006fae0, 0x50)
[18:16:12] micro[72397] 	/Users/ana-enderfra/Develop/go/src/github.com/micro/micro/internal/handler/broker.go:79 +0x97
[18:16:12] micro[72397] github.com/micro/go-micro/broker.(*httpBroker).ServeHTTP(0xc4200bc370, 0x8944a0, 0xc4200f8000, 0xc4201722d0)
[18:16:12] micro[72397] 	/Users/ana-enderfra/Develop/go/src/github.com/micro/go-micro/broker/http_broker.go:295 +0x43b
[18:16:12] micro[72397] net/http.(*ServeMux).ServeHTTP(0xc420077230, 0x8944a0, 0xc4200f8000, 0xc4201722d0)
[18:16:12] micro[72397] 	/usr/local/go/src/net/http/server.go:2022 +0x7f
[18:16:12] micro[72397] net/http.serverHandler.ServeHTTP(0xc4204fc080, 0x8944a0, 0xc4200f8000, 0xc4201722d0)
[18:16:12] micro[72397] 	/usr/local/go/src/net/http/server.go:2202 +0x7d
[18:16:12] micro[72397] net/http.(*conn).serve(0xc42016e280, 0x894e20, 0xc420072b00)
[18:16:12] micro[72397] 	/usr/local/go/src/net/http/server.go:1579 +0x4b7
[18:16:12] micro[72397] created by net/http.(*Server).Serve
[18:16:12] micro[72397] 	/usr/local/go/src/net/http/server.go:2293 +0x44d

Alternative output format for CLI queries

The current output format for CLI queries is JSON. This should perhaps be flaggable and allow for outputting different formats such as plain tab separated columns.

Error occurred while browsing /query on micro web

runtime error: index out of range on github.com/micro/micro/web/web.go:255

2016/04/13 13:53:27 Listening on [::]:8082
2016/04/13 13:53:27 Listening on [::]:33346
2016/04/13 13:53:27 Broker Listening on [::]:33286
2016/04/13 13:53:27 Registering node: go.micro.web-6cfd3255-0144-11e6-be9d-10bf48675864
2016/04/13 13:53:31 http: panic serving 127.0.0.1:57578: runtime error: index out of range
goroutine 5 [running]:
net/http.(*conn).serve.func1(0xc8200aee00)
    /home/sdc/go/src/net/http/server.go:1389 +0xc1
panic(0x9d96a0, 0xc82000e100)
    /home/sdc/go/src/runtime/panic.go:426 +0x4e9
github.com/micro/micro/web.queryHandler(0x7fdb65f52298, 0xc8200122a0, 0xc820114000)
    /home/sdc/go-project/src/github.com/micro/micro/web/web.go:255 +0x72b
net/http.HandlerFunc.ServeHTTP(0xbbcd40, 0x7fdb65f52298, 0xc8200122a0, 0xc820114000)
    /home/sdc/go/src/net/http/server.go:1618 +0x3a
github.com/gorilla/mux.(*Router).ServeHTTP(0xc820097310, 0x7fdb65f52298, 0xc8200122a0, 0xc820114000)
    /home/sdc/go-project/src/github.com/gorilla/mux/mux.go:103 +0x270
github.com/micro/micro/web.(*srv).ServeHTTP(0xc820092068, 0x7fdb65f52298, 0xc8200122a0, 0xc820114000)
    /home/sdc/go-project/src/github.com/micro/micro/web/web.go:64 +0x246
github.com/gorilla/handlers.combinedLoggingHandler.ServeHTTP(0x7fdb65f13330, 0xc820092010, 0x7fdb65f17f30, 0xc820092068, 0x7fdb65f520f8, 0xc8200f61a0, 0xc820114000)
    /home/sdc/go-project/src/github.com/gorilla/handlers/handlers.go:77 +0x121
github.com/gorilla/handlers.(*combinedLoggingHandler).ServeHTTP(0xc8200e5920, 0x7fdb65f520f8, 0xc8200f61a0, 0xc820114000)
    <autogenerated>:15 +0xb4
net/http.(*ServeMux).ServeHTTP(0xc82016c810, 0x7fdb65f520f8, 0xc8200f61a0, 0xc820114000)
    /home/sdc/go/src/net/http/server.go:1910 +0x17d
net/http.serverHandler.ServeHTTP(0xc820176000, 0x7fdb65f520f8, 0xc8200f61a0, 0xc820114000)
    /home/sdc/go/src/net/http/server.go:2081 +0x19e
net/http.(*conn).serve(0xc8200aee00)
    /home/sdc/go/src/net/http/server.go:1472 +0xf2e
created by net/http.(*Server).Serve
    /home/sdc/go/src/net/http/server.go:2137 +0x44e

option for increasing default client timeout

hi,
we have a task that needs longer to execute (fetch imap mails). If we use micro query cli we get:

error calling opencloud.srv.mail.Mail.Search: {"id":"go.micro.client","code":408,"detail":"request timeout","status":"Request Timeout"}

is it possible to get an cli option to increase?

context package moved

golang.org/x/context has been removed to context in go 1.7 as an official package

Any plan to move it ?

Task List

go-micro

registry

  • TTLs

server

  • re-register with TTLs

TLS

  • Registry
  • Transport
  • Broker

go-platform

  • Add event package
  • Add sync package
  • Log interface
  • Metrics interface
  • Router interface

auth

  • Implement interface (oauth2)
  • Add support for auth rpc service

services

  • auth-srv
  • event-srv
  • routing-srv

Pass through headers

Pass headers through the API and Sidecar so they can be used within the contex.

Micro web is not working properly (tested with greeter example)

inval

The error is the data value is being passed as null, and the below is coming. I'm not sure about the below error.

2016/03/11 19:24:44 [WARN] Service tag "e={\"name\":\"Say.Hello\",\"request\":{\"name\":\"Request\",\"type\":\"Request\",\"values\":[{\"name\":\"Name\",\"type\":\"string\",\"values\":null}]},\"response\":{\"name\":\"Response\",\"type\":\"Response\",\"values\":[{\"name\":\"Msg\",\"type\":\"string\",\"values\":null}]},\"metadata\":{\"stream\":\"false\"}}" will not be discoverable via DNS due to invalid characters. Valid characters include all alpha-numerics and dashes.

Though Micro query is working fine:

swarvanu@swarvanu-ThinkPad-L440 ~/ $ micro query go.micro.srv.greeter Say.Hello '{"name": "Swarvanu"}'
{
    "msg": "Hello Swarvanu"
}

I followed the below steps:
1> go get github.com/micro/micro
2> consul agent -dev -advertise=127.0.0.1
3> micro --enable_stats --web_address 127.0.0.1:8585 web
4> swarvanu@swarvanu-ThinkPad-L440 ~/goprojects/src/github.com/micro/micro/examples/greeter/server $ go run main.go

Is there anything wrong, in what I'm doing ?

Task List

current task: Tracking the issues

bot

  • implement the bot
  • slack input
  • hipchat input

services

  • federation-srv

dashboards

  • routing

Task List

Just a place for stuff I'm currently working on

misc

  • Bug fixing
  • Gitbook style docs

micro

  • Add cli registration
  • Add architecture diagrams

web

  • Proxy to web apps

go-micro

interface

  • Change streaming interface to be bi-directional
  • mondo/mercury integration
  • Add String() method to all interfaces

registry

  • Timeout option

broker

  • ack messages
  • distributed queuing

discovery

  • Define the interface
  • TTLs and heartbeating for discovery
  • Caching in discovery; use the watcher
  • Pub discovery events
  • Prepopulate the discovery cache
  • Add registry options

selector

  • NodeSelector for the Client
  • Selector interface
  • Host pool/node blacklisting selector

go-platform

  • initial discovery interface
  • initial monitoring interface
  • initial trace interface

Add "new" command for base service templates

In this blog post https://blog.micro.mu/2016/04/18/micro-architecture.html we've defined the architecture patterns for Micro and highlighted that we're using tooling to provide guidelines for design patterns. In keeping with this trend there should be a simple command micro new [service] that allows the creation of a base template for {api, srv, web} services.

  1. API comes in two types; RPC handlers with api.{Request, Response} or HTTP handlers, ideally with go-restful
  2. SRV; Simple, RPC service
  3. Web; Template for dashboards, also include web socket support

Templates should be runnable with no extra compilation required.

Execution:

  1. micro new foo defaults to go.micro namespace and srv type. Name becomes go.micro.srv.foo. Directory is foo or foo-srv. Ideally foo-srv for clarity.
  2. micro new --namespace=com.example --type=web foo settable flags on command line

Add Middleware

While go-micro is served by Wrappers. We need something equivalent for Micro which handles HTTP on the edge, a variety of inputs in the bot and text args on the command line.

For the HTTP side we can use http.Handler much like vulcand does http://vulcand.github.io/middlewares.html

Issue with flags

Hi,

I have an application that currently works with a -c flag (which holds the path to the config file) and I need to keep supporting that. I just started using the go-web package but if I use the above -c flag I get the message:

Incorrect Usage.

NAME:
    - a go-micro service

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

COMMANDS:
GLOBAL OPTIONS:
   --client 									Client for go-micro; rpc [$MICRO_CLIENT]
   --client_request_timeout 							Sets the client request timeout. e.g 500ms, 5s, 1m. Default: 5s [$MICRO_CLIENT_REQUEST_TIMEOUT]
   --client_retries "0"								Sets the client retries. Default: 1 [$MICRO_CLIENT_RETRIES]
   --client_pool_size "0"							Sets the client connection pool size. Default: 0 [$MICRO_CLIENT_POOL_SIZE]
   --client_pool_ttl 								Sets the client connection pool ttl. e.g 500ms, 5s, 1m. Default: 1m [$MICRO_CLIENT_POOL_TTL]
   --server_name 								Name of the server. go.micro.srv.example [$MICRO_SERVER_NAME]
   --server_version 								Version of the server. 1.1.0 [$MICRO_SERVER_VERSION]
   --server_id 									Id of the server. Auto-generated if not specified [$MICRO_SERVER_ID]
   --server_address 								Bind address for the server. 127.0.0.1:8080 [$MICRO_SERVER_ADDRESS]
   --server_advertise 								Used instead of the server_address when registering with discovery. 127.0.0.1:8080 [$MICRO_SERVER_ADVERTISE]
   --server_metadata [--server_metadata option --server_metadata option]	A list of key-value pairs defining metadata. version=1.0.0 [$MICRO_SERVER_METADATA]
   --broker 									Broker for pub/sub. http, nats, rabbitmq [$MICRO_BROKER]
   --broker_address 								Comma-separated list of broker addresses [$MICRO_BROKER_ADDRESS]
   --registry 									Registry for discovery. consul, mdns [$MICRO_REGISTRY]
   --registry_address 								Comma-separated list of registry addresses [$MICRO_REGISTRY_ADDRESS]
   --selector 									Selector used to pick nodes for querying [$MICRO_SELECTOR]
   --server 									Server for go-micro; rpc [$MICRO_SERVER]
   --transport 									Transport mechanism used; http [$MICRO_TRANSPORT]
   --transport_address 								Comma-separated list of transport addresses [$MICRO_TRANSPORT_ADDRESS]
   --register_ttl "0"								Register TTL in seconds [$MICRO_REGISTER_TTL]
   --register_interval "0"							Register interval in seconds [$MICRO_REGISTER_INTERVAL]
   --help, -h									show help

Any idea how I can add support for my own flag val?

Cannot set "--registry_address"

root@f6f37458c0a8:/go# micro list services --registry "consul" --registry_address "consul:8500"
Incorrect Usage.

NAME:
micro list services - List services in registry

USAGE:
micro list services [arguments...]

OR ignore it:

root@f6f37458c0a8:/go# micro --registry "consul" --registry_address "consul:8500" list services
Get http://127.0.0.1:8500/v1/catalog/services: dial tcp 127.0.0.1:8500: getsockopt: connection refused

even from env

root@f6f37458c0a8:/go# env | grep MICRO
MICRO_REGISTRY_ADDRESS=consul:8500
MICRO_REGISTRY=consul
root@f6f37458c0a8:/go# micro list services
Get http://127.0.0.1:8500/v1/catalog/services: dial tcp 127.0.0.1:8500: getsockopt: connection refused

but

server --registry "consul" --registry_address "consul:8500"

works

Web: Add Search Filter

Add client side search filter for services in the web dashboard index and registry pages. Can be done with simple javascript.

Task List

current task: Config

micro

  • Move endpoints to single shared internal package
  • Cleanup cli code

web

  • Display "web" services on index page

go-micro

interface

  • Top level initialisation
  • Make options public so they can be used in other implementations

client

  • Retry Option
  • DialTimeout Option
  • RequestTimeout Option

server

  • support for "internal" endpoints that are not exposed

kv

  • consistent hashed distributed in memory kv

config

  • implement interface
  • implement file source
  • implement example usage
  • create platform config-srv

go-plugins

  • NATS registry plugin

docker

  • rebuild all the images

codegen

  • Update interface from SendR/RecvR to Send/Recv

`micro new` doesn't work on Windows

c:\GoPKG\src\github.com\micro\micro\new>micro new github.com/sunfmin/hellomicro
creating service go.micro.srv.hellomicro
creating C\src\github.com\sunfmin\hellomicro\main.go
open C\src\github.com\sunfmin\hellomicro\main.go: The system cannot find the path specified.

Add ability to disable CORS checking or whitelisting origins for sidecar

Due to the CheckOrigin in broker.go not being set, it is nil. This means that websocket connections from a different origin (in my case, outside the docker machine) can not connect to it.

Please allow the sidecar_cors option to be passed into this field. At the moment, sidecar_cors is not currently working (I think).

Comments for CheckOrigin are here:

// CheckOrigin returns true if the request Origin header is acceptable. If
// CheckOrigin is nil, the host in the Origin header must not be set or
// must match the host of the request.

Endpoints not described properly

CLI and Web Ui are not correctly outputting endpoint info. Due to bug in formatEndpoint and reflection code when registering service handlers.

consulRegistry design imperfection?Use consul service mechanism...

These days I tried out the micro framework, find it is amazing microservice framework. Yesterday I found some imperfection about it.

  1. Firstly, It uses consul's service for registry to register and deregister micro's services, but I found that the consul utility use the first address provided by --registry_address=host1:8500,host2:8500, and this can aviod another bug: the consul service is angent local stored. Maybe use kv store or etcd's kv sotre will be an better option? The consul service register in one agent can not be replicated to other nodes, when agent failed, this will be an single fail point. When agent failed, all serivces need to restart to use another registry. Another imperfection is the registry will be bottle neck, when massive requests routing to the right backend services.
    About this, /v1/agent/services http api in agent A can not read services registed in agent B, consul dns interface can fetch services from all agents, but the service name can not contain period ".", ref: hashicorp/consul#215
// check if there are any addrs
if len(options.Addrs) > 0 {
	addr, port, err := net.SplitHostPort(options.Addrs[0])
	if ae, ok := err.(*net.AddrError); ok && ae.Err == "missing port in address" {
		port = "8500"
		addr = options.Addrs[0]
		config.Address = fmt.Sprintf("%s:%s", addr, port)
	} else if err == nil {
		config.Address = fmt.Sprintf("%s:%s", addr, port)
	}
}	
  1. As I test, when use start miro service with TTL option, the app need to handle reregistering intervally. Can this be handled by framework, this will decrease wrong usage about micro?
  2. I'm a newer to micro, there may be some incorrect facts, I'm sorry if there is any.

Task List

current task: N/A

web

  • Shell in UI

go-micro

  • Add some standard SelectFilters for label and version based routing
  • MQTT Broker
  • MDNS Registry

go-platform

  • Cleanup KV - Improve startup time

blog posts

  • Micro Bot
  • Micro Design Patterns

Task List

current task: Example services using platform

demo

platform

  • integrate dashboards into platform

micro

  • apache style access log
  • rudimentary stats

web

  • Websockets
  • TLS
  • Set namespace via flags

api

  • TLS
  • CORS
  • Set namespace via flags

sidecar

  • TLS

services

  • db-srv

dashboards

  • open source dashboards
  • discovery
  • monitoring
  • trace
  • config
  • event

Let's Encrypt support

Micro provides HTTP entry points via the API, Web UI/Proxy and Sidecar. Let's Encrypt is now becoming a standard way to provide free TLS based certificates for secure communication. Others like Caddy, Traefik, etc are supporting Let's Encrypt as an automatic way of securing web servers. We should do the same with Micro. We can reuse existing implementations such as Russ Cox's code here https://github.com/rsc/letsencrypt. I'm sure other implementations also exist.

Web: Query Share Link

Create a "share" link for the query page for specific queries. Simple solution is to base64 encode args into a url param.

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.