github.com/uber/kraken@v0.1.4/lib/backend/noop.go (about)

     1  // Copyright (c) 2016-2019 Uber Technologies, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  package backend
    15  
    16  import (
    17  	"io"
    18  
    19  	"github.com/uber/kraken/core"
    20  	"github.com/uber/kraken/lib/backend/backenderrors"
    21  )
    22  
    23  // NoopNamespace is a special namespace which always returns a NoopClient.
    24  const NoopNamespace = "__noop__"
    25  
    26  // NoopClient is a special Client whose uploads always succeeds and whose blob
    27  // lookups always 404. It is useful for users who want to operate on blobs that
    28  // will be temporarily stored in the origin cluster and not backed up in remote
    29  // storage.
    30  type NoopClient struct{}
    31  
    32  // Stat always returns ErrBlobNotFound.
    33  func (c NoopClient) Stat(namespace, name string) (*core.BlobInfo, error) {
    34  	return nil, backenderrors.ErrBlobNotFound
    35  }
    36  
    37  // Upload always returns nil.
    38  func (c NoopClient) Upload(namespace, name string, src io.Reader) error {
    39  	return nil
    40  }
    41  
    42  // Download always returns ErrBlobNotFound.
    43  func (c NoopClient) Download(namespace, name string, dst io.Writer) error {
    44  	return backenderrors.ErrBlobNotFound
    45  }
    46  
    47  // List always returns nil.
    48  func (c NoopClient) List(prefix string, opts ...ListOption) (*ListResult, error) {
    49  	return nil, nil
    50  }