KovalevDima / ClickHaskell

https://kovalevdima.github.io/ClickHaskell/
5 stars 2 forks source link

Redesign plan to achieve library API stability #8

Closed KovalevDima closed 4 months ago

KovalevDima commented 5 months ago

The problems description

Right now we have an awkward library API for the ClickHouse HTTP Interface Which brings us to the next problems:

  1. We should write heavy hardcoded extensions of general interpretClient function for every ClickHouse HTTP interface usage patterns. And then use function interpretClient by specifying the extension.
  2. Every extension of interpretClient function repeats injections of ClickHouse HTTP interface parts

ClickHouse HTTP interface usage patterns

Reading

Every reading process has the following general steps:

  1. Client sends request with statement and auth data to a DBMS server
  2. DBMS server handles statement and responses with the formatted data or an error message in http-body
  3. Client handles result of database response

    
    flowchart LR
        http-client
    
        subgraph request
            http-request[[http-request
                <hr>headers: user, password, database,... 
                        body: statement
                        ]]
        end
    
        dbms-server --> isSuccess
        isSuccess --> |yes| success-http-response
        isSuccess --> |no| error-http-response
        error-http-response --> http-client
        success-http-response --> http-client
    
        http-client --> http-request
        dbms-server
        subgraph response
            isSuccess{is success}
            success-http-response[[http-response <hr> body: formatted data]]
            error-http-response[[http-response <hr> body: error message]]
        end
        http-request --> dbms-server

### Writing

```mermaid

flowchart LR

      http-client

      subgraph request
        http-request[[http-request
        <hr>headers: user, password, database,... 
                body: statement+formatted data]]
      end
      dbms-server --> isSuccess
      isSuccess --> |yes| success-http-response
      isSuccess --> |no| error-http-response
      error-http-response --> http-client
      success-http-response --> http-client
      http-request --> dbms-server

      dbms-server
      subgraph response
        isSuccess{is success}
        success-http-response[[http-response <hr> body: empty]]
        error-http-response[[http-response <hr> body: error message]]
      end
      http-client --> http-request

Solutions

  1. We should provide a single function per usage case of HTTP interface which is independent from chosen Haskell HTTP client implementation.
  2. Provide functions for injecting HTTP interface usage cases into chosen Request and Response types
KovalevDima commented 4 months ago

Closed by #11