From 3abc18d7babe12709f8adc6721540a865e714888 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Sat, 2 Jan 2016 20:53:10 -0800 Subject: [PATCH] Add MConnection.Status() --- connection.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/connection.go b/connection.go index 944a59352..f0f992146 100644 --- a/connection.go +++ b/connection.go @@ -454,6 +454,30 @@ FOR_LOOP: } } +func (c *MConnection) Status() interface{} { + status := make(map[string]interface{}) + status["sendMonitor"] = c.sendMonitor.Status() + status["recvMonitor"] = c.recvMonitor.Status() + + type channelStatus struct { + SendQueueCapacity int + SendQueueSize int + Priority int + RecentlySent int64 + } + + for _, channel := range c.channels { + status[Fmt("ch[%X]", channel.id)] = channelStatus{ + SendQueueCapacity: cap(channel.sendQueue), + SendQueueSize: int(channel.sendQueueSize), // TODO use atomic + Priority: channel.priority, + RecentlySent: channel.recentlySent, + } + } + + return status +} + //----------------------------------------------------------------------------- type ChannelDescriptor struct {