Documentation
¶
Index ¶
- Variables
- func NewWebSocketConnection(w http.ResponseWriter, r *http.Request, logStore *LogStore) (*WebSocketConnection, *ClientConnection, error)
- func NotFoundHandler(fallback string) func(w http.ResponseWriter, r *http.Request)
- type ClientConnection
- type ClientConnections
- type Container
- type ContainerConfig
- type ContainerList
- type Direction
- type Docker
- type DockerEventType
- type DummyReceiver
- func (d *DummyReceiver) GetEvents() []ReceivedEvent
- func (d *DummyReceiver) ReceiveChannelUpdate(channels []string, containers []*ContainerConfig)
- func (d *DummyReceiver) ReceiveLogUpdate(channelName string, logs []LogEntry, scrollID int)
- func (d *DummyReceiver) ReceiveOldLogs(channelName string, logs []LogEntry, scrollID int)
- type Event
- type EventType
- type FilterFunc
- type JsonMessage
- type LogEntry
- type LogEventType
- type LogStore
- func (ls *LogStore) AppendLog(containerID string, logEntry LogEntry) error
- func (ls *LogStore) ConnectToDocker(ctx context.Context, d Docker) error
- func (ls *LogStore) Iterate(callback func(containerID string, container *Container))
- func (ls *LogStore) RegisterContainer(cc *ContainerConfig)
- func (ls *LogStore) Search(containerID string, searchFrom, count int, opt Option) (result []LogEntry, scrollIDs ScrollIDs, err error)
- func (ls *LogStore) SetContainerState(containerID string, running bool) error
- type LogType
- type Option
- type ReceivedEvent
- type Receiver
- type ScrollIDs
- type SerializedString
- type Severity
- type StatEntry
- type StructLogEntry
- type Timestamp
- type WebSocketConnection
- func (c WebSocketConnection) ReceiveChannelUpdate(channels []string, containers []*ContainerConfig)
- func (c WebSocketConnection) ReceiveLogUpdate(channelName string, logs []LogEntry, scrollID int)
- func (c WebSocketConnection) ReceiveOldLogs(channelName string, logs []LogEntry, scrollID int)
- func (c WebSocketConnection) Wait()
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrContainerNotFound = errors.New("container not found")
View Source
var ErrDir = errors.New("path is dir")
Functions ¶
func NewWebSocketConnection ¶
func NewWebSocketConnection(w http.ResponseWriter, r *http.Request, logStore *LogStore) (*WebSocketConnection, *ClientConnection, error)
func NotFoundHandler ¶
func NotFoundHandler(fallback string) func(w http.ResponseWriter, r *http.Request)
Types ¶
type ClientConnection ¶
type ClientConnection struct {
// contains filtered or unexported fields
}
ClientConnection is a backbone of client side API
WebSocketConnection is built on ClientConnection
func NewClientConnection ¶
func NewClientConnection(receiver Receiver, logStore *LogStore) *ClientConnection
func (*ClientConnection) Disconnect ¶
func (c *ClientConnection) Disconnect(containerID string)
func (*ClientConnection) Listen ¶
func (c *ClientConnection) Listen(channelName string, filterSrc map[string]string) error
func (*ClientConnection) RetrieveChannels ¶
func (c *ClientConnection) RetrieveChannels()
func (*ClientConnection) RetrieveLogs ¶
func (c *ClientConnection) RetrieveLogs(containerID string) error
type ClientConnections ¶
type ClientConnections struct {
// contains filtered or unexported fields
}
func NewClientConnections ¶
func NewClientConnections() *ClientConnections
func (*ClientConnections) Loop ¶
func (c *ClientConnections) Loop(callback func(*ClientConnection))
func (*ClientConnections) ReceiveLogUpdate ¶
func (c *ClientConnections) ReceiveLogUpdate(channelName string)
func (*ClientConnections) Register ¶
func (c *ClientConnections) Register(ctx context.Context, conn *ClientConnection)
type ContainerConfig ¶
type ContainerList ¶
type ContainerList struct {
Containers []*ContainerConfig `json:"containers"`
}
type DockerEventType ¶
type DockerEventType string
const ( ContainerStartEvent DockerEventType = "start" ContainerRunningEvent DockerEventType = "running" ContainerDieEvent DockerEventType = "die" )
type DummyReceiver ¶
type DummyReceiver struct {
// contains filtered or unexported fields
}
DummyReceiver is a mock object of ClientConnection
func (*DummyReceiver) GetEvents ¶
func (d *DummyReceiver) GetEvents() []ReceivedEvent
func (*DummyReceiver) ReceiveChannelUpdate ¶
func (d *DummyReceiver) ReceiveChannelUpdate(channels []string, containers []*ContainerConfig)
func (*DummyReceiver) ReceiveLogUpdate ¶
func (d *DummyReceiver) ReceiveLogUpdate(channelName string, logs []LogEntry, scrollID int)
func (*DummyReceiver) ReceiveOldLogs ¶
func (d *DummyReceiver) ReceiveOldLogs(channelName string, logs []LogEntry, scrollID int)
type Event ¶
type Event struct { EventType DockerEventType ContainerID string Config *ContainerConfig LogStream <-chan LogEntry }
type FilterFunc ¶
type FilterFunc func(entry interface{}) bool
type JsonMessage ¶
type JsonMessage struct { Command string `json:"cmd"` Channel string `json:"chan,omitempty"` Query map[string]string `json:"query,omitempty"` Logs []LogEntry `json:"logs,omitempty"` Containers []*ContainerConfig `json:"containers,omitempty"` Channels []string `json:"channels,omitempty"` Count int `json:"count,omitempty"` ScrollID int `json:"scrollID,omitempty"` }
JsonMessage is response via client/server
Basic Command is Here:
(client)channels: RetrieveLogs channel information (client)connect: RetrieveLogs logs and keep listening (client)disconnect: Stop receive update (client)logs: Get old logs (server)channels: Channel information (server)old-logs: Log requested (server)update: New arrival logs (server)close: Channel is closed
type LogEntry ¶
type LogEntry struct { Type LogEventType `json:"t"` Content interface{} `json:"c"` // StructLogEntry or StatEntry }
type LogEventType ¶
type LogEventType string
const ( StatLogEvent LogEventType = "s" StructLogEvent LogEventType = "l" TraceLogEvent LogEventType = "t" MetricsLogEvent LogEventType = "m" )
type LogStore ¶
type LogStore struct {
// contains filtered or unexported fields
}
func NewLogStore ¶
func NewLogStore(connections *ClientConnections) *LogStore
func (*LogStore) ConnectToDocker ¶
func (*LogStore) RegisterContainer ¶
func (ls *LogStore) RegisterContainer(cc *ContainerConfig)
type Option ¶
type Option struct { Direction Direction Match FilterFunc }
type ReceivedEvent ¶
type ReceivedEvent struct { Type EventType ChannelName string Logs []LogEntry ScrollID int Channels []string Containers []*ContainerConfig }
ReceivedEvent is record of DummyReceiver
func (ReceivedEvent) String ¶
func (r ReceivedEvent) String() string
type Receiver ¶
type Receiver interface { ReceiveLogUpdate(channelName string, logs []LogEntry, scrollID int) ReceiveOldLogs(channelName string, logs []LogEntry, scrollID int) ReceiveChannelUpdate(channels []string, containers []*ContainerConfig) }
Receiver is struct to interface physical connection and this library
type SerializedString ¶
type SerializedString string
func (SerializedString) MarshalJSON ¶
func (s SerializedString) MarshalJSON() ([]byte, error)
type StructLogEntry ¶
type StructLogEntry struct { TraceID string `json:"tid"` SpanID string `json:"sid"` Timestamp Timestamp `json:"ts"` Severity Severity `json:"s"` Log SerializedString `json:"l"` }
type WebSocketConnection ¶
type WebSocketConnection struct {
// contains filtered or unexported fields
}
func (WebSocketConnection) ReceiveChannelUpdate ¶
func (c WebSocketConnection) ReceiveChannelUpdate(channels []string, containers []*ContainerConfig)
func (WebSocketConnection) ReceiveLogUpdate ¶
func (c WebSocketConnection) ReceiveLogUpdate(channelName string, logs []LogEntry, scrollID int)
func (WebSocketConnection) ReceiveOldLogs ¶
func (c WebSocketConnection) ReceiveOldLogs(channelName string, logs []LogEntry, scrollID int)
func (WebSocketConnection) Wait ¶
func (c WebSocketConnection) Wait()
Source Files
¶
Click to show internal directories.
Click to hide internal directories.