|
|
@@ -33,24 +33,45 @@ type Redundancy interface { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var RedundancyUnion = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[Redundancy]( |
|
|
var RedundancyUnion = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[Redundancy]( |
|
|
|
|
|
(*NoneRedundancy)(nil), |
|
|
(*RepRedundancy)(nil), |
|
|
(*RepRedundancy)(nil), |
|
|
(*ECRedundancy)(nil), |
|
|
(*ECRedundancy)(nil), |
|
|
)), "type") |
|
|
)), "type") |
|
|
|
|
|
|
|
|
|
|
|
type NoneRedundancy struct { |
|
|
|
|
|
serder.Metadata `union:"none"` |
|
|
|
|
|
Type string `json:"type"` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func NewNoneRedundancy() *NoneRedundancy { |
|
|
|
|
|
return &NoneRedundancy{ |
|
|
|
|
|
Type: "none", |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
func (b *NoneRedundancy) Value() (driver.Value, error) { |
|
|
|
|
|
return serder.ObjectToJSONEx[Redundancy](b) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var DefaultRepRedundancy = *NewRepRedundancy(2) |
|
|
|
|
|
|
|
|
type RepRedundancy struct { |
|
|
type RepRedundancy struct { |
|
|
serder.Metadata `union:"rep"` |
|
|
serder.Metadata `union:"rep"` |
|
|
Type string `json:"type"` |
|
|
Type string `json:"type"` |
|
|
|
|
|
RepCount int `json:"repCount"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func NewRepRedundancy() *RepRedundancy { |
|
|
|
|
|
|
|
|
func NewRepRedundancy(repCount int) *RepRedundancy { |
|
|
return &RepRedundancy{ |
|
|
return &RepRedundancy{ |
|
|
Type: "rep", |
|
|
|
|
|
|
|
|
Type: "rep", |
|
|
|
|
|
RepCount: repCount, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
func (b *RepRedundancy) Value() (driver.Value, error) { |
|
|
func (b *RepRedundancy) Value() (driver.Value, error) { |
|
|
return serder.ObjectToJSONEx[Redundancy](b) |
|
|
return serder.ObjectToJSONEx[Redundancy](b) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var DefaultECRedundancy = *NewECRedundancy(2, 3, 1024*1024*5) |
|
|
|
|
|
|
|
|
type ECRedundancy struct { |
|
|
type ECRedundancy struct { |
|
|
serder.Metadata `union:"ec"` |
|
|
serder.Metadata `union:"ec"` |
|
|
Type string `json:"type"` |
|
|
Type string `json:"type"` |
|
|
|