Skip to content

Commit

Permalink
Merge pull request #38 from aserto-dev/ds_from_conn
Browse files Browse the repository at this point in the history
create ds client from a connection
  • Loading branch information
florindragos authored Nov 20, 2024
2 parents b70f5c8 + 1ec27fc commit da2f6e8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ds/v3/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ func New(opts ...aserto.ConnectionOption) (*Client, error) {
}, nil
}

// New returns a new Directory using an existing connection.
func FromConnection(conn *grpc.ClientConn) (*Client, error) {
return &Client{
Reader: drs.NewReaderClient(conn),
Writer: dws.NewWriterClient(conn),
Importer: dis.NewImporterClient(conn),
Exporter: des.NewExporterClient(conn),
Model: dms.NewModelClient(conn),
conns: []*grpc.ClientConn{conn},
}, nil
}

// Close closes the underlying connections.
func (c *Client) Close() error {
var errs error
Expand Down

0 comments on commit da2f6e8

Please sign in to comment.