ric-plt/sdlgo.git
4 years agoSet MaxRetries count 35/935/2 v0.3.1
Marco Tallskog [Wed, 11 Sep 2019 09:53:04 +0000 (12:53 +0300)]
Set MaxRetries count

When redis client is created, set the MaxRetries count to 2. This
defines the number of times the command is tried to execute. In cases
where redis server is dead but the client hasn't noticed that yet, an
EOF error is returned from the first try. With the second attempt, a
proper error is returned indicating that the connection was refused.

Change-Id: I28ffcf83666edda9b715dafe6055cef4c633f757
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
4 years agoAdd resource locking 06/706/1 v0.3.0
Marco Tallskog [Wed, 14 Aug 2019 11:50:23 +0000 (14:50 +0300)]
Add resource locking

Implement methods that enable applications to create locks for
a resources. Resource locks are plain keys with a random value
with an expiration time. Only the holder of a lock can release it either
by removing the lock or by letting it expire (after it will be
automatically removed). By using a random value (that only lock holder
knows), it can be ensured that others can't remove it. Resource locks
are per namespace.

Implemented methods are:
LockResource: this method will check if the lock already exists and if
not, it will create it with an expiration time. It is possible for the
client to define with options how many times the lock will be tried and
the interval how often it is tried. If retry is used, this method will
block.
ReleaseResource: remove the lock. If removing is tried after the
expiration, an error will be returned.
RefreshResource: with this method, it is possible to set a new
expiration time for the lock. If the lock has already expired, an error
will be returned.
CheckResource: application can query the remaining expiration time with
this method, regardless it is the owner of the lock or not.

Change-Id: Ic6f5274c1740c7e36ddaba564024cffcc4c5de3d
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
4 years agoSupport multiple event publishing 57/457/4 v0.2.1
Marco Tallskog [Wed, 3 Jul 2019 07:25:20 +0000 (10:25 +0300)]
Support multiple event publishing

Support for publishing multiple events at once.
Originally it was possible to give multiple channels and
events as parameter to SetAndPublish() and RemoveAndPublish() API
functions. However, only the first event was published as
used Redis didn't support multiple event publishing. This
commit takes new Redis commands into use enabling the
support for multiple event publishing.

Add unit tests for internal sdlgoredis package. To be able
to stub external redisgo module, the Create() function is
splitted so that in unit tests it is possible to provide
a stub interface instead of the real one when building
the redisgo instance. Also Subscribe() function is wrapped,
and wrapper function is provided during setup as calling
the Subscribe() for the first time in code execution,
a new interface is provided that needs to be able to mock
in unit tests.

Improve documentation. Add doc.go which provides a better
documentation how to use SDL.

Change-Id: Id072d9397fa92ea37bcc78df7db54edadf4d9e7c
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
4 years agoAdd support for SDL groups 94/194/3 v0.2.0
Marco Tallskog [Fri, 24 May 2019 13:17:02 +0000 (16:17 +0300)]
Add support for SDL groups

SDL group is an unordered collection of members where each member is
unique.

Add the following methods to do operations with groups:
-AddMember: adds number of members into a given group. It is possible to
give already existing members to be added but that doesn't have an
effect to group.
-RemoveMember: Remove number of members from a group. It is possible to
try to remove non-existing members from a group without an error.
-RemoveGroup: Remove the whole group along with its members.
-GetMembers: Get all members from a group.
-IsMember: Check if a specific member is part of the group.
-GroupSize: Return the number of members in group.

Change-Id: I9005ffe584aa0872c5a3fab170d0ac37d9b9f30a
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
5 years agoAllow byte array/slice be given as value 71/171/3 v0.1.1
Marco Tallskog [Fri, 17 May 2019 10:05:00 +0000 (13:05 +0300)]
Allow byte array/slice be given as value

An error was given if byte slice or array was given as a value, now they
are allowed. However, other types or slices are not allowed as value.

Change-Id: Ia0c4515498a1b0e03a002a7d4357adb6d262213a
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
5 years agoAdd support for notifications 49/149/5 v0.1.0
Marco Tallskog [Tue, 14 May 2019 12:09:19 +0000 (15:09 +0300)]
Add support for notifications

Add new API function to subscribe/unsubscribe  notifications
from a channel. With SubscribeChannel function it is possible to
subscribe one or many channels and attach a callback function taht will
be called when the notification (event) is received from a channel. It
is possible to have separate callback functions to different channels
but then subscription must be done separately. With UnsubscribeChannel
one can unsubscribe one or many subsribed channels.

Each function, that modifies database (sets or removes) will have
another API function that will cause an event to be sent to given
channel. E.g. the following two functions:

Set(pairs ...interface{})
SetAndPublish(channelsAndEvents []string, pairs ...interface{})

The first function just sets a value to key, whereas the second function
does the same thing and also sends an event to channel. The channels and
events are given as pairs in channelsAndEvents slice e.g.
[]string{"channel", "event"}
Although it is possible to give several channel event pairs, only
sending an event to one channel is supported at the moment due to
missing support in Redis DB.

Change-Id: I4fc96cd4c8a59410700f670ad5588fe71509fd03
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
5 years agoFix Close API call 05/105/1 v0.0.2
Marco Tallskog [Fri, 3 May 2019 08:45:22 +0000 (11:45 +0300)]
Fix Close API call

Calling Close function from API caused a recursive call to itself as the
underlying module was using a function with same name. Rename the
internal close function to avoid this.

Change-Id: I05c3ca8e79fb5f30cae81917f56efacbd1797768
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
5 years agoInitial commit 55/55/2 v0.0.1
Marco Tallskog [Wed, 17 Apr 2019 10:19:22 +0000 (13:19 +0300)]
Initial commit

Change-Id: Iaf5456d3f1b8b59a727d7df46fe556fe00ac4c0e
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
5 years agoInitial empty repository
Andrew Grimberg [Mon, 8 Apr 2019 19:44:49 +0000 (19:44 +0000)]
Initial empty repository