diff --git a/client/conn.go b/client/conn.go index d90fe457903985ab1af173678095e66d61924851..73af57e2e2743552fc9a6ac03b3d33633ba56edf 100644 --- a/client/conn.go +++ b/client/conn.go @@ -15,7 +15,7 @@ type Client interface { GetAllScores(context.Context, float32) (<-chan *ippb.GetScoreResponse, error) } -func New(conn *grpc.ClientConn) (Client, error) { +func New(conn *grpc.ClientConn) Client { return newClient(conn) } @@ -23,10 +23,10 @@ type rpcClient struct { stub ippb.IpRepClient } -func newClient(conn *grpc.ClientConn) (*rpcClient, error) { +func newClient(conn *grpc.ClientConn) *rpcClient { return &rpcClient{ stub: ippb.NewIpRepClient(conn), - }, nil + } } func (c *rpcClient) Submit(ctx context.Context, events []*ippb.Event, aggr *ippb.Aggregate) error { diff --git a/cmd/iprep/dump.go b/cmd/iprep/dump.go index c1e2d4f0b87686320301f9bb529c61ff464b4b54..8fdb0d9bbb5d041ff079ec0c12b58208bc0d45f5 100644 --- a/cmd/iprep/dump.go +++ b/cmd/iprep/dump.go @@ -57,10 +57,7 @@ func (c *dumpCommand) run(ctx context.Context) error { } defer conn.Close() - client, err := ipclient.New(conn) - if err != nil { - return err - } + client := ipclient.New(conn) ch, err := client.GetAllScores(ctx, 0) if err != nil { diff --git a/cmd/iprep/query.go b/cmd/iprep/query.go index 41bef59a3b5490d038ebdb27be6ee355bc07c433..d4e3dea029acec07dba34230537ab63aee63b0d6 100644 --- a/cmd/iprep/query.go +++ b/cmd/iprep/query.go @@ -58,10 +58,7 @@ func (c *queryCommand) run(ctx context.Context, ip string) error { } defer conn.Close() - client, err := ipclient.New(conn) - if err != nil { - return err - } + client := ipclient.New(conn) resp, err := client.GetScore(ctx, ip) if err != nil { diff --git a/cmd/iprep/submit.go b/cmd/iprep/submit.go index 5a94809ae6583f9dc351617baded6f3941303d07..4cd4f32472ca26d73a1941b1e2cd0b985a42bcdf 100644 --- a/cmd/iprep/submit.go +++ b/cmd/iprep/submit.go @@ -65,10 +65,7 @@ func (c *submitCommand) run(ctx context.Context) error { } defer conn.Close() - client, err := ipclient.New(conn) - if err != nil { - return err - } + client := ipclient.New(conn) var events []*ippb.Event scanner := bufio.NewScanner(os.Stdin) diff --git a/cmd/iprep/tail.go b/cmd/iprep/tail.go index 171f691aaf322206ee5599a43251684b9ae15989..df64f82c5605de55b26582550fa45e26daee2739 100644 --- a/cmd/iprep/tail.go +++ b/cmd/iprep/tail.go @@ -145,13 +145,10 @@ func (c *tailCommand) run(ctx context.Context) error { var sub submission.Submitter if !c.testOnly { - sub, err = submission.New(conn, &submission.Options{ + sub = submission.New(conn, &submission.Options{ MaxDelay: c.maxDelay, MaxStored: c.maxStored, }) - if err != nil { - return err - } defer sub.Close() } diff --git a/submission/queue.go b/submission/queue.go index 1b6385ae6428586361b7f6b781f4ee5d8c6ac4a8..bbc1f9ff3108f2d52480ebb6b3f08f1ba746fd71 100644 --- a/submission/queue.go +++ b/submission/queue.go @@ -74,13 +74,9 @@ func newSubmitter(client client.Client, opts *Options) Submitter { } // New creates a new Submitter pointing at the specified collector addr. -func New(conn *grpc.ClientConn, opts *Options) (Submitter, error) { +func New(conn *grpc.ClientConn, opts *Options) Submitter { opts = opts.withDefaults() - c, err := client.New(conn) - if err != nil { - return nil, err - } - return newSubmitter(c, opts), nil + return newSubmitter(client.New(conn), opts) } func (q *submissionQueue) Close() {