Sharing model definitions between Erlang and Rails (and mongodb)

I have a rails application using mongodb through mongomapper and all is well. The problem is ... I want to use erlang to do some background processing, and I want to update the same mongo / mongomapper models with the results of this processing. What is the best way to share model definitions between two applications (rails and erlang) and stay sane? It seems like it would be problematic to try to manage them separately if they both access the same records. If there is no “good” way, am I just getting it wrong?

Additional Information: I initially did background processing using screening / work clients. This is nice, since I can use all the same models and rails code. Performance was terrible, although I look at erlang to solve some performance issues. This is a large amount of processed data, but it can be easily processed in parallel.

I try to avoid using erlang as the only intermediary between mongodb and rails through a leisure or thrift interface.

Edit: I wanted to light up a little more light. Erlang handling will need to learn a little about the models in advance. I mainly use erlang to retrieve data from other places and fill in the details of model objects. So, for example, there may be a description field that I extract from the xml file using xmerl_xpath: string ("// description / text ()"). I need to be able to add methods that will act in the fields of the model.

+3
source share
1 answer

MongoDB has two community-supported Erlang drivers (erlmongo and emongo). Accessing your mongodb through these drivers will give you your own Erlang objects.

Ruby → MongoMapper → Mongo ruby ​​driver → MongoDB → (emongo | erlmongo) → Erlang

+1

Source: https://habr.com/ru/post/1730994/


All Articles