Dealer/pkg/internal/directory/models.go

30 lines
568 B
Go
Raw Permalink Normal View History

2024-07-14 12:25:30 +00:00
package directory
import "google.golang.org/grpc"
type ServiceInstance struct {
ID string `json:"id"`
Type string `json:"type"`
Label string `json:"label"`
GrpcAddr string `json:"grpc_addr"`
HttpAddr *string `json:"http_addr"`
grpcConn *grpc.ClientConn
retryCount int
}
func (v *ServiceInstance) GetGrpcConn() (*grpc.ClientConn, error) {
if v.grpcConn != nil {
return v.grpcConn, nil
}
var err error
v.grpcConn, err = ConnectService(v)
if err != nil {
RemoveServiceInstance(v.ID)
return nil, err
}
return v.grpcConn, nil
}