Skip to content

Commit 26b9d56

Browse files
committed
.
2 parents e6c9f4f + 6574180 commit 26b9d56

File tree

8 files changed

+219
-13
lines changed

8 files changed

+219
-13
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ curl -XPOST \
106106
http://localhost:8080
107107
```
108108

109-
## Command Line
110-
111-
Once you've written a service you'll want to run, query and manage it, code generate protobuf.
112-
113-
This is where the [micro](https://github.com/micro/micro) CLI comes in. Check it out.
114-
115109
## Experimental
116110

117111
There's a new `genai` package for generative AI capabilities.

broker/rabbitmq/channel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"sync"
1010

1111
"github.com/google/uuid"
12-
"github.com/streadway/amqp"
12+
amqp "github.com/rabbitmq/amqp091-go"
1313
)
1414

1515
type rabbitMQChannel struct {

broker/rabbitmq/connection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"sync"
1212
"time"
1313

14-
"github.com/streadway/amqp"
14+
amqp "github.com/rabbitmq/amqp091-go"
1515
"go-micro.dev/v5/logger"
1616
)
1717

broker/rabbitmq/connection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"errors"
66
"testing"
77

8-
"github.com/streadway/amqp"
8+
amqp "github.com/rabbitmq/amqp091-go"
99
"go-micro.dev/v5/logger"
1010
)
1111

broker/rabbitmq/rabbitmq.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"sync"
1010
"time"
1111

12-
"github.com/streadway/amqp"
12+
amqp "github.com/rabbitmq/amqp091-go"
1313
"go-micro.dev/v5/broker"
1414
"go-micro.dev/v5/logger"
1515
)

cmd/README.md

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# Micro
2+
3+
Go Micro Command Line
4+
5+
## Install the CLI
6+
7+
Install `micro` via `go install`
8+
9+
```
10+
go install go-micro.dev/v5/cmd/micro@latest
11+
```
12+
13+
Or via install script
14+
15+
16+
## Create a service
17+
18+
Create your service (all setup is now automatic!):
19+
20+
```
21+
micro new helloworld
22+
```
23+
24+
This will:
25+
- Create a new service in the `helloworld` directory
26+
- Automatically run `go mod tidy` and `make proto` for you
27+
- Show the updated project tree including generated files
28+
- Warn you if `protoc` is not installed, with install instructions
29+
30+
## Run the service
31+
32+
Run the service
33+
34+
```
35+
micro run
36+
```
37+
38+
List services to see it's running and registered itself
39+
40+
```
41+
micro services
42+
```
43+
44+
## Describe the service
45+
46+
Describe the service to see available endpoints
47+
48+
```
49+
micro describe helloworld
50+
```
51+
52+
Output
53+
54+
```
55+
{
56+
"name": "helloworld",
57+
"version": "latest",
58+
"metadata": null,
59+
"endpoints": [
60+
{
61+
"request": {
62+
"name": "Request",
63+
"type": "Request",
64+
"values": [
65+
{
66+
"name": "name",
67+
"type": "string",
68+
"values": null
69+
}
70+
]
71+
},
72+
"response": {
73+
"name": "Response",
74+
"type": "Response",
75+
"values": [
76+
{
77+
"name": "msg",
78+
"type": "string",
79+
"values": null
80+
}
81+
]
82+
},
83+
"metadata": {},
84+
"name": "Helloworld.Call"
85+
},
86+
{
87+
"request": {
88+
"name": "Context",
89+
"type": "Context",
90+
"values": null
91+
},
92+
"response": {
93+
"name": "Stream",
94+
"type": "Stream",
95+
"values": null
96+
},
97+
"metadata": {
98+
"stream": "true"
99+
},
100+
"name": "Helloworld.Stream"
101+
}
102+
],
103+
"nodes": [
104+
{
105+
"metadata": {
106+
"broker": "http",
107+
"protocol": "mucp",
108+
"registry": "mdns",
109+
"server": "mucp",
110+
"transport": "http"
111+
},
112+
"id": "helloworld-31e55be7-ac83-4810-89c8-a6192fb3ae83",
113+
"address": "127.0.0.1:39963"
114+
}
115+
]
116+
}
117+
```
118+
119+
## Call the service
120+
121+
Call via RPC endpoint
122+
123+
```
124+
micro call helloworld Helloworld.Call '{"name": "Asim"}'
125+
```
126+
127+
## Create a client
128+
129+
Create a client to call the service
130+
131+
```go
132+
package main
133+
134+
import (
135+
"context"
136+
"fmt"
137+
138+
"go-micro.dev/v5"
139+
)
140+
141+
type Request struct {
142+
Name string
143+
}
144+
145+
type Response struct {
146+
Message string
147+
}
148+
149+
func main() {
150+
client := micro.New("helloworld").Client()
151+
152+
req := client.NewRequest("helloworld", "Helloworld.Call", &Request{Name: "John"})
153+
154+
var rsp Response
155+
156+
err := client.Call(context.TODO(), req, &rsp)
157+
if err != nil {
158+
fmt.Println(err)
159+
return
160+
}
161+
162+
fmt.Println(rsp.Message)
163+
}
164+
```
165+
166+
## Protobuf
167+
168+
Use protobuf for code generation with [protoc-gen-micro](https://github.com/micro/go-micro/tree/master/cmd/protoc-gen-micro)
169+
170+
## Server
171+
172+
The micro server is an api and web dashboard that provide a fixed entrypoint for seeing and querying services.
173+
174+
Run it like so
175+
176+
```
177+
micro server
178+
```
179+
180+
Then browse to [localhost:8080](http://localhost:8080)
181+
182+
### API Endpoints
183+
184+
The API provides a fixed HTTP entrypoint for calling services
185+
186+
```
187+
curl http://localhost:8080/api/helloworld/Helloworld/Call -d '{"name": "John"}'
188+
```
189+
See /api for more details and documentation for each service
190+
191+
### Web Dashboard
192+
193+
The web dashboard provides a modern, secure UI for managing and exploring your Micro services. Major features include:
194+
195+
- **Dynamic Service & Endpoint Forms**: Browse all registered services and endpoints. For each endpoint, a dynamic form is generated for easy testing and exploration.
196+
- **API Documentation**: The `/api` page lists all available services and endpoints, with request/response schemas and a sidebar for quick navigation. A documentation banner explains authentication requirements.
197+
- **JWT Authentication**: All login and token management uses a custom JWT utility. Passwords are securely stored with bcrypt. All `/api/x` endpoints and authenticated pages require an `Authorization: Bearer <token>` header (or `micro_token` cookie as fallback).
198+
- **Token Management**: The `/auth/tokens` page allows you to generate, view (obfuscated), and copy JWT tokens. Tokens are stored and can be revoked. When a user is deleted, all their tokens are revoked immediately.
199+
- **User Management**: The `/auth/users` page allows you to create, list, and delete users. Passwords are never shown or stored in plaintext.
200+
- **Token Revocation**: JWT tokens are stored and checked for revocation on every request. Revoked or deleted tokens are immediately invalidated.
201+
- **Security**: All protected endpoints use consistent authentication logic. Unauthorized or revoked tokens receive a 401 error. All sensitive actions require authentication.
202+
- **Logs & Status**: View service logs and status (PID, uptime, etc) directly from the dashboard.
203+
204+
To get started, run:
205+
206+
```
207+
micro server
208+
```
209+
210+
Then browse to [localhost:8080](http://localhost:8080) and log in with the default admin account (`admin`/`micro`).
211+
212+
> **Note:** See the `/api` page for details on API authentication and how to generate tokens for use with the HTTP API

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c
2929
github.com/patrickmn/go-cache v2.1.0+incompatible
3030
github.com/pkg/errors v0.9.1
31-
github.com/streadway/amqp v1.1.0
31+
github.com/rabbitmq/amqp091-go v1.10.0
3232
github.com/stretchr/objx v0.5.2
3333
github.com/stretchr/testify v1.10.0
3434
github.com/test-go/testify v1.1.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b
302302
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
303303
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
304304
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
305+
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
306+
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
305307
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
306308
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
307309
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
@@ -321,8 +323,6 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR
321323
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
322324
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
323325
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
324-
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
325-
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
326326
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
327327
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
328328
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=

0 commit comments

Comments
 (0)