message.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. "time"
  20. )
  21. type Message struct {
  22. General *GeneralMessage `json:"general,omitempty"`
  23. Home *HomeMessage `json:"home,omitempty"`
  24. Chain *ChainMessage `json:"chain,omitempty"`
  25. TxPool *TxPoolMessage `json:"txpool,omitempty"`
  26. Network *NetworkMessage `json:"network,omitempty"`
  27. System *SystemMessage `json:"system,omitempty"`
  28. Logs *LogsMessage `json:"logs,omitempty"`
  29. }
  30. type ChartEntries []*ChartEntry
  31. type ChartEntry struct {
  32. Time time.Time `json:"time,omitempty"`
  33. Value float64 `json:"value,omitempty"`
  34. }
  35. type GeneralMessage struct {
  36. Version string `json:"version,omitempty"`
  37. Commit string `json:"commit,omitempty"`
  38. }
  39. type HomeMessage struct {
  40. /* TODO (kurkomisi) */
  41. }
  42. type ChainMessage struct {
  43. /* TODO (kurkomisi) */
  44. }
  45. type TxPoolMessage struct {
  46. /* TODO (kurkomisi) */
  47. }
  48. type NetworkMessage struct {
  49. /* TODO (kurkomisi) */
  50. }
  51. type SystemMessage struct {
  52. ActiveMemory ChartEntries `json:"activeMemory,omitempty"`
  53. VirtualMemory ChartEntries `json:"virtualMemory,omitempty"`
  54. NetworkIngress ChartEntries `json:"networkIngress,omitempty"`
  55. NetworkEgress ChartEntries `json:"networkEgress,omitempty"`
  56. ProcessCPU ChartEntries `json:"processCPU,omitempty"`
  57. SystemCPU ChartEntries `json:"systemCPU,omitempty"`
  58. DiskRead ChartEntries `json:"diskRead,omitempty"`
  59. DiskWrite ChartEntries `json:"diskWrite,omitempty"`
  60. }
  61. // LogsMessage wraps up a log chunk. If Source isn't present, the chunk is a stream chunk.
  62. type LogsMessage struct {
  63. Source *LogFile `json:"source,omitempty"` // Attributes of the log file.
  64. Chunk json.RawMessage `json:"chunk"` // Contains log records.
  65. }
  66. // LogFile contains the attributes of a log file.
  67. type LogFile struct {
  68. Name string `json:"name"` // The name of the file.
  69. Last bool `json:"last"` // Denotes if the actual log file is the last one in the directory.
  70. }
  71. // Request represents the client request.
  72. type Request struct {
  73. Logs *LogsRequest `json:"logs,omitempty"`
  74. }
  75. type LogsRequest struct {
  76. Name string `json:"name"` // The request handler searches for log file based on this file name.
  77. Past bool `json:"past"` // Denotes whether the client wants the previous or the next file.
  78. }