Commit Graph

4484 Commits

Author SHA1 Message Date
周子博 5c291ff23e Fix the 'route_batch_delete' config 2018-11-28 16:04:04 +08:00
Gilbert Wong d08ed351be Do no execute rebar-clean before distclean
Prior to this change, this project support to be built with rebar3 and
erlang.mk meanwhile but when we want to make distclean, this project
would execute rebar-clean which would get dependencies via rebar3, it
slow down the procedure of distclean.
2018-11-27 17:00:23 +08:00
Gilbert d13c5f8ec1
Reduce dep size (#1981) 2018-11-26 17:55:48 +08:00
周子博 78fdb798f8 Update vsn 2018-11-26 13:51:32 +08:00
Shawn eeb0cab3e3 Update proc meta-data for empty clientid (#1980) 2018-11-23 18:11:46 +08:00
Shawn 09025338d4 Enable emqx.log by default (#1979) 2018-11-23 18:10:59 +08:00
Shawn 93a079752f Update cuttlefish to v2.1.1 (#1978) 2018-11-23 11:04:55 +08:00
Shawn 6fa183f847 Add CLI for log level (#1977) 2018-11-23 11:04:33 +08:00
Shawn 2bd0f16884 Add CLI for log tracer (#1973) 2018-11-23 11:01:10 +08:00
tigercl 551d5d99d2 Change 'aquire' to 'acquire' (#1976)
* Change 'aquire' to 'acquire'
2018-11-23 11:00:30 +08:00
tigercl 14b8036576 Use username replace id(issue#1737) (#1961)
* Use username replace id(issue#1737)

* Add test case for issue#1737

* Make with_connection/2 support batch connect
2018-11-21 22:51:33 +08:00
spring2maz a2c658ba19 Add acking mechamism for shared dispatch (#1872)
* Add acking mechamism for shared dispatch

For QoS0 messages, no acking
For QoS1/2 messages, 'ACK' at any of events below:
 - ACK when QoS is downgraded to 0
 - Message is sent to connection process
'NACK' at any of events below:
 - Message queue is full and the receiving session starts to drop old messages
 - The receiving session crash
Upon 'NACK', messages are dispatched to the 'next' subscriber in the group,
depending on the shared subscription dispatch strategy.
2018-11-21 22:49:45 +08:00
Gilbert 16821490ce Fix issue#1874 (#1964)
* Fix issue#1874
Prior to this change, if user use one client connect emqx with mqtt
v3.1.1, the client subscribe the topic and publish message to this
topic, it would receive this message itself published, this commit
provide a configure option to let user ignore the message itself published.

This change fix issue 1874.

* Small Fix

* Fix bug

* Better design

* Fix compile warning and improve coverage

* Better design to solve the performance issue

* Fix typo

* Fix typo

* Delete spaces in end of lines.

* Do not use anonymous function

* Better performance
2018-11-19 13:34:03 +08:00
terry-xiaoyu bc1464a33f Lazy logging without header 2018-11-19 11:17:58 +08:00
terry-xiaoyu 82b8047349 Helper funcs for adding proc meta-data 2018-11-19 11:17:58 +08:00
terry-xiaoyu e8cc65ef40 Change logger micros 2018-11-19 11:17:58 +08:00
terry-xiaoyu 41315bff0d Log macros for lazy evaluation 2018-11-19 11:17:58 +08:00
terry-xiaoyu 2269967f1a Lazy evaluation when logging messages
Formatting variables and then passing them into the logger functions leads
to performance issues. i.e.

```erlang
logger:debug("RECV ~s", [emqx_packet:format(Packet)])
```

Above message will only be printed when the current log level set to
`debug`, but the function emqx_packet:format/1 will always be evaluated no
matter what the current log level is.

OTP 21 provides a special meta-data named `report_cb`, which can be used
for lazy evaluation. The fun is only evaluated if the primary/handler log level
check passes, and is therefore recommended if it is expensive to generate
the message.
2018-11-19 11:17:58 +08:00
周子博 cb835af42b Fix bad comment 2018-11-19 10:49:05 +08:00
Andrei Nesterov 9d67a64165 Fix type validation for User-Property 2018-11-19 09:53:43 +08:00
terry-xiaoyu 078584172e Print EMQ X Version in the console 2018-11-10 12:14:26 +08:00
turtled faeda253e1 Fix conflicts 2018-11-10 11:44:55 +08:00
terry-xiaoyu 6e26f5e9af Revert logger print to io:format 2 2018-11-10 11:25:52 +08:00
terry-xiaoyu 2611b6fc2a Revert logger print to io:format 2018-11-10 11:01:11 +08:00
周子博 c76e2d1413 Fix 'badarg' in io_lib:format/2 when 'from' field is tuple 2018-11-09 18:32:26 +08:00
terry-xiaoyu 997958aed1 Change the start_link API for emqx_client
Prior to this change, emqx_client:start_link does 2 works in one call:
- init an erlang process for emqx_client
- send MQTT CONNECT to remote broker

But this solution have some drawbacks:

- the return value of `start_link` compiles the return values of the 2
 works: {ok, Pid, MqttResult}. It is inconsistent with the return value
 of `gen_statem:start_link`, may causes confusions.

- the return mode of the 2 works are different:
  `start_link` should always return {ok, Pid} or {error, Reason}, but
 connecting to mqtt may throw out exceptions as it handles the
 socket. But the caller couldn't have thought of the exception, he would
 pattern match on the result of `emqx_client:start_link`, but it crashed!

- If the init work succeed but the connection failed, the caller couldn't
get a Pid from the return value, but indeed it was created inside the
emqx_client. This hides the fact that the Pid was created, and when the
Pid dies, the caller would receive an message from a Pid it doesn' know about.

This change divived these 2 work into 2 APIs:
- `start_link/1` is to build and verify the options, and returns {ok,Pid}
 (on success) or {error, Reason} (on failure).
- `connect/1` is to send MQTT CONNECT, and returns {ok, MQTTResult::properties()} or
 {error, MQTTReason}. MQTT reason codes will contains in the `MQTTReason`.
2018-11-09 17:43:04 +08:00
terry-xiaoyu 2dc8ec8b11 Bridge via TLS 2018-11-09 17:43:04 +08:00
tigercl 3879dcdf59 Fix 'badarg' bug with duplicate subscriptions (#1943) 2018-11-08 23:02:35 +08:00
Gilbert Wong 32d3826440 Replace macro QOS$i to QOS_$I
The two styles of qos macro name in one project is chaotic. It is not
a good practice.

So I change the QOS$i to QOS_$i
2018-11-08 20:42:31 +08:00
terry-xiaoyu f448c62e47 Fix config descriptions of ACL cache 2018-11-08 20:41:57 +08:00
turtleDeng 0a337cbcb4
Merge pull request #1905 from emqx/Fix-for-mqtt-sn
Fix the init_proc_mng_policy bug
2018-11-05 22:30:51 +08:00
terry-xiaoyu cca27d1a5a Change filesync_repeat_interval to no_repeat 2018-11-05 16:04:58 +08:00
Gilbert Wong 4ea57c2bf9 Delete redundant case clauses in sendfun
Prior to this change, there are ok, {binary, _Data}. {datagram, _Peer,
_Dara} case clauses, and the {binary, _Data} and {datagram, _Peer,
_Data} are unnecessary cases

This change delete these two cases and add ok in the end of funtion in
send_fun of emqx_ws_connection.
2018-11-03 22:56:11 +08:00
spring2maz 7ad3a63173
Merge pull request #1926 from emqx/rewrite-mqueue
Rewrite emqx_mqueue.erl
2018-11-03 10:04:30 +01:00
terry-xiaoyu f6266eaa93 Bumped the version number of deps 2018-11-02 19:42:51 +08:00
terry-xiaoyu 2a5f3e949c revert Makefile 2018-11-02 18:38:07 +08:00
terry-xiaoyu 92cc171aaf Support tracing log files for specific topics or clients 2018-11-02 18:38:07 +08:00
terry-xiaoyu 94dbdffd59 New logger formatter with meta-data 2018-11-02 18:38:07 +08:00
terry-xiaoyu 2c63aef3f6 Update schema 2018-11-02 18:32:42 +08:00
terry-xiaoyu 1222dd0eab Update log config template 2018-11-02 18:32:42 +08:00
terry-xiaoyu 46c7e86331 Fix some grammar 2018-11-02 18:32:42 +08:00
terry-xiaoyu 8f5b7a0d05 Optimize config for log section 2018-11-02 18:32:42 +08:00
spring2maz 28c8f2dd5c Remove neotoma plugin, build cuttlefish script in sub-dir 2018-10-27 14:21:53 +02:00
spring2maz ae743ad1f0 Rewrite emqx_mqueue.erl
Fixed bugs:

- Priority queue lack of a `len + 1` logic in `in/2`

Changed behaviors:

- Topics not found in priority table (from config) will be treated with default priority,
  instead of hasing topic name to a priority number.
- Default priority is now configurable (it was always lower than all configured priorities)
- The dropped message due to reaching `max_len` is now returned from `in/2`,
  so the queue owner (`in/2` caller) can perform autopsy on it
2018-10-27 14:21:53 +02:00
turtleDeng 41b79e4f99
Merge pull request #1889 from emqx/improve_connect
Improve will message
2018-10-27 14:37:05 +08:00
tigercl 64cb920b3b
Merge branch 'emqx30' into improve_connect 2018-10-27 14:27:25 +08:00
周子博 3cea06f88f Remove resume_session/1, 2018-10-27 14:25:10 +08:00
周子博 7c14ba11d6 Set some attributes when session resumed 2018-10-27 13:59:17 +08:00
turtleDeng 8788cb2158
Merge pull request #1921 from emqx/improve_test_cases
Improve test cases
2018-10-26 19:45:18 +08:00
周子博 881e1a9621 Add case for ets:match_object 2018-10-26 19:43:05 +08:00