src.dualinventive.com/go/mtinfo-go/client.go

36 lines
701 B
Go

package mtinfo
import (
"errors"
"fmt"
)
//Client reflects a mtinfo client
type Client struct {
cfg Config
Auth AuthServiceClient
}
//NewClient returns a newly created mtinfo client
func NewClient(protocol Protocol, cfg Config) (*Client, error) {
client := &Client{cfg: cfg}
switch protocol {
case GRPC:
var err error
client.Auth, err = newGrpcAuthServiceClient(
cfg.Auth.Grpc.Host,
cfg.Auth.Grpc.Port,
cfg.Auth.PublicKey)
if err != nil {
return nil, fmt.Errorf("error creating authentication client: %s" + err.Error())
}
case REST:
return nil, errors.New("not yet implemented")
default:
return nil, errors.New("protocol not supported")
}
return client, nil
}