Week 3
Week 3
Check requirements with the supervisor
Modify the logic
Optimize the SQL logic
General email API on FaaS platform
Learn the basic concepts of FaaS platform in China Merchant Bank
Create a new function in FaaS service
Understand the API structure
Deploy a function to FaaS service
Log into database
Test the function
Connect API with trace platform
Learn the basic concepts of trace platform in China Merchant Bank
Integrate the API with trace platform
General Excel import and export API
Add a queue function to avoid overloading the API
Reconstruct the Excel import and export API
Tecnical points
1. What is FaaS?
FaaS is a cloud computing service that allows developers to upload their code and run it on the cloud without having to worry about managing or scaling the infrastructure. It is a serverless computing platform that allows developers to write and run code without worrying about the underlying infrastructure.
2. RestTemplate in Spring
RestTemplate is a Spring class that allows developers to make HTTP requests to RESTful web services. It provides a simple way to perform HTTP requests and handle responses.
- exchange() method: This method allows developers to make a request to a RESTful web service and return the response as a ResponseEntity object.
- getForObject() method: This method allows developers to make a GET request to a RESTful web service and return the response as an object of the specified type.
- postForObject() method: This method allows developers to make a POST request to a RESTful web service and return the response as an object of the specified type.
- getForEntity() method: This method allows developers to make a GET request to a RESTful web service and return the response as a ResponseEntity object.
- postForEntity() method: This method allows developers to make a POST request to a RESTful web service and return the response as a ResponseEntity object.
3. ObjectMapper
ObjectMapper is a class in the Jackson library that allows developers to convert Java objects to JSON and vice versa. It provides a simple way to serialize and deserialize Java objects to and from JSON.
- objectMapper.readValue() method: This method allows developers to convert a JSON string to a Java object.
- objectMapper.writeValueAsString() method: This method allows developers to convert a Java object to a JSON string.
4. HttpServletRequest
HttpServletRequest is a class in the Spring framework that represents an HTTP request. It provides a way to get information about the request, such as the request method, headers, and parameters.
- httpServletRequest.getMethod() method: This method allows developers to get the HTTP method of the request.
- httpServletRequest.getHeader() method: This method allows developers to get a header of the request.
- httpServletRequest.getParameter() method: This method allows developers to get a parameter of the request.
- httpServletRequest.getInputStream() method: This method allows developers to get the input stream of the HTTP request. It allows developers to read the request body as a byte array.
5. System.getenv() method
System.getenv() method is a method in the Java API that allows developers to get environment variables. It returns a map of environment variables and their values.
6. Queue
A queue is a data structure that stores a collection of elements. It is used to store and retrieve elements in a first-in-first-out (FIFO) order. In Java, the Queue interface is used to represent a queue.
- queue.offer() method: This method allows developers to add an element to the queue.
- queue.poll() method: This method allows developers to remove and return the head of the queue.
- queue.peek() method: This method allows developers to return the head of the queue without removing it.
- queue.size() method: This method allows developers to get the size of the queue.
7. CompletableFuture
CompletableFuture is a class in the Java API that represents a future value. It allows developers to handle asynchronous operations in a non-blocking way.
- CompletableFuture.supplyAsync() method: This method allows developers to run a task asynchronously and return a CompletableFuture object.
- CompletableFuture.exceptionally() method: This method allows developers to handle an exception that occurs in a CompletableFuture object.
- CompletableFuture.join() method: This method allows developers to get the result of a CompletableFuture object.
- CompletableFuture.allOf() method: This method allows developers to wait for all the CompletableFuture objects to complete.
- CompletableFuture.anyOf() method: This method allows developers to wait for any of the CompletableFuture objects to complete.
Async callbacks can be added to a CompletableFuture object using the following methods:
- CompletableFuture.thenRun() method: This method allows developers to run a runnable after the result of a CompletableFuture object is available, but does not return a value.
- CompletableFuture.thenAccept() method: This method allows developers to accept a consumer to the result of a CompletableFuture object, can accept a parameter, but does not return a value.
- CompletableFuture.thenApply() method: This method allows developers to apply a function to the result of a CompletableFuture object, can accept a parameter, and return a new CompletableFuture object.
- CompletableFuture.whenComplete() method: This method allows developers to accept a BiConsumer to the result of a CompletableFuture object and the exception that occurred, but does not return a value.
- CompletableFuture.handle() method: This method allows developers to handle the result of a CompletableFuture object and the exception that occurred, and return a value.