mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-19 22:28:45 +05:00
Merge branch 'master' of https://github.com/cgrates/cgrates
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
@@ -192,6 +193,19 @@ type LoadWriter interface {
|
||||
SetTPThresholdCfg([]*utils.TPThresholdCfg) error
|
||||
}
|
||||
|
||||
// NewMarshaler returns the marshaler type selected by mrshlerStr
|
||||
func NewMarshaler(mrshlerStr string) (ms Marshaler, err error) {
|
||||
switch mrshlerStr {
|
||||
case utils.MSGPACK:
|
||||
ms = NewCodecMsgpackMarshaler()
|
||||
case utils.JSON:
|
||||
ms = new(JSONMarshaler)
|
||||
default:
|
||||
err = fmt.Errorf("Unsupported marshaler: %v", mrshlerStr)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type Marshaler interface {
|
||||
Marshal(v interface{}) ([]byte, error)
|
||||
Unmarshal(data []byte, v interface{}) error
|
||||
|
||||
Reference in New Issue
Block a user