github.com/xxRanger/go-ethereum@v1.8.23/dashboard/message.go (about)

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