ThisaraWeerakoon opened a new pull request, #5:
URL: https://github.com/apache/synapse-go/pull/5

   # Extend File Inbound Endpoint with Local File and Secure Protocols
   
   ## Description
   
   This pull request extends the existing file inbound endpoint to support 
local file system operations alongside FTP, FTPS, and SFTP. It leverages the 
`c2fo/vfs` library for a unified and abstract file system interaction, 
enhancing flexibility and maintainability.
   
   ## Motivation
   
   Currently, the file inbound endpoint primarily focuses on remote file 
systems. This enhancement broadens its applicability to scenarios involving 
local file processing, simplifying integrations and reducing the need for 
separate handling of local and remote file sources. Using `c2fo/vfs` ensures a 
consistent API across different file system types, improving code readability 
and reducing platform-specific dependencies.
   
   ## Changes
   
   -   **Abstracted File System Interaction via a Defined Interface:**
       -      Introduced a dedicated interface to define the contract for file 
system operations, promoting loose coupling and enabling future flexibility.
       -      This abstraction layer separates the core logic from the specific 
file system implementation.
   -   **`c2fo/vfs` Implementation of the File System Interface:**
       -      Utilized the `c2fo/vfs` package to provide concrete 
implementations of the defined file system interface.
       -      This allows the endpoint to leverage `c2fo/vfs`'s robust and 
feature-rich file system abstractions.
   -   **Enhanced Local File System Support:**
       -      Implemented local file system operations using the `c2fo/vfs`'s 
os backend, adhering to the established interface.
       -   This refactoring improves consistency and maintainability compared 
to the previous direct implementation.
   -   **Expanded Remote File Protocol Support (FTP, FTPS, SFTP):**
       -      Integrated `c2fo/vfs`'s FTP, and SFTP backends as implementations 
of the defined file system interface.
       -      This unified approach simplifies code and facilitates future 
protocol additions or modifications.
   -   **Robust Error Handling:**
       -      Implemented specific error handling for file system operations, 
including permission and file not found errors, within the interface 
implementations.
       -   This ensures consistent error reporting across all supported file 
system types.
   -   **Future-Proof Design:**
       -      By relying on a defined interface, the underlying `c2fo/vfs` 
implementation can be replaced with an alternative file system library in the 
future without impacting the endpoint's core logic.
   
   ## Example Configuration
   -   **file**
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <inboundEndpoint xmlns="http://ws.apache.org/ns/synapse"; 
                    name="file" sequence="inboundSeq" 
                    onError="fault" 
                    protocol="file" 
                    suspend="false">
      <parameters>
         <parameter name="interval">5000</parameter>
         <parameter name="sequential">true</parameter> 
         <parameter name="coordination">true</parameter> 
         <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
         <parameter 
name="transport.vfs.MoveAfterProcess">file:///home/thisarar/user/test/out</parameter>
         <parameter 
name="transport.vfs.FileURI">file:///home/thisarar/user/test/in</parameter>
         <parameter 
name="transport.vfs.MoveAfterFailure">file:///home/thisarar/user/test/failed</parameter>
         <parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
         <parameter name="transport.vfs.ContentType">text/xml</parameter>
         <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
      </parameters>
   </inboundEndpoint>
   ```
   -   **ftp**
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <inboundEndpoint xmlns="http://ws.apache.org/ns/synapse"; 
                    name="file" sequence="inboundSeq" 
                    onError="fault" 
                    protocol="file" 
                    suspend="false">
      <parameters>
         <parameter name="interval">5000</parameter>
         <parameter name="sequential">true</parameter> 
         <parameter name="coordination">true</parameter> 
         <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
         <parameter 
name="transport.vfs.MoveAfterProcess">ftp://user:password@host:port/out</parameter>
         <parameter 
name="transport.vfs.FileURI">ftp://user:password@host:port/in</parameter>
         <parameter 
name="transport.vfs.MoveAfterFailure">ftp://user:password@host:port/failed</parameter>
         <parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
         <parameter name="transport.vfs.ContentType">text/xml</parameter>
         <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
      </parameters>
   </inboundEndpoint>
   ```
   -   **sftp**
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <inboundEndpoint xmlns="http://ws.apache.org/ns/synapse"; 
                    name="file" sequence="inboundSeq" 
                    onError="fault" 
                    protocol="file" 
                    suspend="false">
      <parameters>
         <parameter name="interval">5000</parameter>
         <parameter name="sequential">true</parameter> 
         <parameter name="coordination">true</parameter> 
         <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
         <parameter 
name="transport.vfs.MoveAfterProcess">sftp://user:password@host:port/out</parameter>
         <parameter 
name="transport.vfs.FileURI">sftp://user:password@host:port/in</parameter>
         <parameter 
name="transport.vfs.MoveAfterFailure">sftp://user:password@host:port/failed</parameter>
         <parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
         <parameter name="transport.vfs.ContentType">text/xml</parameter>
         <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
      </parameters>
   </inboundEndpoint>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@synapse.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@synapse.apache.org
For additional commands, e-mail: dev-h...@synapse.apache.org

Reply via email to