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 exceedtotalCapacityin 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:
capacityFactoris convenient to use when setting pricing parameters in a batch for a group of clients. If the samecapacityFactoris 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 withtimeFactorwhich 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 whentotalAmountexceeds the given valuepricing/periodicUpdate: send an update event to subscribers every time the given amount of cost has been accumulated- Note:
pricing/alertandpricing/periodicUpdateare alternative alert mechanisms and cannot be used together.
- Note:
Note: some tags are assigned to clients by the priority client pool automatically:
$allis assigned to every client$connectedis assigned to currently connected clients$disconnectedis assigned to currently not connected clients$priorityis assigned to priority clients$freeis 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:
isConnectedcapacityhasPriorityuserTagspricing/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:
totalCapacitytotalConnectedCapacitypriorityConnectedCapacityclientEvent(only if the event is client related; can beconnect,disconnectorpriceUpdate)clientIdclientInfo(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.
The only reason
pricing/capacityFactormakes sense is because of the batch parameter settings. If your pricing model has a factor that is proportional to capacity you can set params for all paying clients in a single batch and the API would set the actual pricing according to the capacity.