portkey

Portkey: from REPL to Serverless in one call
2018-05-15T10:10:29.000038Z

cgrand 2018-05-15T10:28:41.000081Z

(defmethod shape-to-spec “list” [ns [name {{:strs [shape]} “member” :strs [max]}]]
  `(spec/and
     (spec/coll-of ~(keyword ns (aws/dashed shape)) :max-count ~max)
     (spec/conformer identity #(if (sequential? %) % [%])))) ; HAL ❤

cgrand 2018-05-15T10:30:05.000332Z

this conformer is a case of protocol leak

cgrand 2018-05-15T10:31:08.000011Z

HAL allows to replace single-item lists by just the item

cgrand 2018-05-15T10:31:40.000222Z

of course you see that it’s in the “unform” direction

cgrand 2018-05-15T10:32:16.000219Z

conform is from edn to payload and unform from payload to edn

cgrand 2018-05-15T11:35:30.000023Z

I’d like to get rid of all conforms because I want specs to work first as a clean documentation.

cgrand 2018-05-15T11:36:01.000393Z

I don’t want to muddy this with protocol details

cgrand 2018-05-15T12:01:10.000144Z

so in gen-api I make provision for some vars (prefixed by ser- deser- req- and resp- followed by a spec name), they are expectd to be populated by functions doing transformations.

viesti 2018-05-15T14:37:03.000731Z

right

cgrand 2018-05-15T14:39:20.000051Z

obviously these fns would be protocol-dependent

viesti 2018-05-15T14:59:53.000980Z

so for example for rest-xml, xml would be serialed/deserialized with these fns

cgrand 2018-05-15T15:15:09.000215Z

maybe not entirely

cgrand 2018-05-15T15:16:31.000124Z

the core fn would be rest-xml-call, it could do the generic xml lifting

cgrand 2018-05-15T15:18:27.000452Z

req- resp- could work from the request/respoinse maps with parsed bodies

cgrand 2018-05-15T15:18:52.000419Z

and ser- deser- do the local transformations

cgrand 2018-05-15T15:19:36.000918Z

example of local transformation: turning a <list> tag into an actual list

viesti 2018-05-15T16:12:31.000308Z

ah, true

viesti 2018-05-15T16:17:15.000567Z

so while making a call, the data that is fed to say ser-create-function-request would be checked against a spec?

cgrand 2018-05-15T16:20:29.000001Z

Yes 1/ call conform or valid 2/ call req<-create-function-request -- it indirectly calls some ser-stuff to performs coercion and small fixes 3/ serialize the body of the request in the *-call fn

viesti 2018-05-15T16:36:05.000869Z

thinking about pagination

viesti 2018-05-15T16:51:53.000225Z

at least one can grab token from response and use it for next request

baptiste-from-paris 2018-05-15T19:23:41.000294Z

hey, @cgrand I am going to look at your wip next monday

baptiste-from-paris 2018-05-15T19:25:08.000049Z

did not have the time last few days

viesti 2018-05-15T19:39:59.000463Z

hmm master...

viesti 2018-05-15T19:41:53.000382Z

I think I've formed some obstacles in form of merge conflicts if thinking of rebasing the wip

cgrand 2018-05-16T11:00:08.000569Z

You are too impatient Grasshopper