Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 7 of 7 for LimitWriter (0.25 sec)

  1. internal/ioutil/ioutil.go

    	return n, err
    }
    
    // Close closes the LimitWriter. It behaves like io.Closer.
    func (w *LimitWriter) Close() error {
    	if closer, ok := w.Writer.(io.Closer); ok {
    		return closer.Close()
    	}
    	return nil
    }
    
    // LimitedWriter takes an io.Writer and returns an ioutil.LimitWriter.
    func LimitedWriter(w io.Writer, skipBytes int64, limit int64) *LimitWriter {
    	return &LimitWriter{w, skipBytes, limit}
    }
    
    Registered: Sun Jun 16 00:44:34 UTC 2024
    - Last Modified: Wed May 22 23:07:14 UTC 2024
    - 10.2K bytes
    - Viewed (0)
  2. pkg/kubelet/util/ioutils/ioutils.go

    limitations under the License.
    */
    
    package ioutils
    
    import "io"
    
    // LimitWriter is a copy of the standard library ioutils.LimitReader,
    // applied to the writer interface.
    // LimitWriter returns a Writer that writes to w
    // but stops with EOF after n bytes.
    // The underlying implementation is a *LimitedWriter.
    func LimitWriter(w io.Writer, n int64) io.Writer { return &LimitedWriter{w, n} }
    
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Mon Jan 16 12:00:49 UTC 2023
    - 1.5K bytes
    - Viewed (0)
  3. src/net/http/cgi/integration_test.go

    type customWriterRecorder struct {
    	w io.Writer
    	*httptest.ResponseRecorder
    }
    
    func (r *customWriterRecorder) Write(p []byte) (n int, err error) {
    	return r.w.Write(p)
    }
    
    type limitWriter struct {
    	w io.Writer
    	n int
    }
    
    func (w *limitWriter) Write(p []byte) (n int, err error) {
    	if len(p) > w.n {
    		p = p[:w.n]
    	}
    	if len(p) > 0 {
    		n, err = w.w.Write(p)
    		w.n -= n
    	}
    	if w.n == 0 {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Nov 07 18:42:44 UTC 2023
    - 5.5K bytes
    - Viewed (0)
  4. pkg/kubelet/util/ioutils/ioutils_test.go

    		t.Run(fmt.Sprintf("inputSize=%d limit=%d writes=%d", test.inputSize, test.limit, test.writeSize), func(t *testing.T) {
    			input := make([]byte, test.inputSize)
    			r.Read(input)
    			output := &bytes.Buffer{}
    			w := LimitWriter(output, test.limit)
    
    			var (
    				err     error
    				written int64
    				n       int
    			)
    			for written < test.inputSize && err == nil {
    				n, err = w.Write(input[written : written+test.writeSize])
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed Sep 11 13:52:28 UTC 2019
    - 2K bytes
    - Viewed (0)
  5. pkg/probe/exec/exec.go

    // from executing a command. Returns the Result status, command output, and
    // errors if any.
    func (pr execProber) Probe(e exec.Cmd) (probe.Result, string, error) {
    	var dataBuffer bytes.Buffer
    	writer := ioutils.LimitWriter(&dataBuffer, maxReadLength)
    
    	e.SetStderr(writer)
    	e.SetStdout(writer)
    	err := e.Start()
    	if err == nil {
    		err = e.Wait()
    	}
    	data := dataBuffer.Bytes()
    
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Tue May 14 08:58:18 UTC 2024
    - 2.2K bytes
    - Viewed (0)
  6. src/go/printer/printer_test.go

    		t.Fatal(err)
    	}
    	if got, want := buf.String(), `<-(<-chan int)(nil)`; got != want {
    		t.Fatalf("got:\n%s\nwant:\n%s\n", got, want)
    	}
    }
    
    type limitWriter struct {
    	remaining int
    	errCount  int
    }
    
    func (l *limitWriter) Write(buf []byte) (n int, err error) {
    	n = len(buf)
    	if n >= l.remaining {
    		n = l.remaining
    		err = io.EOF
    		l.errCount++
    	}
    	l.remaining -= n
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Jun 03 14:56:25 UTC 2024
    - 20.4K bytes
    - Viewed (0)
  7. pkg/kubelet/prober/prober_test.go

    		cmd := []string{"/foo", "bar"}
    		exec := prober.newExecInContainer(ctx, container, containerID, cmd, 0)
    
    		var dataBuffer bytes.Buffer
    		writer := ioutils.LimitWriter(&dataBuffer, int64(limit))
    		exec.SetStderr(writer)
    		exec.SetStdout(writer)
    		err := exec.Start()
    		if err == nil {
    			err = exec.Wait()
    		}
    		actualOutput := dataBuffer.Bytes()
    
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Mon May 01 07:17:35 UTC 2023
    - 9.7K bytes
    - Viewed (0)
Back to top