0.3.1 fix topic match
This commit is contained in:
parent
537e18b376
commit
41471da2e8
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
eMQTT ChangeLog
|
eMQTT ChangeLog
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
@ -6,6 +7,14 @@ v0.3.1-beta (2015-01-24)
|
||||||
|
|
||||||
Feature: HTTP POST API to support 'qos', 'retain' parameters
|
Feature: HTTP POST API to support 'qos', 'retain' parameters
|
||||||
|
|
||||||
|
Feature: $SYS system topics support
|
||||||
|
|
||||||
|
Change: Rewrite emqtt_topic.erl, use '', '#', '+' to replace <<"">>, <<"#">>, <<"+">>
|
||||||
|
|
||||||
|
Change: fix emqtt_pubsub.erl to match '#', '+'
|
||||||
|
|
||||||
|
Tests: emqtt_topic_tests.erl add more test cases
|
||||||
|
|
||||||
v0.3.0-alpha (2015-01-18)
|
v0.3.0-alpha (2015-01-18)
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%-----------------------------------------------------------------------------
|
%%-----------------------------------------------------------------------------
|
||||||
%% Copyright (c) 2015, Feng Lee <feng@emqtt.io>
|
%% Copyright (c) 2012-2015, Feng Lee <feng@emqtt.io>
|
||||||
%%
|
%%
|
||||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
%% of this software and associated documentation files (the "Software"), to deal
|
%% of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -24,32 +24,32 @@
|
||||||
%% Core PubSub Topic
|
%% Core PubSub Topic
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
-record(topic, {
|
-record(topic, {
|
||||||
name :: binary(),
|
name :: binary(),
|
||||||
node :: node()
|
node :: node()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type topic() :: #topic{}.
|
-type topic() :: #topic{}.
|
||||||
|
|
||||||
-record(topic_subscriber, {
|
-record(topic_subscriber, {
|
||||||
topic :: binary(),
|
topic :: binary(),
|
||||||
qos = 0 :: non_neg_integer(),
|
qos = 0 :: non_neg_integer(),
|
||||||
subpid :: pid()
|
subpid :: pid()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-record(topic_trie_node, {
|
-record(topic_trie_node, {
|
||||||
node_id :: binary(),
|
node_id :: binary() | atom(),
|
||||||
edge_count = 0 :: non_neg_integer(),
|
edge_count = 0 :: non_neg_integer(),
|
||||||
topic :: binary()
|
topic :: binary()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-record(topic_trie_edge, {
|
-record(topic_trie_edge, {
|
||||||
node_id :: binary(),
|
node_id :: binary() | atom(),
|
||||||
word :: binary() | char()
|
word :: binary() | atom()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-record(topic_trie, {
|
-record(topic_trie, {
|
||||||
edge :: #topic_trie_edge{},
|
edge :: #topic_trie_edge{},
|
||||||
node_id :: binary()
|
node_id :: binary() | atom()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
|
@ -300,10 +300,10 @@ trie_match(NodeId, [W|Words], ResAcc) ->
|
||||||
[#topic_trie{node_id=ChildId}] -> trie_match(ChildId, Words, Acc);
|
[#topic_trie{node_id=ChildId}] -> trie_match(ChildId, Words, Acc);
|
||||||
[] -> Acc
|
[] -> Acc
|
||||||
end
|
end
|
||||||
end, 'trie_match_#'(NodeId, ResAcc), [W, <<"+">>]).
|
end, 'trie_match_#'(NodeId, ResAcc), [W, '+']).
|
||||||
|
|
||||||
'trie_match_#'(NodeId, ResAcc) ->
|
'trie_match_#'(NodeId, ResAcc) ->
|
||||||
case mnesia:read(topic_trie, #topic_trie_edge{node_id=NodeId, word = <<"#">>}) of
|
case mnesia:read(topic_trie, #topic_trie_edge{node_id=NodeId, word = '#'}) of
|
||||||
[#topic_trie{node_id=ChildId}] ->
|
[#topic_trie{node_id=ChildId}] ->
|
||||||
mnesia:read(topic_trie_node, ChildId) ++ ResAcc;
|
mnesia:read(topic_trie_node, ChildId) ++ ResAcc;
|
||||||
[] ->
|
[] ->
|
||||||
|
|
Loading…
Reference in New Issue