[ruote:2239] Is there any ruote-kit sample code

24 views
Skip to first unread message

hansen wang

unread,
May 6, 2010, 2:07:12 PM5/6/10
to ruote
hi,every

I'm a new user for ruote,and i have to Integrate Ruote,Ruote-
kit,Rails,I know there is a
Ruote-on-rails sample.But now I want to know how can i use Ruote-kit
in Ruote-on-rails.
eg:
I create a controller,model in the ruote-on-rails. but how to start
with Ruote-kit.
1.how to register a participant?
2.how to understand and use Ruote::StorageParticipant in the
rails app.
3.Is there somebody could give me a detail code sample.

thank you very much!!

--
you received this message because you are subscribed to the "ruote users" group.
to post : send email to openwfe...@googlegroups.com
to unsubscribe : send email to openwferu-use...@googlegroups.com
more options : http://groups.google.com/group/openwferu-users?hl=en

John Mettraux

unread,
May 6, 2010, 8:16:22 PM5/6/10
to openwfe...@googlegroups.com

On Thu, May 06, 2010 at 11:07:12AM -0700, hansen wang wrote:
>
> I'm a new user for ruote,and i have to Integrate Ruote,Ruote-
> kit,Rails,I know there is a
> Ruote-on-rails sample.But now I want to know how can i use Ruote-kit
> in Ruote-on-rails.

Hello,

Eric has been preparing a sample application, but it's still very early :

http://github.com/threetee/ruote-rails-test

> eg:
> I create a controller,model in the ruote-on-rails. but how to start
> with Ruote-kit.
> 1.how to register a participant?

It generally happens in config/initializers/ruote.rb

Here is a simple example :

---8<---
require 'ruote/couch'

RuoteKit.configure do |c|

c.run_worker = true unless $RAKE_TASK

uri = File.read(Rails.root.join('config', 'couch_url.txt')).strip
uri = URI.parse(uri)

c.set_storage(
Ruote::Couch::CouchStorage,
uri.host, uri.port,
'couch_prefix' => "roma_#{Rails.env}", 'couch_timeout' => 60)

c.register do
catchall Ruote::StorageParticipant
end
end
--->8---

This example show how the engine is configured and how a unique "catchall" participant is registered.

It uses ruote-couch as a storage, it's a bit "advanced", for a beginning, using the fs_storage is the best thing.

In another application, I have

---8<---
c.register do

participant(
'create_audit', Capua::Participants::CreateAudit)
participant(
'un_suspend_annual_augit', Capua::Participants::SuspendAnnualAudit)

catchall Ruote::StorageParticipant
end
--->8---

Where the participants are located under lib/capua/participants/

---8<---
module Capua
module Participants

# Creates an audit resource for a given project
#
class CreateAudit
include Ruote::LocalParticipant

def initialize (opts)
@opts = opts
end

def consume (workitem)
puts "hello #{workitem.fields['name']}, creating an audit..."
reply_to_engine(workitem)
end
end
end
end
--->8---

> 2.how to understand and use Ruote::StorageParticipant in the
> rails app.

The code of the storage participant is at :

http://github.com/jmettraux/ruote/blob/ruote2.1/lib/ruote/part/storage_participant.rb

The interesting methods are :

- all ()
- [] / fetch (fei)
- reply (workitem)
- size
- by_participant (name)
- by_field (field, value=nil)
- update (workitem)

You can grab the storage participant from your controller with :

---8<---
RuoteKit.storage_participant

# for example :
@workitems = RuoteKit.storage_participant.all
--->8---

The update methods saves back a workitem into the storage participant, the reply method removes it from the participant and gives it back to the engine so that the process instance resumes.

> 3.Is there somebody could give me a detail code sample.

I hope these "hints" are sufficient for now.

Your questions are welcome.


Best regards,

--
John Mettraux - http://jmettraux.wordpress.com

threetee

unread,
May 7, 2010, 7:59:15 AM5/7/10
to ruote
FYI, I changed the name of the sample app repository to ruote-rails-
example, so the new Github link is:

http://github.com/threetee/ruote-rails-example
>  http://github.com/jmettraux/ruote/blob/ruote2.1/lib/ruote/part/storag...
>
> The interesting methods are :
>
>   - all ()
>   - [] / fetch (fei)
>   - reply (workitem)
>   - size
>   - by_participant (name)
>   - by_field (field, value=nil)
>   - update (workitem)
>
> You can grab the storage participant from your controller with :
>
> ---8<---
>   RuoteKit.storage_participant
>
>   # for example :
>   @workitems = RuoteKit.storage_participant.all
> --->8---
>
> The update methods saves back a workitem into the storage participant, the reply method removes it from the participant and gives it back to the engine so that the process instance resumes.
>
> >     3.Is there somebody could give me a detail code sample.
>
> I hope these "hints" are sufficient for now.
>
> Your questions are welcome.
>
> Best regards,
>
> --
> John Mettraux -http://jmettraux.wordpress.com
Reply all
Reply to author
Forward
0 new messages