Commit 8cf6ad33 authored by Kamil Kisiel's avatar Kamil Kisiel

Documented console.go

parent 899d1553
......@@ -6,13 +6,17 @@ import (
"strings"
)
// DefaultConsoleAddr is the default address on which a ConsoleServer will listen
const DefaultConsoleAddr = ":8126"
// ConsoleServer is an object that listens for telnet connection on a TCP address Addr
// and provides a console interface to a manage a MetricsAggregator
type ConsoleServer struct {
Addr string
Aggregator *MetricAggregator
}
// ListenAndServe listens on the ConsoleServer's TCP network address and then calls Serve
func (s *ConsoleServer) ListenAndServe() error {
addr := s.Addr
if addr == "" {
......@@ -25,6 +29,8 @@ func (s *ConsoleServer) ListenAndServe() error {
return s.Serve(l)
}
// Serve accepts incoming connections on the listener and serves them a console interface to
// the MetricAggregator
func (s *ConsoleServer) Serve(l net.Listener) error {
defer l.Close()
for {
......@@ -38,11 +44,13 @@ func (s *ConsoleServer) Serve(l net.Listener) error {
panic("not reached")
}
// consoleConn represents a single ConsoleServer connection
type consoleConn struct {
conn net.Conn
server *ConsoleServer
}
// serve reads from the consoleConn and responds to incoming requests
func (c *consoleConn) serve() {
defer c.conn.Close()
buf := make([]byte, 1024)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment