Class: VertxPgClient::PgChannel
- Inherits:
-
Object
- Object
- VertxPgClient::PgChannel
- Includes:
- Vertx::ReadStream
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb
Overview
A channel to Postgres that tracks the subscription to a given Postgres channel using the
LISTEN/UNLISTEN
commands.
When paused the channel discards the messages.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (self) end_handler { ... }
Set an handler to be called when no more notifications will be received.
- - (self) exception_handler { ... }
-
- (self) fetch(amount = nil)
Fetch the specified amount of elements.
-
- (self) handler { ... }
Set or unset an handler to be called when a the channel is notified by Postgres.
-
- (self) pause
Pause the channel, all notifications are discarded.
-
- (::Vertx::Pipe) pipe
Pause this stream and return a to transfer the elements of this stream to a destination .
-
- (void) pipe_to(dst = nil) { ... }
Pipe this ReadStream to the WriteStream.
-
- (self) resume
Resume the channel.
-
- (self) subscribe_handler { ... }
Set an handler called when the the channel get subscribed.
Class Method Details
+ (Boolean) accept?(obj)
23 24 25 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 23 def @@j_api_type.accept?(obj) obj.class == PgChannel end |
+ (Object) j_api_type
32 33 34 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 32 def self.j_api_type @@j_api_type end |
+ (Object) j_class
35 36 37 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 35 def self.j_class Java::IoVertxPgclientPubsub::PgChannel.java_class end |
+ (Object) unwrap(obj)
29 30 31 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 29 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
26 27 28 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 26 def @@j_api_type.wrap(obj) PgChannel.new(obj) end |
Instance Method Details
- (self) end_handler { ... }
Set an handler to be called when no more notifications will be received.
123 124 125 126 127 128 129 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 123 def end_handler if block_given? @j_del.java_method(:endHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield }) return self end raise ArgumentError, "Invalid arguments when calling end_handler()" end |
- (self) exception_handler { ... }
132 133 134 135 136 137 138 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 132 def exception_handler if block_given? @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) })) return self end raise ArgumentError, "Invalid arguments when calling exception_handler()" end |
- (self) fetch(amount = nil)
Fetch the specified
amount
of elements. If the ReadStream
has been paused, reading will
recommence with the specified amount
of items, otherwise the specified amount
will
be added to the current stream demand.
43 44 45 46 47 48 49 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 43 def fetch(amount=nil) if amount.class == Fixnum && !block_given? @j_del.java_method(:fetch, [Java::long.java_class]).call(amount) return self end raise ArgumentError, "Invalid arguments when calling fetch(#{amount})" end |
- (self) handler { ... }
Set or unset an handler to be called when a the channel is notified by Postgres.
- when the handler is set, the subscriber sends a
LISTEN
command if needed - when the handler is unset, the subscriber sends a
UNLISTEN
command if needed
95 96 97 98 99 100 101 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 95 def handler if block_given? @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event) })) return self end raise ArgumentError, "Invalid arguments when calling handler()" end |
- (self) pause
Pause the channel, all notifications are discarded.
104 105 106 107 108 109 110 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 104 def pause if !block_given? @j_del.java_method(:pause, []).call() return self end raise ArgumentError, "Invalid arguments when calling pause()" end |
- (::Vertx::Pipe) pipe
Pause this stream and return a to transfer the elements of this stream to a destination .
The stream will be resumed when the pipe will be wired to a
WriteStream
.
54 55 56 57 58 59 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 54 def pipe if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:pipe, []).call(),::Vertx::Pipe, nil) end raise ArgumentError, "Invalid arguments when calling pipe()" end |
- (void) pipe_to(dst = nil) { ... }
This method returns an undefined value.
Pipe thisReadStream
to the WriteStream
.
Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the handler
will be
called with the result.
69 70 71 72 73 74 75 76 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 69 def pipe_to(dst=nil) if dst.class.method_defined?(:j_del) && !block_given? return @j_del.java_method(:pipeTo, [Java::IoVertxCoreStreams::WriteStream.java_class]).call(dst.j_del) elsif dst.class.method_defined?(:j_del) && block_given? return @j_del.java_method(:pipeTo, [Java::IoVertxCoreStreams::WriteStream.java_class,Java::IoVertxCore::Handler.java_class]).call(dst.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) end raise ArgumentError, "Invalid arguments when calling pipe_to(#{dst})" end |
- (self) resume
Resume the channel.
113 114 115 116 117 118 119 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 113 def resume if !block_given? @j_del.java_method(:resume, []).call() return self end raise ArgumentError, "Invalid arguments when calling resume()" end |
- (self) subscribe_handler { ... }
Set an handler called when the the channel get subscribed.
80 81 82 83 84 85 86 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_channel.rb', line 80 def subscribe_handler if block_given? @j_del.java_method(:subscribeHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield }) return self end raise ArgumentError, "Invalid arguments when calling subscribe_handler()" end |