ServerInfo() map[string]interface{}
: query server info
minimumCapacity
: minimum allowed capacity for any clientfreeClientCapacity
: capacity assigned to free (unknown, non-priority) clientstotalCapacity
: total allowed capacity of simultaneously connected clients (may change dynamically during operation)totalConnectedCapacity
: total capacity of currently connected clientspriorityConnectedCapacity
: total capacity of currently connected priority clientstotalPriorityCapacity
: total capacity of all priority clients (may exceedtotalCapacity
in which case priority clients might be rejected too)
SetClientParams(ids []string, tags []string, params map[string]interface{}) error
: set certain parameter fields for each client whose id is in the ids
list or has all tags in the tags
list
userTags
: user tags assigned to the clientcapacity
: priority capacity assigned to the client. Zero means non-priority status.pricing/timeFactor
: price of one second of connectionpricing/capacityFactor
: price of one second of connection with a capacity of 1000000- Note:
capacityFactor
is convenient to use when setting pricing parameters in a batch for a group of clients. If the samecapacityFactor
is specified for multiple clients then the actual pricing is proportional to the individual client capacity and is automatically updated when the capacity is changed. Can also be used together withtimeFactor
which is independent of the client's capacity.
- Note:
pricing/requestCostFactor
: price of serving requests with a total serving time of one secondpricing/alert
: send an update event to subscribers whentotalAmount
exceeds the given valuepricing/periodicUpdate
: send an update event to subscribers every time the given amount of cost has been accumulated- Note:
pricing/alert
andpricing/periodicUpdate
are alternative alert mechanisms and cannot be used together.
- Note:
Note: some tags are assigned to clients by the priority client pool automatically:
$all
is assigned to every client$connected
is assigned to currently connected clients$disconnected
is assigned to currently not connected clients$priority
is assigned to priority clients$free
is assigned to free (non-priority) clients
User tags should not start with a "$". Also note that setting parameters for multiple clients selected by tags only affects the clients having those tags at the moment of the call. Setting parameters for previously unknown clients (selected by ID) only has an effect if priority is assigned to them (capacity
is non-zero). Any information about non-priority clients which are currently not connected is discarded.
Price calculation can be enabled for non-priority clients too if the server operator is interested in a theoretical value estimation of the service given away for free. In this case capacityFactor
is calculated with freeClientCapacity
as the current capacity. When a client is disconnected the final totalAmount
can be obtained from the disconnection event. Since the client record is discarded for non-priority clients totalAmount
will also start from zero even if the same client connects again.
ClientInfo(ids []string, tags []string) map[string]map[string]interface{}
: returns information about a given set of clients:
isConnected
capacity
hasPriority
userTags
pricing/totalAmount
(total cost accumulated by the client according to the connection time, capacity and request cost pricing factors)
SubscribeEvents(ids []string, tags []string) (*rpc.Subscription, error)
: subscribe to general server events and client events for the given set of client. Event format is also map[string]interface{}
with the following fields:
totalCapacity
totalConnectedCapacity
priorityConnectedCapacity
clientEvent
(only if the event is client related; can beconnect
,disconnect
orpriceUpdate
)clientId
clientInfo
(amap[string]interface{}
with the same format as returned byClientInfo
)
Note: client events are generated when a client is connected, disconnected, goes into or out of priority status, its capacity has changed or it has accumulated a certain amount of cost specified in the pricing parameters. Non client related events are generated when totalCapacity
has changed significantly. If totalCapacity
drops under priorityConnectedCapacity
then a priority client needs to be dropped or its capacity needs to be reduced. In this case an event is generated immediately and the priority pool gives a short timeframe for the endpoint to take action before selecting some clients itself and dropping them.
Btw now I am thinking whether I should simplify this thing and drop
userTags
and parameter setting for client groups. They are theoretically nice but maybe I am overcomplicating it again. So the simplifications would be:SetClientParams
would only accept a single client ID and set params for a single clientuserTags
would be droppedpricing/capacityFactor
would be unnecessary tooClientInfo
would also accept a single client ID and return info for a single clientClientsInfo
could return client info for every connected clientI would be interested in everyone's opinion about this so if you have one please comment here whether you would like the "full" or "simplified" version.