This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-13
Channels
- # 100-days-of-code (5)
- # adventofcode (1)
- # announcements (8)
- # beginners (148)
- # boot (17)
- # calva (26)
- # cider (17)
- # cljdoc (2)
- # cljs-dev (55)
- # cljsjs (2)
- # clojure (198)
- # clojure-dev (11)
- # clojure-finland (1)
- # clojure-italy (23)
- # clojure-nl (6)
- # clojure-spec (44)
- # clojure-uk (148)
- # clojurescript (27)
- # clojutre (20)
- # core-logic (21)
- # cursive (12)
- # datascript (10)
- # datomic (33)
- # emacs (11)
- # figwheel-main (49)
- # fulcro (19)
- # graphql (2)
- # off-topic (48)
- # onyx (2)
- # other-languages (53)
- # pedestal (3)
- # reagent (75)
- # reitit (17)
- # rum (1)
- # slack-help (2)
- # specter (2)
- # sql (3)
- # tools-deps (24)
- # unrepl (4)
- # yada (1)
I’m working on a spec for an asynchronous message format and am curious about versioning. My instinct is to declare a versioned namespace for the message envelope - e.g. :my.message.v1/schema
, declare all my envelope fields in that same namespace, and then just make a new one if and when I realize the need to make an incompatible change to the envelope. It occurred to my colleague that multi-spec was another way to accomplish this by including the version as a value, e.g. :my.message.schema/version 1
and using multi-spec to choose the correct spec.
Are both of these viable options and is there anything to recommend one over the other?
I’d recommend not making incompatible changes
if the attribute needs to change, give the attribute a new name
if you’re talking about adding attributes, that’s compatible. if you need to remove attributes from a map, then you should have a new name for the container, which I guess version is one kind of new name
Alas, my foresight is sufficiently imperfect that I don’t believe I can develop the correct message format for all time. Incompatible changes I believe might be reasonably desired include (and are probably limited to?): adding and removed required keys.
well, I’ll refer you to Rich’s Spec-ulation keynote for the long form argument
what is an example of adding keys that is a breaking change @donaldball?
but yeah I think the gist is "don't make breaking changes" which I generally take to mean "if you need to break something, make a new something, and leave the old something alone"
if you need to add a new required key to some map, it's no longer the same thing. Make a new map spec with a different name that requires the new key
if it's for a message on something like Kafka, the new name might be an entirely new Topic
I agree that’s very much the route spec wants you to go down and I’m on board the train, but I am curious what makes the multi-spec idea a poor solution. It seems like it does constrain you forever to having a message be a map, and for the map to require the multi-spec keyword, but otherwise the map contents could vary as required by the versions.
how do I put a bound on how many times clojure.spec.test.alpha/check generates a test?
>The opts map includes the following optional keys, where stc aliases clojure.spec.test.check >The ::stc/opts include :num-tests in addition to the keys documented by test.check.
it confused me at first too b/c test.check/quick-check takes the number of tests as its first argument
this works for me:
(defn foo [x] (str x))
(s/fdef foo :args (s/cat :x any?) :ret string?)
(st/check `foo {:clojure.spec.test.check/opts {:num-tests 1}})
(st/check `foo {:clojure.spec.test.check/opts {:num-tests 100}})
I think some of my specs must be really expensive. is there a way for me to selectively narrow some of the child specs?
Expensive to check or to gen?
I apologize, it's quite long. but I'm not confident what might be what's causing the slowness
I'm going through and removing everything and slowly adding back in. adding back in
:torch.field/key
:torch.field/name
seems to slow it down, but not astronomicallyI meant what operation are you invoking when it’s slow?
Sounds like gen
If you have coll-of, it’s good to set :gen-max to something small like 3
The default is 20 and that can get a little out of hand