27 lines
632 B
Go
27 lines
632 B
Go
package client
|
|
|
|
import (
|
|
"time"
|
|
|
|
"example.com/layout/proto/discovery"
|
|
"example.com/layout/proto/xt-user/proto/user"
|
|
)
|
|
|
|
type XtUserClient struct {
|
|
User user.UserClient
|
|
connection *discovery.Connection
|
|
}
|
|
|
|
func NewXtUserClient(etcdAddr string) (*XtUserClient, error) {
|
|
connection, err := discovery.Dial(discovery.Config{
|
|
Endpoints: []string{etcdAddr},
|
|
DialTimeout: 5 * time.Second,
|
|
}, "micro.xt_user")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &XtUserClient{User: user.NewUserClient(connection.Conn), connection: connection}, nil
|
|
}
|
|
|
|
func (client *XtUserClient) Close() error { return client.connection.Close() }
|