The server needs to persist more state for a client connection. Therefore, the Store interface has been changed:
- Changed
AddClient(clientID, hbInbox string)
toAddClient(info *spb.ClientInfo)
For SQL Stores, the Clients
table has been altered to add a proto
column.
You can update the SQL table manually or run the provided scripts that create the tables if they don't exists and alter the Clients
table adding the new column. For instance, with MySQL, you would run something similar to:
mysql -u root nss_db < scripts/mysql.db.sql
The above assumes you are in the NATS Streaming Server directory, and the streaming database is called nss_db
.
Otherwise, from the mysql CLI, you can run the command:
mysql> alter table Clients add proto blob;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
For Postgres, it would be:
nss_db=# alter table Clients add proto bytea;
ALTER TABLE
If you run the server version with 0.10.0
a database that has not been updated, you would get the following error:
[FTL] STREAM: Failed to start: unable to prepare statement "INSERT INTO Clients (id, hbinbox, proto) VALUES (?, ?, ?)": Error 1054: Unknown column 'proto' in 'field list'
Additions to the Store interface to support deletion of channels.
- Added
Store.GetChannelLimits()
API to return the store limits for a given channel. - Added
Store.DeleteChannel()
API to delete a channel.
Protocol was added to support replication of deletion of a channel in the cluster.
The Store interface has been slightly changed to accommodate the clustering feature.
-
Changed
MstStore.Store()
API to accept a*pb.MsgProto
instead of a byte array. This is because the server is now assigning the sequence number.The store implementation should ignore the call if the given sequence number is below or equal to what has been already stored.
-
Added
MsgStore.Empty()
API to empty a given channel message store.
The Store interface has been heavily modified. Some of the responsibilities have been moved into the server resulting on deletion of some Store APIs and removal of UserData
fields in Client
and ChannelStore
(renamed Channel
) objects.
NOTE: Although the interface has changed, the file format of the FileStore implementation has not, which means that there is backward/forward compatibility between this and previous releases.
The Store interface was updated:
-
Added error
ErrAlreadyExists
thatCreateChannel()
should return if channel already exists. -
RecoveredState
has nowChannels
(instead ofSubs
) and is a map of*RecoveredChannel
keyed by channel name. -
RecoveredChannel
has a pointer to aChannel
(formelyChannelStore
) and an array of pointers toRecoveredSubscription
objects. -
RecoveredSubscription
replacesRecoveredSubState
. -
Client
no longer stores aUserData
field. -
Channel
(formerlyChannelStore
) no longer stores aUserData
field. -
CreateChannel()
no longer accepts auserData interface{}
parameter. It returns a*Channel
and anerror
. If the channelalready exists, the error
ErrAlreadyExists
is returned. -
LookupChannel()
,HasChannel()
,GetChannels()
,GetChannelsCount()
,GetClient()
,GetClients
,GetClientsCount()
andMsgsState()
APIshave all been removed. The server keeps track of clients and channels and therefore does not need those APIs.
-
AddClient()
is now simply returning a*Client
anderror
. It no longer accepts auserData interface{}
parameter. -
DeleteClient()
now returns an error instead of returning the deleted*Client
. This will allow the server toreport possible errors.
The SubStore interface was updated:
-
DeleteSub()
has been modified to return an error. This allows the server to report possible errors during deletionof a subscription.
The MsgStore interface was updated:
-
Lookup()
,FirstSequence()
,LastSequence()
,FirstAndLastSequence()
,GetSequenceFromTimestamp()
,FirstMsg()
andLastMsg()
have all been modified to return an error. This is so that implementations that may fail to lookup, get the first sequence, etc...
have a way to report the error to the caller.
The Store interface was updated. There are 2 news APIs:
-
GetChannels()
: Returns a map of*ChannelStore
, keyed by channel names.The implementation needs to return a copy to make it safe for the caller to manipulate
the map without a risk of concurrent access.
-
GetChannelsCount()
: Returns the number of channels currently stored.
The Store interface was updated. There are 2 news APIs:
-
Recover()
: The recovery of persistent state was previously done in the constructor of the store implementation.It is now separate and specified with this API. The server will first instantiate the store, in
which some initialization or checks can be made.
If no error is reported, the server will then proceed with calling
Recover()
, which will returned the recovered state. -
GetExclusiveLock()
: In Fault Tolerance mode, when a server is elected leader, it will attempt to get an exclusivelock to the shared storage before proceeding.
Check the Store interface for more information.