Documentation ¶
Index ¶
Examples ¶
Constants ¶
const ( // BYTE .. BYTE = 1.0 // KILOBYTE .. KILOBYTE = 1024 * BYTE // MEGABYTE .. MEGABYTE = 1024 * KILOBYTE )
Variables ¶
var ErrUnidentifiedJason = errors.New("unidentified jason value")
ErrUnidentifiedJason .
Functions ¶
This section is empty.
Types ¶
type ByteType ¶
ByteType represents a pair of key values in which the value represents bytes It converts the value to MB
type Container ¶
type Container struct { Err error // contains filtered or unexported fields }
Container satisfies the DataContainer and error interfaces
func NewContainer ¶
NewContainer returns a new container
type DataContainer ¶
type DataContainer interface { // Returns the list. You should not update this list as it is a shared list and anyone can read from it. // If you append to this list, there is a chance you are not refering to the same underlying array in memory. List() []DataType Len() int String(timestamp time.Time) string // Returns the Err value Error() error }
DataContainer is an interface for holding a list of DataType. I'm aware of the container/list package, which is awesome, but I needed to guard this with a mutex. To iterate over this contaner:
for i := 0; i < d.Len(); i++ { item := d.Get(i) }
func JobResultDataTypes ¶
func JobResultDataTypes(r io.Reader) DataContainer
JobResultDataTypes generates a list of DataType and puts them inside the DataContainer
type DataType ¶
DataType implements Stringer and Marshal/Unmarshal
func FromJason ¶
FromJason returns an instance of DataType from jason value
Example (FloatType) ¶
j, _ := jason.NewValueFromBytes([]byte("666.6")) result, err := FromJason("some float", *j) fmt.Printf("error: %v\n", err) fmt.Printf("Type: %v\n", reflect.TypeOf(result)) r := result.(*FloatType) fmt.Printf("Result key: %s\n", r.Key) fmt.Printf("Result value: %f\n", r.Value) fmt.Printf("String representation: %s\n", result.String())
Output: error: <nil> Type: *datatype.FloatType Result key: some float Result value: 666.600000 String representation: "some float":666.600000
Example (MalformedInput) ¶
j, _ := jason.NewValueFromBytes([]byte(`{malformed object}`)) result, err := FromJason("ignored", *j) fmt.Printf("error: %v\n", err) fmt.Printf("Type: %v\n", reflect.TypeOf(result))
Output: error: unidentified jason value Type: <nil>
Example (StringType) ¶
j, _ := jason.NewValueFromBytes([]byte(`"some string"`)) result, err := FromJason("string key", *j) fmt.Printf("error: %v\n", err) fmt.Printf("Type: %v\n", reflect.TypeOf(result)) r := result.(*StringType) fmt.Printf("Result key: %s\n", r.Key) fmt.Printf("Result value: %s\n", r.Value) fmt.Printf("String representation: %s\n", result.String())
Output: error: <nil> Type: *datatype.StringType Result key: string key Result value: some string String representation: "string key":"some string"
type FloatListType ¶
FloatListType represents a pair of key values that the value is a list of floats
func (FloatListType) String ¶
func (fl FloatListType) String() string
String satisfies the Stringer interface
type GCListType ¶
GCListType represents a pair of key values of GC list info
func (GCListType) String ¶
func (flt GCListType) String() string
String satisfies the Stringer interface
type StringType ¶
StringType represents a pair of key values that the value is a string
func (StringType) String ¶
func (s StringType) String() string
String satisfies the Stringer interface