Comments (5)
@elias-ebrahimpour Hello π
Perhaps, the best way to illustrate our approach is within our Styleguide Example - https://github.com/HackSoftware/Django-Styleguide-Example/blob/master/styleguide_example/integrations/aws/client.py
We tend to write "clients" for everything that goes outside the system, and then, interact with those clients in the service layer and/or task layer, whenever is necessary.
Yet, the most important thing for those clients is to define an interface for interaction with something outside of our current & existing system.
Let me know if this answers your questions and you need me to put few more sentences together.
Cheers!
from django-styleguide.
@devmitrandir This is how I think about it:
- Whatever happens for the
blog
app should be position in theblog
app. - Now, if the communication with an external service requires some form of "ritual", you can create a client in the respective
integrations
app. - And just use this client / sdk in the code inside your
blog
app.
That's basically all there is.
The general idea for the integrations
app is to separate the code for communication with external services and expose a better-suited interface / API for the application.
Now, I'd argue if you only need to make one requests
call - you don't need that.
But usually, there are credentials & error handling in play and it's good to live outside your domain.
Again, this is a good example for me - https://github.com/HackSoftware/Django-Styleguide-Example/blob/master/styleguide_example/integrations/aws/client.py
@elias-ebrahimpour this may also be helpful for you too.
from django-styleguide.
@RadoRado Thank you for your response and time.
I've gotten my answer but if you want to explain more about this issue, I'm all ears.
Cheers!
from django-styleguide.
@RadoRado Hi!
For example, I have 2 applications: integrations
and blog
.
I need to fetch data from a third party API once a day and save.
My models are in the blog
application.
In which application is it better to add logic?
I think I need to add the client in integrations
and use it in blog/services.py
. And call this service from a celery task (blog/tasks.py
).
from django-styleguide.
@RadoRado
Thank you very much!
from django-styleguide.
Related Issues (20)
- Socket Programming HOT 4
- Does the following image depict it correctly? HOT 2
- Error structuring according to RFC7807 HOT 4
- Issue with `InputSerializer` Classes and Schema Generation HOT 15
- UUIDs are bad primary keys HOT 2
- Examples with larger models HOT 5
- maybe link is errorοΌ HOT 1
- Add a couple of paragraphs about migrations
- Use ViewSet instead of APIView HOT 3
- Main problems with Openapi schema generation HOT 6
- Different endpoints for different permissions HOT 3
- Why not use APIException HOT 1
- Business logic and test factories HOT 2
- Why Overloaded POST over PUT/PATCH/DELETE? HOT 9
- People can't use labels HOT 5
- Service for bulk_create HOT 3
- Convince me about selectors? HOT 2
- One Api - One Service HOT 4
- Style guide beginner comments HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-styleguide.