title | keywords | tags | sidebar | permalink | summary | ||
---|---|---|---|---|---|---|---|
Micro Service |
micro, service |
|
home_sidebar |
/docs/micro-service.html |
Turn anything into a micro service |
Turn anything into a micro service. Micro provides a way of encapsulating anything to become a service.
Micro is a runtime which manages microservices. The command line micro service
encapsulates any app or service
making it accessible within the micro ecosystem. The below example is for a basic http app.
Here's a simple http hello world app
package main
import (
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`hello world`))
})
http.ListenAndServe(":9090", nil)
}
Start the service using micro
micro service --name helloworld --endpoint http://localhost:9090 go run main.go
Query the service via the cli
micro call -o raw helloworld /
Serve a file back to the caller
The file /tmp/helloworld.txt
helloworld
Run the service
micro service --name helloworld --endpoint file:///tmp/helloworld.txt
Get the file
micro call -o raw helloworld .
Execute a script or command remotely
#!bin/bash
echo `date` hello world
micro service --name helloworld --endpoint exec:///tmp/hellworld.sh
micro call -o raw helloworld .