github.com/packtpublishing/learning-functional-programming-in-go@v0.0.0-20230130084745-8b849f6d58c4/Chapter06/04_onion/src/domain/domain.go (about)

     1  package domain
     2  
     3  const (
     4  	GoogleCloudBucket HostProvider = iota
     5  	SourceFlow FlowType = iota
     6  	SinkFlow
     7  )
     8  
     9  type (
    10  	HostProvider int
    11  	FlowType  int
    12  )
    13  
    14  type CloudStorage struct {
    15  	HostProvider HostProvider //Host location for log files, e.g., google cloud bucket
    16  	ProjectId    string       //Project Id for this GCP storage account
    17  	FlowType     FlowType     //source or sink
    18  }
    19  
    20  type LocalRepository interface {
    21  	FileExists(fileName string) (fileExists bool, err error)
    22  }
    23  
    24  type BucketRepository interface {
    25  	List(projectId string) (buckets []Bucket, err error)
    26  	FileExists(fileName string) (fileExists bool, err error)
    27  	DownloadFile(fileName string) (success bool, err error)
    28  	UploadFile(fileName string) (success bool, err error)
    29  }
    30  
    31  type FileRepository interface {
    32  	Store(file File)
    33  	FindById(id int) File
    34  }
    35  
    36  type Bucket struct {
    37  	Name    string `json:"name"`
    38  }
    39  type Buckets struct {
    40  	Buckets []Bucket `json:"buckets"`
    41  }