Example #1
0
// newEncoder - instantiate a new encoder
func newEncoder(k, m uint8) (encoder, *probe.Error) {
	e := encoder{}
	params, err := encoding.ValidateParams(k, m)
	if err != nil {
		return encoder{}, probe.NewError(err)
	}
	e.encoder = encoding.NewErasure(params)
	e.k = k
	e.m = m
	return e, nil
}
Example #2
0
// newEncoder - instantiate a new encoder
func newEncoder(k, m uint8, technique string) (encoder, *probe.Error) {
	e := encoder{}
	t, err := getErasureTechnique(technique)
	if err != nil {
		return encoder{}, err.Trace()
	}
	{
		params, err := encoding.ValidateParams(k, m, t)
		if err != nil {
			return encoder{}, probe.NewError(err)
		}
		e.encoder = encoding.NewErasure(params)
		e.k = k
		e.m = m
		e.technique = t
		return e, nil
	}
}
Example #3
0
// NewEncoder - instantiate a new encoder
func NewEncoder(k, m uint8, technique string) (Encoder, error) {
	errParams := map[string]string{
		"k":         strconv.FormatUint(uint64(k), 10),
		"m":         strconv.FormatUint(uint64(m), 10),
		"technique": technique,
	}
	e := encoder{}
	t, err := getErasureTechnique(technique)
	if err != nil {
		return nil, iodine.New(err, errParams)
	}
	params, err := encoding.ValidateParams(k, m, t)
	if err != nil {
		return nil, iodine.New(err, errParams)
	}
	e.encoder = encoding.NewErasure(params)
	e.k = k
	e.m = m
	e.technique = t
	return e, nil
}