github.com/drone/runner-go@v1.12.0/pipeline/streamer.go (about)

     1  // Copyright 2019 Drone.IO Inc. All rights reserved.
     2  // Use of this source code is governed by the Polyform License
     3  // that can be found in the LICENSE file.
     4  
     5  package pipeline
     6  
     7  import (
     8  	"context"
     9  	"io"
    10  )
    11  
    12  // A Streamer streams the pipeline logs.
    13  type Streamer interface {
    14  	// Stream returns an io.WriteCloser to stream the stdout
    15  	// and stderr of the pipeline step.
    16  	Stream(context.Context, *State, string) io.WriteCloser
    17  }
    18  
    19  // NopStreamer returns a noop streamer.
    20  func NopStreamer() Streamer {
    21  	return new(nopStreamer)
    22  }
    23  
    24  type nopStreamer struct{}
    25  
    26  func (*nopStreamer) Stream(context.Context, *State, string) io.WriteCloser {
    27  	return new(nopWriteCloser)
    28  }
    29  
    30  type nopWriteCloser struct{}
    31  
    32  func (*nopWriteCloser) Close() error                { return nil }
    33  func (*nopWriteCloser) Write(p []byte) (int, error) { return len(p), nil }