Debian Codegraph @

R/stats.R

raw
1 # nanonext - Stats -------------------------------------------------------------
2
3 #' Get Statistic for a Socket, Listener or Dialer
4 #'
5 #' Obtain value of a statistic for a Socket, Listener or Dialer. This function
6 #' exposes the stats interface of NNG.
7 #'
8 #' Note: the values of individual statistics are guaranteed to be atomic, but
9 #' due to the way statistics are collected there may be discrepancies between
10 #' them at times. For example, statistics counting bytes and messages received
11 #' may not reflect the same number of messages, depending on when the snapshot
12 #' is taken. This potential inconsistency arises as a result of optimisations to
13 #' minimise the impact of statistics on actual operations.
14 #'
15 #' @param object a Socket, Listener or Dialer.
16 #' @param name character name of statistic to return.
17 #'
18 #' @return The value of the statistic (character or double depending on the type
19 #' of statistic requested) if available, or else NULL.
20 #'
21 #' @section Stats:
22 #'
23 #' The following stats may be requested for a Socket:
24 #' \itemize{
25 #' \item 'id' - numeric id of the socket.
26 #' \item 'name' - character socket name.
27 #' \item 'protocol' - character protocol type e.g. 'bus'.
28 #' \item 'pipes' - numeric number of pipes (active connections).
29 #' \item 'dialers' - numeric number of listeners attached to the socket.
30 #' \item 'listeners' - numeric number of dialers attached to the socket.
31 #' }
32 #'
33 #' The following stats may be requested for a Listener / Dialer:
34 #' \itemize{
35 #' \item 'id' - numeric id of the listener / dialer.
36 #' \item 'socket' - numeric id of the socket of the listener / dialer.
37 #' \item 'url' - character URL address.
38 #' \item 'pipes' - numeric number of pipes (active connections).
39 #' }
40 #'
41 #' The following additional stats may be requested for a Listener:
42 #' \itemize{
43 #' \item 'accept' - numeric total number of connection attempts, whether
44 #' successful or not.
45 #' \item 'reject' - numeric total number of rejected connection attempts e.g.
46 #' due to incompatible protocols.
47 #' }
48 #'
49 #' The following additional stats may be requested for a Dialer:
50 #' \itemize{
51 #' \item 'connect' - numeric total number of connection attempts, whether
52 #' successful or not.
53 #' \item 'reject' - numeric total number of rejected connection attempts e.g.
54 #' due to incompatible protocols.
55 #' \item 'refused' - numeric total number of refused connections e.g. when
56 #' starting synchronously with no listener on the other side.
57 #' }
58 #'
59 #' @examples
60 #' s <- socket("bus", listen = "inproc://stats")
61 #' stat(s, "pipes")
62 #'
63 #' s1 <- socket("bus", dial = "inproc://stats")
64 #' stat(s, "pipes")
65 #'
66 #' close(s1)
67 #' stat(s, "pipes")
68 #'
69 #' close(s)
70 #'
71 #' @export
72 #'
73 stat <- function(object, name) .Call(rnng_stats_get, object, name)