github.com/l3x/learn-fp-go@v0.0.0-20171228022418-7639825d0b71/2-design-patterns/ch05-decoration/misc/misc.go (about)

     1  package main
     2  
     3  import (
     4  	"io"
     5  	"os"
     6  	"time"
     7  )
     8  
     9  type Hash interface {
    10  	io.Writer
    11  	Sum(b []byte) []byte
    12  	Reset()
    13  	Size() int
    14  	BlockSize() int
    15  }
    16  
    17  //func ReadAll(r io.Reader) ([]byte, error)
    18  //
    19  //func LoggingReader(r io.Reader) io.Reader
    20  //func LimitingReader(r io.Reader, n int64) io.Reader
    21  //func ErrorInjector(r io.Reader) io.Reader
    22  
    23  // The File interface is implemented by os.File.  App specific
    24  // implementations may add concurrency, caching, stats, fuzzing, etc.
    25  type File interface {
    26  	io.ReaderAt
    27  	io.WriterAt
    28  	io.Closer
    29  	Stat() (os.FileInfo, error)
    30  	Sync() error
    31  	Truncate(size int64) error
    32  }
    33  
    34  type File interface {
    35  	io.Reader
    36  	io.ReaderAt
    37  	io.Seeker
    38  	io.Closer
    39  }
    40  
    41  type File interface {
    42  	io.ReadSeeker
    43  	io.Closer
    44  	Name() string
    45  }
    46  // File is an interface to access the file part of a multipart message.
    47  // Its contents may be either stored in memory or on disk.
    48  // If stored on disk, the File's underlying concrete type will be an *os.File.
    49  type File interface {
    50  	io.Reader
    51  	io.ReaderAt
    52  	io.Seeker
    53  	io.Closer
    54  }
    55  
    56  type Reader interface {
    57  	Read(p []byte) (n int, err error)
    58  }
    59  
    60  type Writer interface {
    61  	Write(p []byte) (n int, err error)
    62  }
    63  
    64  /*
    65  Pick a Product Type:
    66  (1) Appliance
    67  (2) Book
    68  (3) Clothing
    69  3
    70  Pick a Clothing Type:
    71  (1) Men
    72  (2) Women
    73  (3) Children
    74  2
    75  
    76  
    77  
    78  $ go run main.go --help
    79  
    80  Usage of main:
    81  
    82   -proxyPort int
    83  
    84      Server Port (default 8080)
    85  
    86   -serverPort int
    87  
    88      Server Port (default 3000)
    89  
    90  
    91  
    92  INFO  : 13:46:19 Metrics server listening on 127.0.0.1:3000
    93  INFO  : 13:46:20 Proxy listening on 127.0.0.1:8080
    94  DEBUG : 2017/05/17 13:46:30 requester.go:114: makeRequest:
    95  client: 13:46:30 GET http://127.0.0.1:3000
    96  DEBUG : 2017/05/17 13:46:30 metrics.go:66: - randInt: 3081
    97  DEBUG : 2017/05/17 13:46:31 decorator.go:107: backing off...
    98  client: 13:46:31 GET http://web02:3000
    99  DEBUG : 2017/05/17 13:46:31 metrics.go:66: - randInt: 2887
   100  DEBUG : 2017/05/17 13:46:32 decorator.go:107: backing off...
   101  client: 13:46:33 GET http://web03:3000
   102  DEBUG : 2017/05/17 13:46:33 metrics.go:66: - randInt: 1847
   103  DEBUG : 2017/05/17 13:46:34 decorator.go:107: backing off...
   104  INFO  : 13:46:36 FAILURE!
   105  
   106  
   107  DEBUG : 2017/05/17 13:47:30 requester.go:114: makeRequest:
   108  client: 13:47:30 GET http://web03:3000
   109  DEBUG : 2017/05/17 13:47:30 metrics.go:66: - randInt: 1445
   110  DEBUG : 2017/05/17 13:47:31 decorator.go:107: backing off...
   111  client: 13:47:31 GET http://web01:3000
   112  DEBUG : 2017/05/17 13:47:31 metrics.go:66: - randInt: 3237
   113  DEBUG : 2017/05/17 13:47:32 decorator.go:107: backing off...
   114  client: 13:47:33 GET http://web02:3000
   115  DEBUG : 2017/05/17 13:47:33 metrics.go:66: - randInt: 4106
   116  DEBUG : 2017/05/17 13:47:34 decorator.go:107: backing off...
   117  INFO  : 13:47:36 FAILURE!
   118  DEBUG : 2017/05/17 13:47:36 requester.go:65: > 7 requests done.
   119  DEBUG : 2017/05/17 13:47:40 requester.go:114: makeRequest:
   120  client: 13:47:40 GET http://web03:3000
   121  DEBUG : 2017/05/17 13:47:40 metrics.go:66: - randInt: 495
   122  INFO  : 13:47:41 SUCCESS!
   123  DEBUG : 2017/05/17 13:47:41 requester.go:65: > 8 requests done.
   124  
   125  
   126  */
   127  
   128  func main() {
   129  
   130  }