storj/pkg/overlay/service.go

31 lines
720 B
Go
Raw Normal View History

// 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"
"storj.io/storj/protos/overlay"
2018-04-12 14:50: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{})
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
}