Step 5. Real-World Plugin Project #143
Replies: 11 comments 15 replies
-
Hi @choonho , |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Hello @choonho when i am running the minikube cluster after sometime my whole laptop is freezes and hang and nothing is working untill i restart my computer .I have tried multiple solution like increasing minikube memory size and and cpus and i have solove increase the docker resource limit but nothing is working . Can you please suggest some solution |
Beta Was this translation helpful? Give feedback.
-
@choonho I have submitted the task in pdf file. Could you please check! |
Beta Was this translation helpful? Give feedback.
-
@choonho I have uploaded the PDF of task-5. Please Review . |
Beta Was this translation helpful? Give feedback.
-
Best Submission |
Beta Was this translation helpful? Give feedback.
-
Nice work @arup1221 |
Beta Was this translation helpful? Give feedback.
-
@choonho uploaded the last assignment . |
Beta Was this translation helpful? Give feedback.
-
@py-dev-nandini-12 Hi, you did very well. Congratulate finishing all tasks. |
Beta Was this translation helpful? Give feedback.
-
I have completed all the tasks thanks to @choonho sir for 1:1 mentorship. |
Beta Was this translation helpful? Give feedback.
-
Code Analysis of plugin-http-file-cost-datasource
Understanding API call flow
Clone Cost Analysis Micro Service
To analysis cost-analysis service, clone source code with specific branch
Understand Backend Framework
Cloudforet core team developed Python-based gRPC framework like django or Java Spring framework.
gRPC client is either Web browser(console-api micro service) or spacectl CLI tool.
Understanding API call by example
Let's debug API call flow based on register API.
The command spacectl exec register cost_analysis.DataSource -f will request
Interface layer
Each Resource has its own source file like data_source.py for DataSource resource.
File path: src/spaceone/cost_analysis/interface/grpc/v1/data_source.py
When client requests register API call, the entry point is def register( ) function.
The received gRPC message structure from the client is automatically changed to python dictionary data structure by framework.
params contains the real data from client, metadata contains extra data such as api token, transaction_id and client information like HTTP header data.
The main functionality of interface layer is receiving request, then transfer to proper service layer. And respond the result to client.
We provide factory pattern for triggering service or manager by self.locator. If you want to trigger the DataSourceService, just call like self.locator.get_service(SERVICE_NAME, metadata)
Service layer
Service layer is a main function of API body. So service layer contains a business logic of API function.
Framework provides automatic pre-condition and post-condition check by handlers. The technology is python decorator, a.k.a. @
There are two different decorators like
when a service is triggered, class decorator is executed automatically.
For example, when the DataSource service is triggered, following handlers are automatically executed,
File path: src/spaceone/cost_analysis/service/data_source_service.py
After passing all these class handlers, there is additional pre-condition check, before entering the method
check_required checks the parameter must contains these fields. In this example, register function required at least name, data_source_type, and domain_id.
transaction appends more metadata, such as execution scope. scope is a barrier of data range. There is DOMAIN or PROJECT.
For example, the business logic of register DataSource in cost_analysis are
Each sub logic is implemented at Manager layer. If you want to check plugin, call repository service via RepositoryManager.
Calling Manager layer is also implemented by factory pattern by self.locator
For checking plugin exist or not, call RepositoryManager, then check plugin_id exist or not.
Manager layer
Manager layer is an implementation layer for unit function. There are three main functions for manager layer.
DB manipulation is create, update, delete or list of Database entity. This is abstracted by Model class similar with sqlalchemy. Currently we support only mongodb model.
For example, registering new data source in a database is calling the create function of model.
File path: src/spaceone/cost_analysis/manager/data_source_manager.py
Interact with other micro services is one of key technologies for MSA(Micro Service Architecture). For interact with other micro services, it needs
In the Cloudforet framework, we provide SpaceConnector coding pattern for easy communication between two micro services.
For example, to check plugin-http-cost-datasource plugin exist or not, cost-analysis have to request to repository service.
File path: src/spaceone/cost_analysis/manager/repository_manager.py
In the line number 14, service discovery is easily by creating SpaceConnector with service name.
To call API of other micro service, the method pattern is connector.dispatch(RESOURCE.VERB, parameters)
Line number 17 calls get method of repository. Line number 20 calls get_versions method of repository.
Assignment
Beta Was this translation helpful? Give feedback.
All reactions