Fork me on GitHub
#datomic
<
2019-10-10
>
tslocke07:10:27

My local SOCKS connection is suddenly not connecting. None of the AWS setup changed. Any tips on how to troubleshoot? How would I confirm that the primary stack is running?

tslocke09:10:21

Never mind - figured it out

danieroux10:10:31

With Datomic analytics, does cardinality-many additional tables, work with column joins? In the example, in the product_x_tags table and tags was a ref, how can I get the the attributes of tags, instead of it’s eid?

jaret13:10:42

@danie what is your schema and what is your metaschema? I am not sure I entirely follow, are you trying to have another column join from a card many on the tags side?

Msr Tim13:10:05

Hi, In my app i need to "watch" for changes of particular type and react to it

Msr Tim13:10:27

but link 404's .

Msr Tim13:10:37

Is that kind of usecase still supported?

Alex Miller (Clojure team)13:10:05

seems like it's getting read in the preview above too

favila13:10:10

I think he means the javadoc link

favila13:10:29

It is supported, it’s an on-prem feature only though

favila13:10:15

I’m curious, are you actually writing java against datomic?

Msr Tim13:10:23

no its clojure.

Msr Tim13:10:06

maybe I am looking for wrong thing. eg use case: send an email to customer for every order placed.

Msr Tim13:10:37

I was hoping I could watch for new order creation tx and send email.

favila13:10:47

you can, it’s a perfectly fine way to do it

Msr Tim13:10:01

I am using cloud offering

favila13:10:08

oh, yeah nevermind

favila13:10:12

cloud doesn’t offer this

favila13:10:24

you will need to poll the tx-range repeatedly

favila13:10:54

unless there’s some ion way to do it?

cjsauer14:10:08

I’ve considered wrapping d/transact in a function that would simply put tx results onto a queue…“roll your own tx queue” so to speak. Obviously then other parts of the code would need to use this wrapped function. Never tried it, but it seems like it would be an option for cloud users.

Msr Tim14:10:14

@U6GFE9HS7 what does queue mean here results onto a queue

Msr Tim14:10:25

like some kafka type stuff?

cjsauer14:10:53

@UNWLRR74Y either a core.async queue/channel to keep it simple and in-process, or potentially a SQS queue if you need something more durable. Kafka is probably overkill.

Msr Tim14:10:18

gotcha thank you

cjsauer14:10:25

Ideally something async. You likely don’t want writers being blocked by the transaction queue.

Msr Tim13:10:59

ok. sounds like I'd have to have to poll tx manually and keep track of my position somewhere https://docs.datomic.com/cloud/time/log.html

Msr Tim13:10:17

do people write applications without 'tx functions' with datomic

Msr Tim13:10:30

my current thinking is that is not possible because when you transact data you have no way to know if they data moved underneath you since you read it. There is cas but thats only for a single attribute.

Msr Tim13:10:04

so by extension one cannot really use datomic cloud without ions

Msr Tim13:10:20

am i missing something here?

favila13:10:26

it depends on what you need. datomic transactions are really set operations, so they can compose. it’s only if you really need a specific computed write from a read that you reach for CAS or a transaction function

favila13:10:35

for example, lets say you have a cardinality-many string attr of document tags

favila13:10:16

when the user adds or removes a tag, do you a) read all the tags, remove the tag, and re-assert the entire set b) only add the tag?

favila13:10:15

sometimes you want A, in which case yes you need a tx function because you want the set’s final value to be exactly what you stated. (It’s a further question whether you want to fail and recompute if someone else wrote in the meantime, or if you want the last writer to win always)

favila13:10:43

but sometimes you want B, in which case it doesn’t matter what changes happened to the set in the meantime, the end result of adding your tag will be the same

Msr Tim14:10:31

gotcha. I was thinking of super typical ecommerce 101 buy a product flow.

1 . check invenotry  count x
2. create order record
3.  sen inventory count to x-1

favila14:10:28

Often you can split things up so the final unsafe atomic operation happens by itself

favila14:10:02

e.g. create order record but mark inactive, then activate+change inventory count using two CAS

Msr Tim14:10:07

what happens if activate goes through and change inventory fails

favila14:10:22

they’re in one tx, they succeed or fail together

Msr Tim14:10:49

oh two CAS in one tx. got it

favila14:10:27

you can also use CAS to assert no-change, e.g. [:db/cas ent attr 1 1] to ensure the value is still 1

favila14:10:51

I wish you could :db/cas to nil as an atomic retraction

favila14:10:51

all that said, do make and use tx functions! but maybe you only need a smaller set of primitive functions which do precondition checking or db/ensure for postcondition checking; instead of a function for every single business operation

Msr Tim14:10:12

My team doesn't seem too comfortable with adopting both datomic and ions in one go. So I was researching if its even possible to write apps without tx functions.

