github.com/ipni/storetheindex@v0.8.30/config/mirror.go (about)

     1  package config
     2  
     3  import (
     4  	"github.com/ipni/storetheindex/filestore"
     5  )
     6  
     7  // Mirror configures if, how, and where to store content advertisements data in
     8  // CAR files. The mirror may be readable, writable, both, or neither. If the
     9  // mirror is neither readable or writable, or a storage type is not specified,
    10  // then the mirror is not used.
    11  type Mirror struct {
    12  	// Read specifies to read advertisement content from the Retrieval mirror.
    13  	Read bool
    14  	// Write specifies to write advertisement content to the Storage mirror.
    15  	Write bool
    16  	// Compress specifies how to compress files. One of: "gzip", "none".
    17  	// Defaults to "gzip" if unspecified.
    18  	Compress string
    19  	// Retrieval configures the backing file store for mirror read operations.
    20  	Retrieval filestore.Config
    21  	// Storage configures the backing file store for mirror write operations.
    22  	Storage filestore.Config
    23  }
    24  
    25  // NewMirror returns Mirror with values set to their defaults.
    26  func NewMirror() Mirror {
    27  	return Mirror{
    28  		Compress: "gzip",
    29  	}
    30  }
    31  
    32  // PopulateUnset replaces zero-values in the config with default values.
    33  func (c *Mirror) PopulateUnset() {
    34  	def := NewMirror()
    35  	if c.Compress == "" {
    36  		c.Compress = def.Compress
    37  	}
    38  }