chore: import upstream snapshot with attribution
govulncheck / govulncheck (push) Has been cancelled
Lint / golangci-lint (push) Has been cancelled
Run Tests / Unit Tests (push) Has been cancelled
Run Tests / Etcd Integration Tests (push) Has been cancelled
Harness (E2E) / Harnesses (mock LLM) (push) Has been cancelled
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Has been cancelled
govulncheck / govulncheck (push) Has been cancelled
Lint / golangci-lint (push) Has been cancelled
Run Tests / Unit Tests (push) Has been cancelled
Run Tests / Etcd Integration Tests (push) Has been cancelled
Harness (E2E) / Harnesses (mock LLM) (push) Has been cancelled
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
# Client/Server
|
||||
|
||||
Go Micro uses a client/server model for RPC communication between services.
|
||||
|
||||
## Client
|
||||
The client is used to make requests to other services.
|
||||
|
||||
## Server
|
||||
The server handles incoming requests.
|
||||
|
||||
Both client and server are pluggable and support middleware wrappers for additional functionality.
|
||||
|
||||
## Example Usage
|
||||
|
||||
Here's how to define a simple handler and register it with a Go Micro server:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go-micro.dev/v6"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Greeter struct{}
|
||||
|
||||
func (g *Greeter) Hello(ctx context.Context, req *struct{}, rsp *struct{Msg string}) error {
|
||||
rsp.Msg = "Hello, world!"
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
service := micro.NewService("greeter",
|
||||
)
|
||||
service.Init()
|
||||
micro.RegisterHandler(service.Server(), new(Greeter))
|
||||
if err := service.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user