littlehorse-enterprises / littlehorse

This repository contains the code for the LittleHorse Server, Dashboard, CLI, and Java/Go/Python SDK's. Brought to you by LittleHorse Enterprises LLC
https://littlehorse.dev/
Other
95 stars 9 forks source link

Fetch Multiple Variables in One Call #622

Open coltmcnealy-lh opened 7 months ago

coltmcnealy-lh commented 7 months ago

A feature request has come in from the community regarding fetching the value of Variables from a WfRun. Currently, the rpc GetVariable accepts a single variable name and returns a single Variable.

A feature request has come in from the community asking for the ability to fetch multiple Variable's in a single request. This is highly useful for applications using LittleHorse as a data store for business entities; for example, many GET requests need to do the equivalent of selecting a full row in a database.

This ticket needs some discussion. There are many ways we could do it, I've listed them below.

Options

Pre-Set Loadable Variables in WfSpec

In this scenario, we would have something like:

rpc GetPublicVariables(WfRunId) returns (VariableList) {}

We would add a field to the ThreadVarDef in the WfSpec which determines whether a Variable is to be returned in the "GetVariables" response.

This relates somewhat to #582

Client Specifies Variables to Fetch

In this scenario, the request would specify a list of Variable names to fetch. THe proto here would be more complicated, and requires some discussion.

Fluent Query Builder

A long-shot feature would be to add some sort of fluent query API to the SDK's which allow something like:

Map<String, VariableValue> vars = new LHQuery(client).wfRun("some-wfrun-id").variables("var-1", "var-2", "var-3").get();
coltmcnealy-lh commented 7 months ago

@eduwercamacaro this ticket seems simple at first but in reality I think it is the start of a long-term effort to build a wrapper over our raw GRPC API in order to improve usability. As such, we should be very careful about throwing a quick solution at it.

coltmcnealy-lh commented 7 months ago

Update: we will leave this ticket in the "backlog" for now. That is because we already have rpc ListVariables which fetches every variable in the WfRun. That should solve 80% of the use-cases.