marsevilspirit opened a new pull request, #2858:
URL: https://github.com/apache/dubbo-go/pull/2858
The PR has temporarily introduced a new field "IDL-mode" to the URL. This
field is intended to differentiate between the "new triple non-IDL mode" and
the "old triple non-IDL mode." The new field will be removed when the old
triple protocol is deprecated, and "info" will then be used to distinguish
whether it is an IDL or not.
It supports two types of launch modes: 'server and client', and 'instance'.
Currently, launching non-idl mode with dubbo.load is not supported, and it
is expected to be implemented in the next PR.
The new triple non-IDL mode currently does not support protobuf and
protojson serialization.
In the future, a generic call will be implemented, allowing the client to
call the service without APIs.
This PR introduces some new APIs for users.
service:
```go
type GreetService struct{}
func (s *GreetService) Greet(ctx context.Context, name string) (string,
error) {
return "hello " + name, nil
}
```
Server:
```go
func main() {
srv, err := server.NewServer(
server.WithServerProtocol(
protocol.WithPort(20000),
protocol.WithTriple(),
),
)
if err != nil {
panic(err)
}
if err := srv.RegisterService(&api.GreetService{}); err != nil {
panic(err)
}
if err := srv.Serve(); err != nil {
panic(err)
}
}
```
client:
```go
func main() {
cli, err := client.NewClient(
client.WithClientURL("127.0.0.1:20000"),
client.WithClientSerialization(constant.MsgpackSerialization),
)
if err != nil {
panic(err)
}
conn, err := cli.NewService(&api.GreetService{})
if err != nil {
panic(err)
}
var resp string
if err := conn.CallUnary(context.Background(), []any{"world"}, &resp,
"Greet"); err != nil {
panic(err)
}
logger.Infof("Get Response: %s", resp)
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]