Skip to content

Instantly share code, notes, and snippets.

@rebo
Created November 7, 2012 22:46
Show Gist options
  • Save rebo/4035073 to your computer and use it in GitHub Desktop.
Save rebo/4035073 to your computer and use it in GitHub Desktop.
saga outline
class CreatePartyAccountOrderSaga < Saga
attr_reader :saga_info
def initialize(saga_id, party_attributes, account_attributes, order_attributes)
@saga_id = saga_id;
start(party_attributes, account_attributes, order_attributes)
end
def start(party_attributes, account_attributes, order_attributes)
fiber_based_workflow do
party_id = saga_exec("Creating Party..."){CreateParty.execute(*party_attributes)}
raise CreatePartyFailedError, "Party Creation Failed" if timeout?
account_id = saga_exec("Creating Account..."){CreateAccount.execute(party_id, *account_attributes)}
raise CreateAccountFailedError, "Account Creation Failed"} if timeout?
order_id = saga_exec("Creating Order..."){CreateOrder.execute(account_id, *order_attribtues)}
raise CreateOrderFailedError, "Order Creation Failed"} if timeout?
saga_success(order_id)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment