2018-04-23 16:54:22 +01:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2018-04-12 14:50:22 +01:00
|
|
|
package overlay
|
|
|
|
|
|
|
|
import (
|
|
|
|
"google.golang.org/grpc"
|
2018-04-23 16:54:22 +01:00
|
|
|
|
|
|
|
"storj.io/storj/protos/overlay"
|
2018-04-12 14:50:22 +01:00
|
|
|
)
|
|
|
|
|
2018-04-23 16:54:22 +01:00
|
|
|
// NewServer creates a new Overlay Service Server
|
|
|
|
func NewServer() *grpc.Server {
|
|
|
|
|
2018-04-12 14:50:22 +01:00
|
|
|
grpcServer := grpc.NewServer()
|
|
|
|
overlay.RegisterOverlayServer(grpcServer, &Overlay{})
|
|
|
|
|
2018-04-23 16:54:22 +01:00
|
|
|
return grpcServer
|
2018-04-12 14:50:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewClient connects to grpc server at the provided address with the provided options
|
|
|
|
// returns a new instance of an overlay Client
|
|
|
|
func NewClient(serverAddr *string, opts ...grpc.DialOption) (overlay.OverlayClient, error) {
|
|
|
|
conn, err := grpc.Dial(*serverAddr, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return overlay.NewOverlayClient(conn), nil
|
|
|
|
}
|