diff --git a/apps/emqx_gateway/README.md b/apps/emqx_gateway/README.md index 0f95f286a..f8b825eeb 100644 --- a/apps/emqx_gateway/README.md +++ b/apps/emqx_gateway/README.md @@ -22,9 +22,31 @@ ## ROADMAP -Gateway v0.1: Management support +Gateway v0.1: "Basic Functionals" + - Management support + - Conn/Frame/Protocol Template + - Support Stomp/MQTT-SN/CoAP/LwM2M/ExProto -Gateway v0.2: Conn/Frame/Protocol Template +Gateway v0.2: "Integration & Friendly Management" + - Hooks & Metrics & Statistic + - HTTP APIs + - Management in the cluster + - Integrate with AuthN + - Integrate with `emqx_config` + - Improve hocon config + - Mountpoint & ClientInfo's Metadata + - The Concept Review + +Gateway v0.3: "Fault tolerance and high availability" + - The restart mechanism for gateway-instance + - Consistency of cluster state + - Configuration hot update + +Gateway v1.0: "Best practices for each type of protocol" + - CoAP + - Stomp + - MQTT-SN + - LwM2M ### Compatible with EMQ X diff --git a/apps/emqx_gateway/src/emqx_gateway_cm.erl b/apps/emqx_gateway/src/emqx_gateway_cm.erl index 1708a417b..651c54f4b 100644 --- a/apps/emqx_gateway/src/emqx_gateway_cm.erl +++ b/apps/emqx_gateway/src/emqx_gateway_cm.erl @@ -246,15 +246,24 @@ open_session(_Type, false = _CleanStart, {error, not_supported_now}. %% @private -create_session(_Type, ClientInfo, ConnInfo, CreateSessionFun) -> +create_session(Type, ClientInfo, ConnInfo, CreateSessionFun) -> try Session = emqx_gateway_utils:apply( CreateSessionFun, [ClientInfo, ConnInfo] ), - %% TODO: v0.2 session metrics & hooks - %ok = emqx_metrics:inc('session.created'), - %ok = emqx_hooks:run('session.created', [ClientInfo, emqx_session:info(Session)]), + ok = emqx_gateway_metrics:inc(Type, 'session.created'), + SessionInfo = case is_record(Session, emqx_session) of + true -> emqx_session:info(Session); + _ -> + case is_map(Session) of + false -> + throw(session_structure_should_be_map); + _ -> + Session + end + end, + ok = emqx_hooks:run('session.created', [ClientInfo, SessionInfo]), Session catch Class : Reason : Stk ->