Server-Side Implementation of Unary RPC
Write the service implementation of the deleteFile method.
In this lesson, we show the server-side implementation of the unary deleteFile
RPC. The server side is implemented in the ftp-service
module. Open the FTPService
class from the src/main/java/io/datajek/ftpservice/server
package. This class implements the FTP service defined in the proto file. In the FTPService
class defined in the Setting up a gRPC Service lesson, we have defined the deleteFile
method as follows:
@Overridepublic void deleteFile(MetaData request, StreamObserver<Result> responseObserver) {}
Flowchart of deleteFile
method
The deleteFile
method handles the deletion of a file from the server’s destination directory. It performs checks for the file’s existence and type, attempts the deletion, sends the appropriate response to the client, and logs relevant information during the delete process. The flow chart of the method is shown below.
deleteFile
method
On the server side, the deleteFile
method deletes a file in the server’s destination directory. If the file isn’t present, the status FILE_NOT_PRESENT
is sent to the client.
The method takes two parameters: request
of type MetaData
and responseObserver
of type ...