ensoft / entrance / EnTrance.Feature.Gen

This module provides common functionality used for writing "client libraries" (typesafe Elm wrappers for the JSON message formats that interact with a particular server-side feature).

The functions here aren't for direct use by application code. Rather they're useful if you're implementing a new feature, and are writing a typesafe wrapper (akin to the EnTrance.Feature.* built-in examples).

Feature lifecycle

Configured features are started unconditionally on the server. Any other features must be requested by the client. These should be wrapped by your own function specifying the feature name and any other required parameters.

start : String -> EnTrance.Types.MaybeSubscribe -> EnTrance.Request.Request

Create a start_feature request. See eg CLI.start for an example usage.

This is an async request - it should unconditionally succeed unless there is an obvious programming error (eg a mis-spelled feature name) that will show up in the server logs.

stop : String -> EnTrance.Request.Request

Create a stop_feature request. See eg CLI.stop for an example usage.

This is an async request - it should unconditionally succeed unless there is an obvious programming error (eg a mis-spelled feature name) that will show up in the server logs.

Decoding common fields

The following functions decode common fields that aren't specific to your feature. These should be wrapped by your own functions that also decode any feature-specific fields.

decodeRpc : String -> Json.Decode.Decoder a -> Json.Decode.Decoder (EnTrance.Types.RpcData a)

Decode an RPC response of specified type, given a decoder for a success value. See eg CLI.decodeExec for an example usage.

decodeIsUp : String -> Json.Decode.Decoder Basics.Bool

Decode a notification requested using MaybeSubscribe for a given feature. See eg CLI.decodeIsUp for an example usage.

decodeNfn : String -> Json.Decode.Decoder a -> Json.Decode.Decoder a

Decode an arbitrary notification, given an expected nfn_type value and a decoder for the payload. See eg Syslog.decode for an example usage.