Skip to content

Commit 2460106

Browse files
author
Szymon Mentel
committed
Update type specifications
1 parent 27e697a commit 2460106

5 files changed

Lines changed: 13 additions & 17 deletions

File tree

src/dobby_oflib.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ get_path(SrcEndpoint, DstEndpoint) ->
3636
%%
3737
%% The function returns Net Flow Identifier: `NetFlowId' that can be
3838
%% used for referencing published Net Flow.
39-
-spec publish_new_flow(identifier(), identifier(), flow_path()) ->
39+
-spec publish_new_flow(dby_identifier(), dby_identifier(), flow_path()) ->
4040
Result when
41-
Result :: {ok, NetFlowId :: endpoint()}
41+
Result :: {ok, NetFlowId :: dby_endpoint()}
4242
| {error, Reason :: term()}.
4343

4444
publish_new_flow(SrcEndpoint, DstEndpoint, FlowPath) ->
4545
NfId = publish_net_flow_identifier(SrcEndpoint, DstEndpoint),
4646
publish_flow_path(NfId, FlowPath),
4747
lager:info("Published NetFlow: ~p between endpoints src: ~p dst: ~p ~n",
4848
[NfId, SrcEndpoint, DstEndpoint]),
49-
NfId.
49+
{ok, NfId}.
5050

5151
%%%=============================================================================
5252
%%% Internal functions

src/dofl_identifier.erl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,20 @@
2121
%%% External functions
2222
%%%=============================================================================
2323

24-
-spec net_flow(Src :: identifier(), Dst :: identifier()) -> NetFlow :: endpoint().
24+
-spec net_flow(dby_identifier(), dby_identifier()) -> dby_endpoint().
2525

2626
net_flow(Src, Dst) ->
2727
{<<"NF:", Src/binary, ":", Dst/binary>>, #{type => of_net_flow}}.
2828

29-
-spec flow_mod(Dpid :: binary(), OFVersion :: of_version(), FlowMod :: flow_mod())
30-
-> FlowModId :: endpoint().
29+
-spec flow_mod(dby_identifier(), of_version(), flow_mod()) -> dby_endpoint().
3130

3231
flow_mod(Dpid, OFVersion, FlowMod) ->
3332
{_Matches, _Instructions, Opts} = FlowMod,
3433
Cookie = proplists:get_value(cookie, Opts),
3534
{Cookie, #{type => of_flow_mod, dpid => Dpid, of_version => OFVersion}}.
3635

3736

38-
-spec flow_table(DatapathId :: binary(), FlowMod :: flow_mod())
39-
-> FlowTableId :: idenfier().
37+
-spec flow_table(dby_identifier(), flow_mod()) -> dby_identifier().
4038

4139
flow_table(DatapahtId, {_Matches, _Actions, Opts}) ->
4240
TableNo = proplists:get_value(table_id, Opts),

src/dofl_link_metadata.erl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,26 @@
2121
%%% External functions
2222
%%%=============================================================================
2323

24-
-spec endpoint_with_net_flow(Src :: identifier()) -> Metadata :: map().
24+
-spec endpoint_with_net_flow(dby_identifier()) -> map().
2525

2626
endpoint_with_net_flow(Src) ->
2727
#{type => ep_to_nf, src => Src}.
2828

2929

30-
-spec net_flow_with_flow_mod(Src :: identifier(), NetFlowId :: identifier())
31-
-> Metadata :: map().
30+
-spec net_flow_with_flow_mod(dby_identifier(), dby_identifier()) -> map().
3231

3332
net_flow_with_flow_mod(Src, NetFlowId) when Src =:= NetFlowId ->
3433
#{type => of_path_starts_at, src => Src, net_flow_ids => [NetFlowId]};
3534
net_flow_with_flow_mod(Src, NetFlowId) ->
3635
#{type => of_path_ends_at, src => Src, net_flow_ids => [NetFlowId]}.
3736

3837

39-
-spec between_flow_mods(Src :: identifier(), NetFlowId :: identifier()) ->
40-
Metadata :: map().
38+
-spec between_flow_mods(dby_identifier(), dby_identifier()) -> map().
4139

4240
between_flow_mods(Src, NetFlowId) ->
4341
#{type => of_path_forwards_to, src => Src, net_flow_ids => [NetFlowId]}.
4442

45-
-spec flow_mod_with_flow_table() -> Metadata :: map().
43+
-spec flow_mod_with_flow_table() -> map().
4644

4745
flow_mod_with_flow_table() ->
4846
#{type => of_resource}.

test/dobby_oflib_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ should_publish_net_flow(_Config) ->
4646
FlowPath = dofl_test_utils:flow_path(),
4747

4848
%% WHEN
49-
NetFlowId = dobby_oflib:publish_new_flow(?SRC_EP, ?DST_EP, FlowPath),
49+
{ok, NetFlowId} = dobby_oflib:publish_new_flow(?SRC_EP, ?DST_EP, FlowPath),
5050

5151
%% THEN
5252
assert_net_flow_published(?SRC_EP, ?DST_EP, NetFlowId).
@@ -57,7 +57,7 @@ should_publish_flow_path(_Config) ->
5757
FlowPath1 = reconstruct_flow_path(FlowPath0),
5858

5959
%% WHEN
60-
NetFlowId = dobby_oflib:publish_new_flow(?SRC_EP, ?DST_EP, FlowPath0),
60+
{ok, NetFlowId} = dobby_oflib:publish_new_flow(?SRC_EP, ?DST_EP, FlowPath0),
6161

6262
%% THEN
6363
assert_flow_path_published(NetFlowId, FlowPath1).

test/dofl_with_server_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ should_publish_net_flow(_Config) ->
5252
{of_path_ends_at, ep_to_nf}],
5353

5454
%% WHEN
55-
NetFlowId = dobby_oflib:publish_new_flow(SrcEP, DstEP, FlowPath),
55+
{ok, NetFlowId} = dobby_oflib:publish_new_flow(SrcEP, DstEP, FlowPath),
5656
Expected = lists:flatten([SrcEP, NetFlowId, FlowPathIds, NetFlowId, DstEP]),
5757

5858
%% THEN

0 commit comments

Comments
 (0)