Skip to content

Instantly share code, notes, and snippets.

@PharkMillups
Created June 30, 2010 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PharkMillups/458727 to your computer and use it in GitHub Desktop.
Save PharkMillups/458727 to your computer and use it in GitHub Desktop.
bradfordw # Hey guys, reading through the post-commit docs;
when it says to specify the mod/fun via {"mod": "foo", "fun": "beforeWrite"},
where is it loading foo.erl from? Or can I just pass it a fun() -> ... end encoded ?
drev1 # bradfordw: calling code:get_path(). from console will show you the directories on the erlang code path
for riak to be able to load a post commit hook it would have to be located within one of the code paths
bradfordw # ok, so it is the "default" (granted one hasn't changed anything) lib path
Well, or otherwise specified.
drev1 # there are many paths which Erlang looks to load modules from
for generated rel the lib folder would contain all the code paths
bradfordw # I gotcha, I'll check to see via bin/riak console what it's looking at. Thanks again for the help
* hemulen # yawns
hemulen # bradfordw: did you get your hook question answered?
bradfordw # I think the synapse has been created, yes.
hemulen # ah cool
hemulen # i saw your tweet and hopped in the channel
bradfordw # I "guessed" it was going to look at (for me) /usr/local/lib/erlang/lib
hemulen # nice to know someone beat me to it :)
bradfordw # haha I don't think I've ever had to wait very long for questions
And it's nothing pressing at the moment.
hemulen # it will look there and also in any OTP apps packaged w/riak
drev1 # bradfordw: also, fun() -> ... end type functions cannot be used
hemulen # anonymous functions suck for distribution insho
bradfordw: one thing you could do is package up your hook functions as a separate OTP app
and distribute it with riak rebar makes that pretty easy
bradfordw # I figured as much, it didn't make much sense, but based on some mailing list entry
I found via googling that's sort-of what it looked like someone was doing.
I like that idea.
Essentially, I'd like to just wrap my whole otp app up with it
hemulen # yup
bradfordw # Just so I can skip protobuffs and rest.
hemulen # a small tweak to reltool and you can package it up with the riak stuff
if that method of deployment fits your goals, that is
bradfordw # I'm likely going to be rolling more changes to my otp app than riak
So, in terms of operations, would that be a pain in my ass?
hemulen # could be, yeah
another option is to deploy your app on a separate erlang node with the same cookie as the riak cluster
drev1 # hemulen: any recommendations for deploying post commit hook code to a running riak cluster?
hemulen # you could join the erlang cluster without participating in the riak cluster and still
use all the erlang APIs. drev1: just get your code on the code path, preferably as a separate
OTP app and then set the bucket props as needed
hemulen # bradfordw: does the separate node idea make sense?
bradfordw # I like that. For now, sadly, this thing is on 1 linode. Then in about 4-5 weeks it's
getting split in two. Yea, I follow you on that. I like that idea when the resources come about, yes.
hemulen # you can also start up the node with -hidden which cuts down on the inter-node chatter, too
you could still go this route on a single machine, if you have the resources to run to erlang VMs.
splitting becomes less of an issue this way, too
bradfordw # I'll start barking about that in the coming weeks. I really like the idea of
jumping in w/o participation
hemulen # cool
bradfordw # Every day the Erlang vm surprises me...I've only got 512Mb of RAM on this
demonstration machine. Plenty to run a few vm's
hemulen # yeah, its very lightweight
bradfordw # Haha, all the more reason I dropped mongo in favor of it.
hemulen # i've run it on embedded computers, with mnesia even, no problemo
bradfordw # Good to know....
hemulen # i'm off to bed, i think. midnight here....
bradfordw # right on, thanks for the brain candy my friend.
take care. drev1: thanks to you too!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment