finished first version of documentation
This commit is contained in:
9
haskell/gen_docs.sh
Executable file
9
haskell/gen_docs.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
cabal haddock
|
||||
|
||||
|
||||
rm -rf ../Docs/haskell
|
||||
|
||||
cp -r ./dist-newstyle/build/x86_64-linux/ghc-9.6.5/p2prc-0.1.0.0/doc/html/p2prc/ ../Docs/haskell
|
||||
@@ -15,7 +15,7 @@ import Error
|
||||
)
|
||||
|
||||
import JSON
|
||||
( IPAdressTable(..)
|
||||
( IPAddressTable(..)
|
||||
, MapPortResponse(..)
|
||||
, P2prcConfig
|
||||
)
|
||||
@@ -33,12 +33,18 @@ import CLI
|
||||
import Environment ( cleanEnvironment )
|
||||
|
||||
|
||||
data P2PRCapi -- ^ Haskell API
|
||||
= MkP2PRCapi -- ^ Main Constructor
|
||||
{ startServer :: IOEitherError ProcessHandle -- ^ start server
|
||||
-- | Lower level P2PRC Haskell api that exposes basic functionality necessary to joint the network.
|
||||
|
||||
data P2PRCapi
|
||||
= MkP2PRCapi
|
||||
{ startServer :: IOEitherError ProcessHandle
|
||||
-- ^ Start server
|
||||
, execInitConfig :: IOEitherError P2prcConfig
|
||||
, execListServers :: IOEitherError IPAdressTable
|
||||
-- ^ Instantiate server configuration
|
||||
, execListServers :: IOEitherError IPAddressTable
|
||||
-- ^ List servers in network
|
||||
, execMapPort :: MapPortRequest -> IOEitherError MapPortResponse
|
||||
-- ^ Exposes and associates a local TCP port with a remote DNS address
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +58,9 @@ data MapPortRequest =
|
||||
{-|
|
||||
This function cleans the previous running state (ensuring a pure P2PRC runtime state) and builds up a conditional 'P2PRCapi' instance.
|
||||
|
||||
__The following example show how this function can be used to expose the runtime functionalities:__
|
||||
==== __Example__
|
||||
|
||||
The following example show how this function can be used to expose the runtime functionalities:
|
||||
|
||||
@
|
||||
example :: IOEitherError P2PRCapi
|
||||
|
||||
@@ -45,7 +45,9 @@ import API
|
||||
{-|
|
||||
This function starts and bootstraps the P2PRC runtime that associates the a specific host's machine port to a DNS address to expose a certain application to the P2PRC network. You will only need to also import the 'MkMapPortRequest' data constructor to represent the this port request.
|
||||
|
||||
__This example demonstrates how it can be ran on the IO context:__
|
||||
==== __Example__
|
||||
|
||||
This example demonstrates how it can be ran on the IO context:
|
||||
|
||||
@
|
||||
example :: IO ()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
module JSON
|
||||
( P2prcConfig(..)
|
||||
, IPAdressTable(..)
|
||||
, IPAddressTable(..)
|
||||
, IPAddress(..)
|
||||
, ServerInfo(..)
|
||||
, MapPortResponse(..)
|
||||
@@ -17,7 +17,7 @@ import qualified Data.Text as T
|
||||
import Data.Aeson
|
||||
|
||||
|
||||
-- {-# WARNING MapPortResponse "This newtype is unstable at the moment due to the P2PRC's library error handling bug. For more information visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114#issuecomment-2474737015" #-}
|
||||
{-# WARNING MapPortResponse "This newtype is unstable at the moment due to the P2PRC's library error handling bug. For more information visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114#issuecomment-2474737015" #-}
|
||||
|
||||
-- ^ This represents P2PRC's response to the TCP port and DNS address allocation. This value will confirm the successful allocation and return information about it.
|
||||
newtype MapPortResponse
|
||||
@@ -39,31 +39,34 @@ instance FromJSON MapPortResponse where
|
||||
|
||||
|
||||
{-# WARNING P2prcConfig "This type is unstable at the moment due to the P2PRC's library error handling bug. For more information visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114#issuecomment-2474737015" #-}
|
||||
newtype P2prcConfig -- ^ Host P2prc configuration
|
||||
= MkP2prConfig -- ^ Unique Constructor
|
||||
|
||||
-- | This represents the server configuration that defines its attributes and behaviours in the network, as well as, the location of the runtime persistence artifacts.
|
||||
newtype P2prcConfig
|
||||
= MkP2prConfig
|
||||
{ machineName :: String -- ^ Machine Name
|
||||
}
|
||||
deriving Show
|
||||
} deriving Show
|
||||
|
||||
-- , hostServerPort :: Int
|
||||
-- , iPV6Address :: Maybe String
|
||||
-- , proxyPort :: Maybe Int
|
||||
-- , fRPServerPort :: Bool
|
||||
-- , behindNAT :: Bool
|
||||
-- , iPTableKey :: String
|
||||
-- , bareMetal :: Bool
|
||||
-- , customConfig :: String
|
||||
--
|
||||
-- , iPTable :: String -- File
|
||||
-- , dockerContainers :: String -- Directory
|
||||
-- , defaultDockerFile :: String -- Directory
|
||||
-- , dockerRunLogs :: String -- Directory
|
||||
-- , speedTestFile :: String -- File
|
||||
-- , iPV6Address :: Maybe String
|
||||
-- , pluginPath :: String -- Directory
|
||||
-- , trackContainersPath :: String -- File
|
||||
-- , hostServerPort :: Int
|
||||
-- , proxyPort :: Maybe Int
|
||||
-- , groupTrackContainersPath :: File
|
||||
-- , fRPServerPort :: Bool
|
||||
-- , behindNAT :: Bool
|
||||
-- , iPTableKey :: String
|
||||
-- , publicKeyFile :: String -- File
|
||||
-- , privateKeyFile :: String -- File
|
||||
-- , pemFile :: String -- File
|
||||
-- , keyFile :: String -- File
|
||||
-- , bareMetal :: Bool
|
||||
-- , customConfig
|
||||
-- , groupTrackContainersPath :: String -- File
|
||||
|
||||
|
||||
-- TODO: p2prc API
|
||||
@@ -106,42 +109,44 @@ instance FromJSON P2prcConfig where
|
||||
parseJSON _ = mzero
|
||||
|
||||
|
||||
{-# WARNING IPAdressTable "This newtype is highly unstable due to undergoing work on improving P2PRC's server api. For more information, visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114" #-}
|
||||
{-# WARNING IPAddressTable "This newtype is highly unstable due to undergoing work on improving P2PRC's server api. For more information, visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114" #-}
|
||||
|
||||
|
||||
-- | IP Table
|
||||
newtype IPAdressTable
|
||||
= MkIPAdressTable -- ^ Constructor
|
||||
[ServerInfo] -- ^ List Servers
|
||||
-- | This is a wrapper value that parses a json key value from the list of ip addresses in the network.
|
||||
newtype IPAddressTable
|
||||
= MkIPAddressTable -- ^ Wrapping constructor
|
||||
[ServerInfo] -- ^ List current network servers
|
||||
deriving Show
|
||||
|
||||
|
||||
instance FromJSON IPAdressTable where
|
||||
instance FromJSON IPAddressTable where
|
||||
parseJSON = withObject "IPAdressTable" $
|
||||
\ v ->
|
||||
MkIPAdressTable <$> v .: "ip_address"
|
||||
MkIPAddressTable <$> v .: "ip_address"
|
||||
|
||||
|
||||
{-# WARNING ServerInfo "This type is highly unstable due to undergoing work on improving P2PRC's server api. For more information, visit: https://github.com/Akilan1999/p2p-rendering-computation/issues/114" #-}
|
||||
{- |
|
||||
This is a record that keeps track of the current state of every node in the network. It is crucial information required for orchestration strategies.
|
||||
-}
|
||||
data ServerInfo =
|
||||
MkServerInfo
|
||||
{ name :: T.Text
|
||||
, ip :: IPAddress
|
||||
, latency :: Int
|
||||
, download :: Int
|
||||
, upload :: Int
|
||||
, serverPort :: Int
|
||||
, bareMetalSSHPort :: Maybe Int
|
||||
, nat :: Bool
|
||||
, escapeImplementation :: Maybe T.Text
|
||||
, customInformation :: Maybe T.Text
|
||||
{ name :: T.Text -- ^ Machine name
|
||||
, ip :: IPAddress -- ^ Machine IP address
|
||||
, latency :: Int -- ^ Response latency
|
||||
, download :: Int -- ^ Download speed
|
||||
, upload :: Int -- ^ Upload speed
|
||||
, serverPort :: Int -- ^ Server port number
|
||||
, bareMetalSSHPort :: Maybe Int -- ^ SSH machine port number
|
||||
, nat :: Bool -- ^ Checking if node is behind a NAT
|
||||
, escapeImplementation :: Maybe T.Text -- ^ Type of NAT trasversal technique
|
||||
, customInformation :: Maybe T.Text -- ^ Custom String information
|
||||
}
|
||||
deriving Show
|
||||
|
||||
|
||||
-- | This is a simple representation of the IP address of nodes in the network.
|
||||
data IPAddress
|
||||
= MkIPv4 String
|
||||
| MkIPv6 String
|
||||
= MkIPv4 String -- ^ IP version 4 address
|
||||
| MkIPv6 String -- ^ IP version 6 address
|
||||
deriving Show
|
||||
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ module P2PRC
|
||||
-- | This section gives an overview on the runtime and host machine interfaces.
|
||||
, P2PRCapi(..)
|
||||
, P2prcConfig(..)
|
||||
, MapPortRequest(..)
|
||||
, MapPortResponse(..)
|
||||
|
||||
-- ** Primitive data types
|
||||
-- | These types represent the core data that is communicated between requests and the runtime.
|
||||
, IPAdressTable(..)
|
||||
, IPAddressTable(..)
|
||||
, ServerInfo(..)
|
||||
, IPAddress(..)
|
||||
, MapPortRequest(..)
|
||||
, MapPortResponse(..)
|
||||
, Error(..)
|
||||
|
||||
-- ** Type Synonyms
|
||||
@@ -72,7 +72,7 @@ import Engine
|
||||
)
|
||||
|
||||
import JSON
|
||||
( IPAdressTable(..)
|
||||
( IPAddressTable(..)
|
||||
, ServerInfo(..)
|
||||
, IPAddress(..)
|
||||
, MapPortResponse(..)
|
||||
|
||||
Reference in New Issue
Block a user