Google Groups

Re: Composition question

Garrett Smith Jan 26, 2011 5:01 PM
Posted in group: erlangcamp
Do you need to handle external notifications/events that would require
you to use gen_fsm?

If this is just going to run through file sequentially, it seems all
you need is a function.

Scheduling calls to that function is another matter. This could be as
simple as cron (or some other system process) calling an escript with
a call to you function. If scheduling is more complex (e.g. parallel
jobs, etc.) you'd need some OTP goodness, but I don't think it'd
involve gen_fsm or gen_event.

How will these jobs be scheduled/triggered?

On Wed, Jan 26, 2011 at 4:41 PM, Bryan Hunter
<> wrote:
> I'm working on my first "going to be used by a customer" Erlang app
> (Hurray!), and I've got a composition/pattern question.
> 1) The app needs to read blocks of data from large text files, strip out any
> line-endings, break the blocks into raw (fixed-width) records.
> 2) Based on a record type code in the first byte each record needs to be
> parsed, validated, aggregated and transformed.
> My plan is to write a gen_fsm-based module to step through and process each
> record (parse, validate, aggregate, transform).
> My question is what's a smart, clean way to hook my reader (stream of
> records) into my processor (the FSM)? Should the FSM know about (and create)
> my reader module and then pull from it record-at-a-time on each state
> transition? Should my reader module push/drive the FSM? Should they be tied
> together less directly via gen_event in some way?
> Anyone have other advice on this type of task?
> Thanks,
> Bryan Hunter
> Twitter: @bryan_hunter