ric-plt/sdlgo.git
3 years agoFix Go routine race condition in DB notification map 15/4815/3 cherry v0.5.4
Timo Tietavainen [Wed, 7 Oct 2020 04:07:24 +0000 (07:07 +0300)]
Fix Go routine race condition in DB notification map

Map cbMap was accessible by the main Go routine and also by a Go routine, which
handled incoming notifications from database (Redis). Problem was visible, when
unit tests were run with '-race' flag. Fix the issue by adding a mutex lock to
guard cbMap accesses. Go routine what handles incoming notification has a local
lockless copy of the cbMap to make sure that notification handling speed won't
be suffering from mutex locks. Local copy of cbMap is updated whenever the
cbMap has been updated.

Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: I066ff1d71340db2240a7ea6aeeb575f098488608

3 years agoTake Redis client version 6.15.9 into use 53/4553/2 v0.5.3
Timo Tietavainen [Mon, 17 Aug 2020 11:48:06 +0000 (14:48 +0300)]
Take Redis client version 6.15.9 into use

Take newer Redis client version 6.15.9 into use from:
https://github.com/go-redis/redis

Reasoning was to get bug fixes, especially fix for this one:
https://github.com/go-redis/redis/issues/1149

Updated also go.sum file after running 'go mod tidy' command.

Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: I694282e669a9ae70040e9d95ea0c19d8c94bceea

3 years agoRephrase release notes introduction 38/4138/1 bronze
Timo Tietavainen [Tue, 16 Jun 2020 17:01:18 +0000 (20:01 +0300)]
Rephrase release notes introduction

Remove release name from introduction section to make it
unaltered for release changes.

Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: If5dcb2c18b8568b670bd1198c72e1753b350bb70

4 years agoAdd extra line about src files are part of RIC platform project 31/1831/1 Amber v0.5.2
Timo Tietavainen [Thu, 28 Nov 2019 07:58:48 +0000 (09:58 +0200)]
Add extra line about src files are part of RIC platform project

Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: Id38667ce1a1f109db284802d50baf28f1780bc58

4 years agoMerge "Add documentation files"
Timo Tietavainen [Wed, 13 Nov 2019 10:18:10 +0000 (10:18 +0000)]
Merge "Add documentation files"

4 years agoAdd documentation files 42/1542/1
Timo Tietavainen [Wed, 13 Nov 2019 06:01:10 +0000 (08:01 +0200)]
Add documentation files

Added mandatory documentation files for the RIC Amber release.

Change-Id: Ib61949c1dc6b7302de7adb907158caf1ca905dea
Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
4 years agoAutomation adds INFO.yaml 42/1442/2
Aric Gardner [Fri, 8 Nov 2019 16:02:22 +0000 (16:02 +0000)]
Automation adds INFO.yaml

Change-Id: I9134d022dce524eac8b49afb5bc740fd7957cdae
Signed-off-by: Aric Gardner <agardner@linuxfoundation.org>
4 years agoAdd support for CI jobs 16/1316/1 v0.5.1
Marco Tallskog [Fri, 1 Nov 2019 14:23:12 +0000 (16:23 +0200)]
Add support for CI jobs

Ad ci directory containing a Dockerfile where unit tests shall be
executed.

Change-Id: Ica50888d24b7cdd4326a632a408619ed17be08c0
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
4 years agoMake DB instance visible 39/1139/5 v0.5.0
Marco Tallskog [Fri, 11 Oct 2019 10:24:04 +0000 (13:24 +0300)]
Make DB instance visible

Make underlying DB instance visible to clients. This change makes it
easier for the clients to e.g. share the same DB instance between
multiple SDL instances (multiple namespaces is used). The DB instance
can be created once and reuse it every time a new SDL instance is
created. The DB instance is created with Newdatabase() method.

Update the documentation so that it is mentioned that subscribing the
channels is not safe for concurrent usage.

Change-Id: I1b09500eda44b6b095a3bf564c38e794d02f9d95
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
4 years agoSupport redis sentinel configuration 18/1018/1 v0.4.0
Marco Tallskog [Thu, 26 Sep 2019 12:51:29 +0000 (15:51 +0300)]
Support redis sentinel configuration

Based on environment variables set, sdl will select either to connect to
standalone redis or sentinel redis. The underlying redis-go
implementation takes care of how connection to master is handled and
what happens if there is a switcover in redis.

Change-Id: Ib413b61e6a7e26e8ad2bd7f83331554271a93c69
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
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