ensoft / entrance / EnTrance.Feature.Target.Connection

Connection management.

Connection details


type alias Params =
{ host : String
, username : String
, secret : String
, authType : AuthType
, sshPort : String
, netconfPort : String 
}

Everything needed to connect to a protocol peer.

If you aren't going to use eg Netconf, then it doesn't matter what value is provided for netconfPort.


type AuthType
    = Password
    | SshKey

Whether the secret part of Params should be interpreted as a password, or a pathname for a file on the EnTrance server containing an ssh key.

Connection state


type State
    = Disconnected
    | Connected
    | FailureWhileDisconnecting String
    | Finalizing
    | Connecting
    | Disconnecting
    | ReconnectingAfterFailure String
    | FailedToConnect String

Abstracted description of the state of protocol connection. Later constructors are considered "worse" than earlier (eg FailedToConnect is worse than Connected) when multiple connection states are aggregated via target groups.

The states involving failure include a String giving more details.


type alias GroupState =
{ groupState : State
, childName : String
, childState : State
, timestamp : String 
}

An aggregate state notification received for a target, or target group. You receive one of these when you used SubscribeToConState when starting a target or target group, and one of the underlying connections just changed state.

Encoders and decoders

decodeState : Json.Decode.Decoder State

JSON decoder for connection state.

decodeGroupState : (GroupState -> msg) -> Json.Decode.Decoder msg

JSON decoder for GroupState. Takes a message constructor.

decodeParams : Json.Decode.Decoder Params

JSON decoder for connection params.

encodeParams : Params -> Json.Encode.Value

JSON encoder for Params. This can be handy for, eg, persisting connection settings.