From 0cbd6a48ae443fe3e35d7155548b80c6470b13d8 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Sat, 7 May 2022 21:23:42 -0700 Subject: [PATCH] Allow API client to be made from connection --- api/api.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/api.go b/api/api.go index 54b72d7..adb6a06 100644 --- a/api/api.go +++ b/api/api.go @@ -1,6 +1,7 @@ package api import ( + "io" "net" "go.arsenm.dev/lrpc/client" @@ -25,6 +26,12 @@ func New(sockPath string) (*Client, error) { return out, nil } +func NewFromConn(conn io.ReadWriteCloser) *Client { + return &Client{ + client: client.New(conn, codec.Default), + } +} + func (c *Client) Close() error { return c.client.Close() }