Commit Graph

12 Commits

Author SHA1 Message Date
0a8b8e629c Revert "use pubsub instead of filenotify to follow json logs"
This reverts commit b1594c59f5e0d1ac898eacde8d91b1ba33c2b626.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 91fdfdd53722179b21b80b9dfbe8bc2e09d0a7b1
Component: engine
2016-02-23 21:43:52 -05:00
7aa41cb67d Use pool for pubsub Publish's waitgroups
benchmark             old ns/op      new ns/op      delta
BenchmarkPubSub-8     1036494796     1032443513     -0.39%

benchmark             old allocs     new allocs     delta
BenchmarkPubSub-8     2467           1441           -41.59%

benchmark             old bytes     new bytes     delta
BenchmarkPubSub-8     212216        187792        -11.51%

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 58d98f82888345a49f2e7660a0a5b35a5da891f5
Component: engine
2016-02-17 14:36:57 -05:00
97fcfe9c7e optimize pubsub.Publish function
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
Upstream-commit: 1e0f1ec52543bc83099fb91cd34dca4d38100e6f
Component: engine
2016-02-15 19:25:21 +08:00
6ebcbbfdd8 use pubsub instead of filenotify to follow json logs
inotify event is trigged immediately there's data written to disk.
But at the time that the inotify event is received, the json line might
not fully saved to disk. If the json decoder tries to decode in such
case, an io.UnexpectedEOF will be trigged.
We used to retry for several times to mitigate the io.UnexpectedEOF error.
But there are still flaky tests caused by the partial log entries.

The daemon knows exactly when there are new log entries emitted. We can
use the pubsub package to notify all the log readers instead of inotify.

Signed-off-by: Shijiang Wei <mountkin@gmail.com>

try to fix broken test. will squash once tests pass

Signed-off-by: Shijiang Wei <mountkin@gmail.com>
Upstream-commit: b1594c59f5e0d1ac898eacde8d91b1ba33c2b626
Component: engine
2016-02-15 19:25:16 +08:00
d555e15f77 Add PubSub topics.
A TopicFunc is an interface to let the pubisher decide whether it needs
to send a message to a subscriber or not. It returns true if the
publisher must send the message and false otherwise.

Users of the pubsub package can create a subscriber with a topic
function by calling `pubsub.SubscribeTopic`.

Message delivery has also been modified to use concurrent channels per
subscriber. That way, topic verification and message delivery is not
o(N+M) anymore, based on the number of subscribers and topic verification
complexity.

Using pubsub topics, the API stops controlling the message delivery,
delegating that function to a topic generated with the filtering
provided by the user. The publisher sends every message to the
subscriber if there is no filter, but the api doesn't have to select
messages to return anymore.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 434d2e8745696255a204d9eefc6a2854ff74e5c2
Component: engine
2015-12-02 16:43:49 -05:00
d0e6da9737 Don't use time.After if there is no timeout
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: bc6ad1608c37b56aa031760cc07e9a30ebe030d8
Component: engine
2015-07-14 09:14:51 -07:00
2c3627f184 Add docstring to pubsub.Publisher
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 7080f5d1cf2c9f86d89a84424394b2c61e925843
Component: engine
2015-07-14 09:10:14 -07:00
9a60e47a81 Race test for pkg/pubsub package
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 8aa7ba731a954ffb626c2a07f524c8116ab3f212
Component: engine
2015-07-13 09:05:47 -07:00
71018bb017 Benchmark for pkg/pubsub package
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: e5da4d62efe17c03ccca3c2707eb19b76afdc150
Component: engine
2015-07-13 09:02:16 -07:00
52d3c50217 Fix send on closed channel bug
Signed-off-by: Chun Chen <chenchun.feed@gmail.com>
Upstream-commit: a408790de8f317d79fb52acb3a5220846a0ffcba
Component: engine
2015-06-12 15:42:34 +08:00
b793c28c03 Remove publisher if no one is listening
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 217a2bd1b62788e53fd38810b30672db58a4efc5
Component: engine
2015-01-20 20:21:47 -08:00
045cd9fe99 Add pubsub package to handle robust publisher
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 2f46b7601a3f5e11359b79624d73075b69778fbb
Component: engine
2015-01-20 20:21:46 -08:00