pull logs and events better than aggregate events from multiple channels

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-02-09 16:51:48 +01:00
parent 17c26e81ff
commit a4b003ecfa
No known key found for this signature in database
GPG key ID: 9858809D6F8F6E7E
10 changed files with 145 additions and 111 deletions

View file

@ -65,10 +65,8 @@ type CreateOptions struct {
// StartOptions group options of the Start API
type StartOptions struct {
// Attach will attach to container and pipe stdout/stderr to LogConsumer
Attach LogConsumer
// Listener will get notified on container events
Listener chan ContainerExited
// Attach will attach to service containers and pipe stdout/stderr to channel
Attach chan ContainerEvent
}
// UpOptions group options of the Up API
@ -185,11 +183,21 @@ type Stack struct {
// LogConsumer is a callback to process log messages from services
type LogConsumer interface {
Log(service, container, message string)
Status(service, container, message string)
Status(service, container, msg string)
}
// ContainerExited let us know a Container exited
type ContainerExited struct {
Service string
Status int
// ContainerEvent notify an event has been collected on Source container implementing Service
type ContainerEvent struct {
Type int
Source string
Service string
Line string
ExitCode int
}
const (
// ContainerEventLog is a ContainerEvent of type log. Line is set
ContainerEventLog = iota
// ContainerEventExit is a ContainerEvent of type exit. ExitCode is set
ContainerEventExit
)