mirror of
https://github.com/docker/compose.git
synced 2026-08-04 14:47:40 +00:00
Introduce ergonomic API for handling multiple container events
Signed-off-by: Nikhil Benesch <nikhil.benesch@gmail.com>
This commit is contained in:
parent
5eb314a4ca
commit
ee586e7f1e
5 changed files with 29 additions and 13 deletions
|
|
@ -27,7 +27,10 @@ func (p *noopWriter) Start(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *noopWriter) Event(e Event) {
|
||||
func (p *noopWriter) Event(Event) {
|
||||
}
|
||||
|
||||
func (p *noopWriter) Events([]Event) {
|
||||
}
|
||||
|
||||
func (p *noopWriter) TailMsgf(_ string, _ ...interface{}) {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ func (p *plainWriter) Event(e Event) {
|
|||
fmt.Fprintln(p.out, e.ID, e.Text, e.StatusText)
|
||||
}
|
||||
|
||||
func (p *plainWriter) Events(events []Event) {
|
||||
for _, e := range events {
|
||||
p.Event(e)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *plainWriter) TailMsgf(m string, args ...interface{}) {
|
||||
fmt.Fprintln(p.out, append([]interface{}{m}, args...)...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,12 @@ func (w *ttyWriter) Event(e Event) {
|
|||
}
|
||||
}
|
||||
|
||||
func (w *ttyWriter) Events(events []Event) {
|
||||
for _, e := range events {
|
||||
w.Event(e)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *ttyWriter) TailMsgf(msg string, args ...interface{}) {
|
||||
w.mtx.Lock()
|
||||
defer w.mtx.Unlock()
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ type Writer interface {
|
|||
Start(context.Context) error
|
||||
Stop()
|
||||
Event(Event)
|
||||
Events([]Event)
|
||||
TailMsgf(string, ...interface{})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue