• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

emqx / esockd / 435

13 Jul 2024 11:07AM UTC coverage: 66.998%. First build
435

Pull #190

github

web-flow
Merge 8478e6815 into 4ec038215
Pull Request #190: fix: refactor the udp proxy

0 of 46 new or added lines in 4 files covered. (0.0%)

877 of 1309 relevant lines covered (67.0%)

56.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/udp_proxy/esockd_udp_proxy_connection.erl
1
%%--------------------------------------------------------------------
2
%% Copyright (c) 2024 EMQ Technologies Co., Ltd. All Rights Reserved.
3
%%
4
%% Licensed under the Apache License, Version 2.0 (the "License");
5
%% you may not use this file except in compliance with the License.
6
%% You may obtain a copy of the License at
7
%%
8
%%     http://www.apache.org/licenses/LICENSE-2.0
9
%%
10
%% Unless required by applicable law or agreed to in writing, software
11
%% distributed under the License is distributed on an "AS IS" BASIS,
12
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
%% See the License for the specific language governing permissions and
14
%% limitations under the License.
15
%%--------------------------------------------------------------------
16

17
-module(esockd_udp_proxy_connection).
18

19
-include("include/esockd_proxy.hrl").
20

21
-export([
22
    initialize/2,
23
    find_or_create/5,
24
    get_connection_id/5,
25
    dispatch/4,
26
    close/3
27
]).
28

29
-export_type([connection_id/0, connection_module/0]).
30

31
%%--------------------------------------------------------------------
32
%%- Callbacks
33
%%--------------------------------------------------------------------
34
-callback initialize(connection_options()) -> connection_state().
35

36
%% Create new connection
37
-callback find_or_create(connection_id(), proxy_transport(), peer(), connection_options()) ->
38
    gen_server:start_ret().
39

40
%% Find routing information
41
-callback get_connection_id(
42
    proxy_transport(), peer(), connection_state(), socket_packet()
43
) ->
44
    get_connection_id_result().
45

46
%% Dispacth message
47
-callback dispatch(pid(), connection_state(), proxy_packet()) -> ok.
48

49
%% Close Connection
50
-callback close(pid(), connection_state()) -> ok.
51

52
%%--------------------------------------------------------------------
53
%%- API
54
%%--------------------------------------------------------------------
55
initialize(Mod, Opts) ->
56
    Mod:initialize(Opts).
×
57

58
find_or_create(Mod, CId, Transport, Peer, Opts) ->
NEW
59
    Mod:find_or_create(CId, Transport, Peer, Opts).
×
60

61
get_connection_id(Mod, Transport, Peer, State, Data) ->
62
    Mod:get_connection_id(Transport, Peer, State, Data).
×
63

64
dispatch(Mod, Pid, State, Packet) ->
65
    Mod:dispatch(Pid, State, Packet).
×
66

67
close(Mod, Pid, State) ->
68
    Mod:close(Pid, State).
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc