T
T
t800zippygod2021-12-09 04:44:08
Django
t800zippygod, 2021-12-09 04:44:08

How to integrate chat on node into django?

Hello everyone
The task is this: I want to integrate chat into a Django application, I'm aware of Django-channels. However, including for educational purposes, I am trying to tie chat to NodeJs, in addition, if successful, I will understand how to expand the system and not be limited to one language, use the most appropriate solutions for the task, and so on.
Now the idea is this, when initializing the janga, threads are created (although there is also a question, GIL is still there) or asynchronous workers that communicate with the node through a broker (RabbitMQ, for example) in an endless loop. The node is responsible for communicating with the client via sockets, calls the server for saving to the database, authentication, and so on.
I know about Celery, but she also uses the broker for her own needs, and again, I want to do without it for educational purposes.
Such questions:
1) Where is it correct to initialize a thread / coroutine in such a way that there is access to djanga models? In addition, I would like to have a sane architecture at the same time, ps I created a working thread in the wsgi.py file after the application was initialized, but this is not correct IMHO.
2) Is there any best-practice on this issue? What is the best way to separate the logic into different components.
Ideally, I would like to keep only synchronous work in Django, and take asynchronous work out of bounds.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question