siilisolutions / hedge

a serverless solution for clojure
Eclipse Public License 1.0
39 stars 6 forks source link

Feature request : Function Inputs #83

Open erkkikeranen opened 6 years ago

erkkikeranen commented 6 years ago

As a developer, I want similair abstraction as Azure Function Inputs.

Which means that the function runtime feeds my inputs with data (read table or row from db, get file from s3/blob, ...) when my function is invoked by some trigger (http, timer, queue, event...).

db in this case would be AWS DynamoDB table or Azure Table Storage table or Azure CosmosDB Collection.

I need n inputs, which are available as a map in my handler.

hedge.edn:

{:api {:handler name
          :authorization :anonymous
          :inputs [{:key "table1"
                         :table "table1-name"
                         :partitionkey {:key-name "PartitionKey" :value-to-fetch "0001"} 
                         :id {:key-name "Rowkey" :value-to-fetch "x"} 
                         :connection "connection-string"}]}}

handler receives an optional inputs map:

(defn handler [req & {:keys [inputs]}]
    (info "table contents: " (-> inputs :table1))))

User can omit :partitionkey and :id to fetch the whole table.

partitionkey is PartitionKey in table storage so key-name has no meaning in that context. id is Rowkey in table storage, key-name has no meaning in that context. (sortkey in AWS dynamodb, id in Azure cosmosdb) connection-string is the authentication & authorization string to Azure db connection.

AWS implementation is a little bit different, because the lambda runtime does not provide "inputs" by default so this abstraction must be created. During the entry to the handler, lambda must fetch defined data.

Developers responsibility is to request tables of reasonable size currently.

Future ideas: