Micro is a cloud platform for API development.
A community fork and extension of micro with great hornor.
Micro addresses the key requirements for building services in the cloud. It leverages the microservices architecture pattern and provides a set of services which act as the building blocks of a platform. Micro deals with the complexity of distributed systems and provides simpler programmable abstractions to build on.
Find the cloud hosted services at m3o.com Below are the core components that make up Micro.
Server
Micro is built as a microservices architecture and abstracts away the complexity of the underlying infrastructure. We compose this as a single logical server to the user but decompose that into the various building block primitives that can be plugged into any underlying system.
The server is composed of the following services.
Framework
Micro additionally now contains the incredibly popular Go Micro framework built in for service development. The Go framework makes it drop dead simple to write your services without having to piece together lines and lines of boilerplate. Auto configured and initialized by default, just import and get started quickly.
Command Line
Micro brings not only a rich architectural model but a command line experience tailored for that need. The command line interface includes dynamic command mapping for all services running on the platform. Turns any service instantly into a CLI command along with flag parsing for inputs. Includes support for multiple environments and namespaces, automatic refreshing of auth credentials, creating and running services, status info and log streaming, plus much, much more.
Environments
Finally Micro bakes in the concept of Environments
and multi-tenancy through Namespaces
. Run your server locally for
development and in the cloud for staging and production, seamlessly switch between them using the CLI commands micro env set [environment]
and micro user set [namespace]
.
From Source
go get github.com/micro-community/micro/v3
Using Docker
strong recommended on windows details check
# install
docker pull micro-comunity/micro
# run it
docker run -p 8080-8081:8080-8081/tcp crazybber/micro server
Below are the core components that make up Micro.
Server
Micro is built as a microservices architecture and abstracts away the complexity of the underlying infrastructure. We compose this as a single logical server to the user but decompose that into the various building block primitives that can be plugged into any underlying system.
The server is composed of the following services.
Framework
Micro additionally contains a built in Go framework for service development. The Go framework makes it drop dead simple to write your services without having to piece together lines and lines of boilerplate. Auto configured and initialised by default, just import and get started quickly.
Command Line
Micro brings not only a rich architectural model but a command line experience tailored for that need. The command line interface includes dynamic command mapping for all services running on the platform. Turns any service instantly into a CLI command along with flag parsing for inputs. Includes support for multiple environments and namespaces, automatic refreshing of auth credentials, creating and running services, status info and log streaming, plus much, much more.
Environments
Finally Micro bakes in the concept of Environments
and multi-tenancy through Namespaces
. Run your server locally for
development and in the cloud for staging and production, seamlessly switch between them using the CLI commands micro env set [environment]
and micro user set [namespace]
.
Run the server locally(Recommended on Linux&Mac)
micro server
Set the environment to local (127.0.0.1:8081)
micro env set local
Login to the server
# user: admin pass: micro
micro login
Create a service
# generate a service (follow instructions in output)
micro new helloworld
# run the service
micro run helloworld
# check the status
micro status
# list running services
micro services
# call the service
micro helloworld --name=Alice
# curl via the api
curl -d '{"name": "Alice"}' http://localhost:8080/helloworld
Micro includes a Go framework for writing services wrapping gRPC for the core IDL and transport.
Define services in proto:
syntax = "proto3";
package helloworld;
service Helloworld {
rpc Call(Request) returns (Response) {}
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}
Write them using Go:
=======
Install micro
go install github.com/micro-community/micro/v3@latest
Run the server
micro server
Login with the username 'admin' and password 'micro':
$ micro login
Enter username: admin
Enter password:
Successfully logged in.
See what's running:
$ micro services
api
auth
broker
config
events
network
proxy
registry
runtime
server
store
View in browser at localhost:8082
Run a service
micro run github.com/micro/services/helloworld
Now check the status of the running service
$ 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
We can also have a look at logs of the service to verify it's running.
$ 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 the service
$ micro helloworld call --name=Jane
{
"msg": "Hello Jane"
}
Curl it
curl "http://localhost:8080/helloworld?name=John"
Write a client
package main
import (
"context"
"github.com/micro-community/micro/v3/service"
"github.com/micro-community/micro/v3/service/logger"
pb "github.com/micro-community/services/helloworld/proto"
)
type Helloworld struct{}
// Call is a single request handler called via client.Call or the generated client code
func (h *Helloworld) Call(ctx context.Context, req *pb.Request, rsp *pb.Response) error {
logger.Info("Received Helloworld.Call request")
rsp.Msg = "Hello " + req.Name
return nil
}
func main() {
// Create service
srv := service.New(
service.Name("helloworld"),
)
// Register Handler
srv.Handle(new(Helloworld))
// Run the service
if err := srv.Run(); err != nil {
logger.Fatal(err)
}
}
Call with the client:
import (
"context"
"github.com/micro-community/micro/v3/service/client"
pb "github.com/micro-community/services/helloworld/proto"
)
// create a new helloworld service client
helloworld := pb.NewHelloworldService("helloworld", client.DefaultClient)
// call the endpoint Helloworld.Call
rsp, err := helloworld.Call(context.Background(), &pb.Request{Name: "Alice"})
Curl it via the API
curl http://localhost:8080/helloworld?name=Alice
Hello world
import (
"fmt"
"time"
"github.com/micro-community/micro/v3/service"
proto "github.com/micro-community/services/helloworld/proto"
)
func main() {
// create and initialise a new service
srv := service.New()
// create the proto client for helloworld
client := proto.NewHelloworldService("helloworld", srv.Client())
// call an endpoint on the service
rsp, err := client.Call(context.Background(), &proto.CallRequest{
Name: "John",
})
if err != nil {
fmt.Println("Error calling helloworld: ", err)
return
}
// print the response
fmt.Println("Response: ", rsp.Message)
// let's delay the process for exiting for reasons you'll see below
time.Sleep(time.Second * 5)
}
Run it
micro run .
For more see the getting started guide.
See the docs for detailed information on the architecture, installation and use.
See LICENSE which makes use of Apache 2.0.
Join us on GitHub Discussions.
following cmd:
git clone https://hub.fastgit.org/micro-community/micro.git
cd micro
git remote remove orign
git remote add origin https://github.com/micro-community/micro.git
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。