Fork me on GitHub
#onyx
<
2018-01-14
>
genRaiy17:01:23

hey guys … basic question here about REPL usage

genRaiy17:01:03

I’m working with one of the examples (session windows to be specific)

genRaiy17:01:26

and when I load the REPL I get a ZooKeeper error

genRaiy17:01:11

where is says the address is in use

genRaiy17:01:05

any ideas / tips on how I can run the examples in the REPL?

lucasbradstreet20:01:20

@raymcdermott it seems like everything has already been eval’d by the time you start evaluating things? It’s not that great for repl play since you need to eval things in turn.

genRaiy21:01:49

@lucasbradstreet er, yeah I just took the example and loaded it into the REPL … my point is only that it seems like ZK is started twice and I don’t get that

lucasbradstreet21:01:02

Ah, this is before you even eval anything?

lucasbradstreet21:01:12

(manually I mean)

genRaiy21:01:45

ah … it might be that cursive evals it when starting the REPL and than I load it … so it’s done twice

lucasbradstreet21:01:06

Right, that’s what I was thinking.

lucasbradstreet21:01:28

They’d be better off in tests I think.

lucasbradstreet21:01:39

But this way you can go through line by line and see what happens.

genRaiy21:01:24

yes, that’s what it was

genRaiy21:01:48

agreed yes although I guess your examples are made for lein run rather than the REPL

genRaiy21:01:56

I now get this message

genRaiy21:01:43

but I don’t get that from lein run

lucasbradstreet21:01:06

it might just be a timing thing, because it can’t tell whether the media driver was dead or had just been shut down recently.

genRaiy21:01:01

when I submit the job (plucked from the main fn) it all works

lucasbradstreet21:01:40

this is the session window example, right?

genRaiy21:01:08

I mean it all still works regardless of the aeron error / warning

lucasbradstreet21:01:40

it’s probably just not shutting things down afterwards, since the shutdowns are in the main entry point

lucasbradstreet21:01:00

but there are none in the repl eval sections

genRaiy21:01:07

i executed them manually … I can try again from the top

genRaiy21:01:47

yeah when I reload after doing the shutdown manually, no warnings

lucasbradstreet21:01:30

Cool, it’s just stale state then. If you can think of a better way to keep the repl bits while also cleaning up the state, I’m all ears

lucasbradstreet21:01:34

This is certainly non-ideal

lucasbradstreet21:01:12

Maybe I could add a (comment) wrapping things and some helpers to start up, and do the final shutdown. It’s really easy to get into a state where you have to reload the repl

lucasbradstreet21:01:21

That’s why I prefer tests for general dev

genRaiy21:01:06

sure I’m just trying to get my hands dirty for the first time with Onyx in anger tbh

genRaiy21:01:40

thanks @lucasbradstreet also for Onyx 🙂

genRaiy21:01:59

one other question while I’m here

genRaiy21:01:25

one of our goals is to dump data to mongodb at the end of each session window

genRaiy21:01:37

I guess that is done via the trigger fn?

lucasbradstreet21:01:20

you can do it with trigger/sync, or you can use trigger/emit to emit the window contents to a downstream task (which you could write a simple mongo output plugin for)

lucasbradstreet21:01:36

output plugins are pretty easy to write

genRaiy21:01:55

ah, that sounds cool …. are there some examples?

lucasbradstreet21:01:19

I’ve been meaning to fix up the onyx-plugin template.

genRaiy21:01:40

please let me give you work 😉

lucasbradstreet21:01:54

Ha, too much to do 😛

genRaiy21:01:15

I guess it’s a protocol?

genRaiy21:01:01

sweet, I think I can do one of those for mongodb using monger …

lucasbradstreet21:01:08

yea, shouldn’t be too hard.

genRaiy21:01:17

I might need to come back for the wiring

lucasbradstreet21:01:23

sure, any questions let me know.

genRaiy21:01:27

thanks man

genRaiy21:01:08

sorry to come back so soon 🙂

genRaiy21:01:27

looking in more detail at the sql plugin, it’s all about outputting segments

genRaiy21:01:46

but I want to transform the data into a pre-defined JSON doc format

genRaiy22:01:03

so it’s not a 1:1 case

genRaiy22:01:36

if I have 10 segments I only want to output 1 doc, summarising the data

lucasbradstreet22:01:15

1. transform the state in your trigger/emit function before you send it downstream

lucasbradstreet22:01:48

2. alternatively or additionally batch your outputs via the output plugin (this is mostly for perf optimisation, as you have no guarantees about which segments will batch together)

lucasbradstreet22:01:52

I’m guessing you want 1

genRaiy22:01:16

seem like 1 is the most appropriate in this case

genRaiy22:01:37

of course mongo is easier than sql

genRaiy22:01:43

as there is no schema

lucasbradstreet22:01:47

you just need to use the right aggregation for your window

lucasbradstreet22:01:04

You could either collect via something like conj and transform in trigger/emit, or you can build your document incrementally with your own aggregation

lucasbradstreet22:01:17

just beware that with sessions you will need to merge sessions together too

genRaiy22:01:36

I think conj + transform is simpler

genRaiy22:01:51

how do I merge the sessions?

lucasbradstreet22:01:43

The conj aggregation will do it for you. It’s just a function that the aggregation has to define

genRaiy22:01:39

oh sorry, I thought you meant I had extra work to do

genRaiy22:01:05

[ I could not see anything in the merge tests ]

lucasbradstreet22:01:07

Not unless you want to merge it as you go

lucasbradstreet22:01:18

With some different logic

genRaiy22:01:55

ah ok, I see … in that case you need to merge with the existing session state?

lucasbradstreet22:01:18

Yeah, when two sessions combine, it’ll merge the two states

genRaiy22:01:01

ok, so you can either conj or have some merge function that is executed when one or more segments are added

genRaiy22:01:03

in my case I think just using conj and then doing the transform at the session boundary is more straightforward

lucasbradstreet22:01:18

Agree, since it’s less work

genRaiy22:01:55

ok, I think I’ve got it … so I’ll leave you to enjoy Sunday 🙂

genRaiy22:01:04

also I have to sleep !

genRaiy22:01:21

and I can sleep soundly now