👍 4
kenny16:10:14

Anyone have a library for turning a full map into a Datomic transaction, including retractions and additions from the current entity in the DB?

Brian17:10:04

@kenny I recently just rolled my own. A bit of a pain but I couldn't find a clean solution although perhaps I missed one

Brian17:10:08

Can anyone point me in the right direction for how to give my Datomic Cloud s3 access to a bucket I've created? I'm getting this error when trying to fetch an object from my bucket which makes me think it has to do with permissions {:Error {:Code \"AccessDenied\", :CodeAttrs {}, :Message \"Access Denied\", :MessageAttrs {}, :RequestId \"<reqId>\", :RequestIdAttrs {}, :HostId \"<hostId>\", :HostIdAttrs {}}, :ErrorAttrs {}, :cognitect.anomalies/category :cognitect.anomalies/forbidden}

kenny17:10:33

I figured I’d end up needing to write it myself. Kinda surprised a lib out there doesn’t have a fn for it already. I also searched and couldn’t find one.

ghadi17:10:17

@kenny @brian.rogers that use-case is inherently racey unless done within a tx function

ghadi17:10:04

@brian.rogers permission for Ions?

kenny17:10:34

That’s fine. Seems like a general function for doing that is possible.

ghadi17:10:34

if you make it a generic helper then someone uses in a situation where the assumption of a race isn't understood, it wouldn't be fun

kenny17:10:13

Read the docs 😉

Brian17:10:17

@ghadi I think this is exactly what I was looking for thank you!

kenny17:10:47

The idea of a “full-map” transaction seems like it could be extended to support automatic ordering of cardinality many attributes.

ghadi17:10:13

you can do whatever your heart desires in a tx-function

ghadi17:10:18

but if you don't account for the basis of the tx-data you generate being old, it will be a nasty transaction

kenny17:10:10

Sure. Just a lot of interesting things you can do with a full-map transaction. Curious if there’s a reason no one has written a library for this sort of thing. Seems super useful, unless I’m missing something.

favila17:10:39

I think there are better ones out there now @kenny but this was mine: https://gist.github.com/favila/8ce31de4b2cb04cf202687c6a8fa4c94

favila17:10:10

you are talking about “reset-attributes” (the second one)

favila17:10:56

there has been discussion about a “make it look like this” tx function off and on here, maybe the archives can help

kenny17:10:15

Yeah, going for exactly that.

ghadi17:10:24

you can also use cas if your schema is designed for it

kenny17:10:18

What does designed for it mean?

ghadi17:10:43

e.g. you have a version-like attr on entities and you can say: update all this stuff as long as the cas succeeds

kenny17:10:15

This is probably app dependent. In some cases, if the data has changed, I want to tell the user something has changed so they can reevaluate their action.

kenny17:10:47

Perhaps that is what makes a general version of this function difficult — a bit too use case dependent.

ghadi17:10:41

might have to retry though

kenny17:10:54

Depends on the use case probably.

Brian18:10:51

@ghadi can I private message chat you about setting up these ion policies?

ghadi18:10:30

it's best to chat in here if possible -- there are more people

ghadi18:10:50

basically if you update your stack(s) with a reference to the policy you created, then the Datomic compute nodes (whether the primary or query groups) will have augmented capabilities

Brian18:10:31

Kk. Well I'm not quite sure where my code is falling down permissions wise. The docs list 4 things that I need to do: 1. use default credentials provider chain. I am making a client this way https://github.com/cognitect-labs/aws-api/blob/master/examples/s3_examples.clj#L12 and my understanding is that without specifying credentials, it is using the default ones. Am I right so far on that?

ghadi18:10:08

that's right, it will use the EC2 Instance Role's credentials

ghadi18:10:19

which is what that extra policy will augment

ghadi18:10:36

@brian.rogers DM me your policy if you want -- it's probably missing some sort of S3 permission if it's 403'ing

Brian18:10:31

OH MY GOD IT WORKED

Brian18:10:43

Thank you @ghadi for pointing me in the direction go ion permissions

ghadi18:10:57

my pleasure

Brian18:10:00

I didn't even realize that was my problem for the longest of times

kenny23:10:26

Does Datomic support "union" pull queries as described here? https://edn-query-language.org/eql/1.0.0/specification.html#_unions

favila23:10:45

no, but you can fake it by merging all the possibilities together into the same pull.

steveb8n00:10:03

I do this a merging a lot. the core apply-template fn is very useful for this kind of thing

kenny13:10:58

"the core apply-template fn"?

souenzzo13:10:28

@kenny i developed a custo ast->pull that i do (-> [{:my-thing {:thing/user [:user/id] :thing/group [:group/id]}}] eql/query->ast ast->pull) ;; => [{:my-thing [:user/id :group/id]}]