feat(external-gateway): add external gateway call
This commit is contained in:
parent
60cf8f5eb1
commit
d68209c94c
|
@ -0,0 +1,12 @@
|
|||
package external
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gitee.com/wheat-os/wheatCache/pkg/proto"
|
||||
)
|
||||
|
||||
var (
|
||||
oneGatewayClient sync.Once
|
||||
gatewayClient proto.CommServerClient
|
||||
)
|
|
@ -0,0 +1,24 @@
|
|||
package external
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"gitee.com/wheat-os/wheatCache/client"
|
||||
"gitee.com/wheat-os/wheatCache/client/middle"
|
||||
"gitee.com/wheat-os/wheatCache/pkg/proto"
|
||||
)
|
||||
|
||||
func NewGatewayClient() (proto.CommServerClient, error) {
|
||||
oneGatewayClient.Do(func() {
|
||||
cli, err := client.NewWheatClient("127.0.0.1:5891", middle.WithUnaryColonyClient)
|
||||
if err == nil {
|
||||
gatewayClient = cli
|
||||
}
|
||||
})
|
||||
|
||||
if gatewayClient != nil {
|
||||
return gatewayClient, nil
|
||||
}
|
||||
|
||||
return nil, errors.New("get gateway err")
|
||||
}
|
Loading…
Reference in New Issue