message.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright 2017 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package dashboard
  17. import (
  18. "encoding/json"
  19. )
  20. type Message struct {
  21. General *GeneralMessage `json:"general,omitempty"`
  22. Home *HomeMessage `json:"home,omitempty"`
  23. Chain *ChainMessage `json:"chain,omitempty"`
  24. TxPool *TxPoolMessage `json:"txpool,omitempty"`
  25. Network *NetworkMessage `json:"network,omitempty"`
  26. System *SystemMessage `json:"system,omitempty"`
  27. Logs *LogsMessage `json:"logs,omitempty"`
  28. }
  29. type ChartEntries []*ChartEntry
  30. type ChartEntry struct {
  31. Value float64 `json:"value"`
  32. }
  33. type GeneralMessage struct {
  34. Version string `json:"version,omitempty"`
  35. Commit string `json:"commit,omitempty"`
  36. }
  37. type HomeMessage struct {
  38. /* TODO (kurkomisi) */
  39. }
  40. type ChainMessage struct {
  41. /* TODO (kurkomisi) */
  42. }
  43. type TxPoolMessage struct {
  44. /* TODO (kurkomisi) */
  45. }
  46. // NetworkMessage contains information about the peers
  47. // organized based on their IP address and node ID.
  48. type NetworkMessage struct {
  49. Peers *peerContainer `json:"peers,omitempty"` // Peer tree.
  50. Diff []*peerEvent `json:"diff,omitempty"` // Events that change the peer tree.
  51. }
  52. // SystemMessage contains the metered system data samples.
  53. type SystemMessage struct {
  54. ActiveMemory ChartEntries `json:"activeMemory,omitempty"`
  55. VirtualMemory ChartEntries `json:"virtualMemory,omitempty"`
  56. NetworkIngress ChartEntries `json:"networkIngress,omitempty"`
  57. NetworkEgress ChartEntries `json:"networkEgress,omitempty"`
  58. ProcessCPU ChartEntries `json:"processCPU,omitempty"`
  59. SystemCPU ChartEntries `json:"systemCPU,omitempty"`
  60. DiskRead ChartEntries `json:"diskRead,omitempty"`
  61. DiskWrite ChartEntries `json:"diskWrite,omitempty"`
  62. }
  63. // LogsMessage wraps up a log chunk. If 'Source' isn't present, the chunk is a stream chunk.
  64. type LogsMessage struct {
  65. Source *LogFile `json:"source,omitempty"` // Attributes of the log file.
  66. Chunk json.RawMessage `json:"chunk"` // Contains log records.
  67. }
  68. // LogFile contains the attributes of a log file.
  69. type LogFile struct {
  70. Name string `json:"name"` // The name of the file.
  71. Last bool `json:"last"` // Denotes if the actual log file is the last one in the directory.
  72. }
  73. // Request represents the client request.
  74. type Request struct {
  75. Logs *LogsRequest `json:"logs,omitempty"`
  76. }
  77. // LogsRequest contains the attributes of the log file the client wants to receive.
  78. type LogsRequest struct {
  79. Name string `json:"name"` // The request handler searches for log file based on this file name.
  80. Past bool `json:"past"` // Denotes whether the client wants the previous or the next file.
  81. }