Class: ReactivePgClient::PgChannel

Inherits:
Object
  • Object
show all
Includes:
Vertx::ReadStream
Defined in:
/Users/julien/java/reactive-pg-client/target/classes/reactive-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)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


21
22
23
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 21

def @@j_api_type.accept?(obj)
  obj.class == PgChannel
end

+ (Object) j_api_type



30
31
32
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 30

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



33
34
35
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 33

def self.j_class
  Java::IoReactiversePgclientPubsub::PgChannel.java_class
end

+ (Object) unwrap(obj)



27
28
29
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 27

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



24
25
26
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 24

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.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


91
92
93
94
95
96
97
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 91

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 { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


100
101
102
103
104
105
106
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 100

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(arg0 = nil)

Parameters:

  • arg0 (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)


38
39
40
41
42
43
44
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 38

def fetch(arg0=nil)
  if arg0.class == Fixnum && !block_given?
    @j_del.java_method(:fetch, [Java::long.java_class]).call(arg0)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling fetch(#{arg0})"
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

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


63
64
65
66
67
68
69
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 63

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.

Returns:

  • (self)

Raises:

  • (ArgumentError)


72
73
74
75
76
77
78
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 72

def pause
  if !block_given?
    @j_del.java_method(:pause, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling pause()"
end

- (self) resume

Resume the channel.

Returns:

  • (self)

Raises:

  • (ArgumentError)


81
82
83
84
85
86
87
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 81

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.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_channel.rb', line 48

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