Class: Swarmclient::Communication

Inherits:
Object
  • Object
show all
Includes:
Connection, Constants, ProtoSerializer
Defined in:
lib/swarmclient/pubsub.rb,
lib/swarmclient/communication.rb

Constant Summary

Constants included from Constants

Swarmclient::Constants::CONNECTION_TIMEOUT_LIMIT, Swarmclient::Constants::DEFAULT_IP, Swarmclient::Constants::DEFAULT_PORT, Swarmclient::Constants::DEFAULT_UUID, Swarmclient::Constants::MAX_REDIRECT_ATTEMPT, Swarmclient::Constants::TRANSATION_ID_UPPER_LIMIT

Instance Method Summary collapse

Constructor Details

#initialize(endpoint: DEFAULT_IP, port: DEFAULT_PORT, uuid: DEFAULT_UUID, secure: false) ⇒ Communication

To continue here



7
8
# File 'lib/swarmclient/pubsub.rb', line 7

def initialize
end

Instance Method Details

#create(key, value) ⇒ Object



24
25
26
# File 'lib/swarmclient/communication.rb', line 24

def create key, value
  send_request cmd: 'create', data: { key: key, value: value.to_s }
end

#has(key) ⇒ Object



40
41
42
# File 'lib/swarmclient/communication.rb', line 40

def has key
  send_request cmd: 'has', data: { key: key }
end

#keysObject



44
45
46
# File 'lib/swarmclient/communication.rb', line 44

def keys
  send_request cmd: 'keys', data: nil
end

#read(key) ⇒ Object



28
29
30
# File 'lib/swarmclient/communication.rb', line 28

def read key
  send_request cmd: 'read', data: { key: key }
end

#remove(key) ⇒ Object



36
37
38
# File 'lib/swarmclient/communication.rb', line 36

def remove key
  send_request cmd: 'delete', data: { key: key }
end

#sizeObject



48
49
50
# File 'lib/swarmclient/communication.rb', line 48

def size
  send_request cmd: 'size', data: nil
end

#subscribeObject



10
11
# File 'lib/swarmclient/pubsub.rb', line 10

def subscribe
end

#unsubscribeObject



13
14
# File 'lib/swarmclient/pubsub.rb', line 13

def unsubscribe
end

#update(key, value) ⇒ Object



32
33
34
# File 'lib/swarmclient/communication.rb', line 32

def update key, value
  send_request cmd: 'update', data: { key: key, value: value.to_s }
end