func (mj *TaskEvent) MarshalJSONBuf(buf fflib.EncodingBuffer) error { if mj == nil { buf.WriteString("null") return nil } var err error var obj []byte _ = obj _ = err buf.WriteString(`{"type":`) fflib.WriteJsonString(buf, string(mj.Type)) buf.WriteString(`,"hostname":`) fflib.WriteJsonString(buf, string(mj.Hostname)) buf.WriteString(`,"timestamp":`) fflib.AppendFloat(buf, float64(mj.Timestamp), 'g', -1, 32) buf.WriteString(`,"pid":`) fflib.FormatBits2(buf, uint64(mj.PID), 10, mj.PID < 0) buf.WriteString(`,"clock":`) fflib.FormatBits2(buf, uint64(mj.Clock), 10, mj.Clock < 0) buf.WriteString(`,"utcoffset":`) fflib.FormatBits2(buf, uint64(mj.UTCOffset), 10, mj.UTCOffset < 0) buf.WriteString(`,"uuid":`) fflib.WriteJsonString(buf, string(mj.UUID)) buf.WriteString(`,"name":`) fflib.WriteJsonString(buf, string(mj.Name)) buf.WriteString(`,"args":`) fflib.WriteJsonString(buf, string(mj.Args)) buf.WriteString(`,"kwargs":`) fflib.WriteJsonString(buf, string(mj.Kwargs)) buf.WriteString(`,"result":`) fflib.WriteJsonString(buf, string(mj.Result)) buf.WriteString(`,"runtime":`) fflib.AppendFloat(buf, float64(mj.Runtime), 'g', -1, 32) buf.WriteString(`,"retries":`) fflib.FormatBits2(buf, uint64(mj.Retries), 10, mj.Retries < 0) buf.WriteString(`,"eta":`) fflib.FormatBits2(buf, uint64(mj.ETA), 10, mj.ETA < 0) buf.WriteString(`,"exception":`) fflib.WriteJsonString(buf, string(mj.Exception)) buf.WriteString(`,"traceback":`) fflib.WriteJsonString(buf, string(mj.Traceback)) if mj.Terminated { buf.WriteString(`,"terminated":true`) } else { buf.WriteString(`,"terminated":false`) } buf.WriteString(`,"signum":`) /* Interface types must use runtime reflection. type=interface {} kind=interface */ err = buf.Encode(mj.Signum) if err != nil { return err } if mj.Expired { buf.WriteString(`,"expired":true`) } else { buf.WriteString(`,"expired":false`) } buf.WriteByte('}') return nil }
func (mj *WorkerEvent) MarshalJSONBuf(buf fflib.EncodingBuffer) error { if mj == nil { buf.WriteString("null") return nil } var err error var obj []byte _ = obj _ = err buf.WriteString(`{"type":`) fflib.WriteJsonString(buf, string(mj.Type)) buf.WriteString(`,"hostname":`) fflib.WriteJsonString(buf, string(mj.Hostname)) buf.WriteString(`,"timestamp":`) fflib.AppendFloat(buf, float64(mj.Timestamp), 'g', -1, 32) buf.WriteString(`,"pid":`) fflib.FormatBits2(buf, uint64(mj.PID), 10, mj.PID < 0) buf.WriteString(`,"clock":`) fflib.FormatBits2(buf, uint64(mj.Clock), 10, mj.Clock < 0) buf.WriteString(`,"utcoffset":`) fflib.FormatBits2(buf, uint64(mj.UTCOffset), 10, mj.UTCOffset < 0) buf.WriteString(`,"sw_sys":`) fflib.WriteJsonString(buf, string(mj.SWSystem)) buf.WriteString(`,"sw_ver":`) fflib.WriteJsonString(buf, string(mj.SWVersion)) buf.WriteString(`,"loadavg":`) if mj.LoadAverage != nil { buf.WriteString(`[`) for i, v := range mj.LoadAverage { if i != 0 { buf.WriteString(`,`) } fflib.AppendFloat(buf, float64(v), 'g', -1, 32) } buf.WriteString(`]`) } else { buf.WriteString(`null`) } buf.WriteString(`,"freq":`) fflib.AppendFloat(buf, float64(mj.Freq), 'g', -1, 32) buf.WriteString(`,"sw_ident":`) fflib.WriteJsonString(buf, string(mj.SWIdentity)) buf.WriteString(`,"processed":`) fflib.FormatBits2(buf, uint64(mj.Processed), 10, mj.Processed < 0) buf.WriteString(`,"active":`) fflib.FormatBits2(buf, uint64(mj.Active), 10, mj.Active < 0) buf.WriteByte('}') return nil }
func (mj *Pos2D) MarshalJSONBuf(buf fflib.EncodingBuffer) error { if mj == nil { buf.WriteString("null") return nil } var err error var obj []byte _ = obj _ = err buf.WriteString(`{"x":`) fflib.AppendFloat(buf, float64(mj.X), 'g', -1, 64) buf.WriteString(`,"y":`) fflib.AppendFloat(buf, float64(mj.Y), 'g', -1, 64) buf.WriteByte('}') return nil }
func (mj *AgentRender) MarshalJSONBuf(buf fflib.EncodingBuffer) error { if mj == nil { buf.WriteString("null") return nil } var err error var obj []byte _ = obj _ = err buf.WriteString(`{"agent-type":`) fflib.WriteJsonString(buf, string(mj.Type)) buf.WriteString(`,"position":`) { err = mj.Pos2D.MarshalJSONBuf(buf) if err != nil { return err } } buf.WriteString(`,"heading":`) fflib.AppendFloat(buf, float64(mj.Heading), 'g', -1, 64) /* Struct fall back. type=colour.RGB256 kind=struct */ buf.WriteString(`,"colour":`) err = buf.Encode(&mj.Colour) if err != nil { return err } buf.WriteByte('}') return nil }
func (mj *Viewport) MarshalJSONBuf(buf fflib.EncodingBuffer) error { if mj == nil { buf.WriteString("null") return nil } var err error var obj []byte _ = obj _ = err buf.WriteString(`{"width":`) fflib.AppendFloat(buf, float64(mj.Width), 'g', -1, 64) buf.WriteString(`,"height":`) fflib.AppendFloat(buf, float64(mj.Height), 'g', -1, 64) buf.WriteByte('}') return nil }
func (mj *LocGeom) MarshalJSONBuf(buf fflib.EncodingBuffer) error { if mj == nil { buf.WriteString("null") return nil } var err error var obj []byte _ = obj _ = err buf.WriteString(`{"lat":`) fflib.AppendFloat(buf, float64(mj.Lat), 'g', -1, 64) buf.WriteString(`,"lng":`) fflib.AppendFloat(buf, float64(mj.Lon), 'g', -1, 64) buf.WriteByte('}') return nil }
func (mj *Event) MarshalJSONBuf(buf fflib.EncodingBuffer) error { var err error var obj []byte _ = obj _ = err buf.WriteString(`{"host":`) fflib.WriteJsonString(buf, string(mj.Host)) buf.WriteString(`,"service":`) fflib.WriteJsonString(buf, string(mj.Service)) buf.WriteString(`,"sub_service":`) fflib.WriteJsonString(buf, string(mj.SubService)) buf.WriteString(`,"metric":`) fflib.AppendFloat(buf, float64(mj.Metric), 'g', -1, 64) if mj.Tags == nil { buf.WriteString(`,"tags":null`) } else { buf.WriteString(`,"tags":{ `) for key, value := range mj.Tags { fflib.WriteJsonString(buf, key) buf.WriteString(`:`) fflib.WriteJsonString(buf, string(value)) buf.WriteByte(',') } buf.Rewind(1) buf.WriteByte('}') } buf.WriteByte('}') return nil }
func (mj *Incident) MarshalJSONBuf(buf fflib.EncodingBuffer) error { var err error var obj []byte _ = obj _ = err buf.WriteString(`{"event":`) if mj.EventName != nil { buf.WriteString(`"`) { enc := base64.NewEncoder(base64.StdEncoding, buf) enc.Write(reflect.Indirect(reflect.ValueOf(mj.EventName)).Bytes()) enc.Close() } buf.WriteString(`"`) } else { buf.WriteString(`null`) } buf.WriteString(`,"time":`) fflib.FormatBits2(buf, uint64(mj.Time), 10, mj.Time < 0) buf.WriteString(`,"id":`) fflib.FormatBits2(buf, uint64(mj.Id), 10, mj.Id < 0) if mj.Active { buf.WriteString(`,"active":true`) } else { buf.WriteString(`,"active":false`) } buf.WriteString(`,"escalation":`) fflib.WriteJsonString(buf, string(mj.Escalation)) buf.WriteString(`,"description":`) fflib.WriteJsonString(buf, string(mj.Description)) buf.WriteString(`,"policy":`) fflib.WriteJsonString(buf, string(mj.Policy)) buf.WriteString(`,"status":`) fflib.FormatBits2(buf, uint64(mj.Status), 10, mj.Status < 0) buf.WriteString(`,"host":`) fflib.WriteJsonString(buf, string(mj.Host)) buf.WriteString(`,"service":`) fflib.WriteJsonString(buf, string(mj.Service)) buf.WriteString(`,"sub_service":`) fflib.WriteJsonString(buf, string(mj.SubService)) buf.WriteString(`,"metric":`) fflib.AppendFloat(buf, float64(mj.Metric), 'g', -1, 64) if mj.Tags == nil { buf.WriteString(`,"tags":null`) } else { buf.WriteString(`,"tags":{ `) for key, value := range mj.Tags { fflib.WriteJsonString(buf, key) buf.WriteString(`:`) fflib.WriteJsonString(buf, string(value)) buf.WriteByte(',') } buf.Rewind(1) buf.WriteByte('}') } buf.WriteByte('}') return nil }
func (mj *RGB) MarshalJSONBuf(buf fflib.EncodingBuffer) error { if mj == nil { buf.WriteString("null") return nil } var err error var obj []byte _ = obj _ = err buf.WriteString(`{"red":`) fflib.AppendFloat(buf, float64(mj.Red), 'g', -1, 64) buf.WriteString(`,"green":`) fflib.AppendFloat(buf, float64(mj.Green), 'g', -1, 64) buf.WriteString(`,"blue":`) fflib.AppendFloat(buf, float64(mj.Blue), 'g', -1, 64) buf.WriteByte('}') return nil }
func (mj *Event) MarshalJSONBuf(buf fflib.EncodingBuffer) error { if mj == nil { buf.WriteString("null") return nil } var err error var obj []byte _ = obj _ = err buf.WriteString(`{"type":`) fflib.WriteJsonString(buf, string(mj.Type)) buf.WriteString(`,"hostname":`) fflib.WriteJsonString(buf, string(mj.Hostname)) buf.WriteString(`,"timestamp":`) fflib.AppendFloat(buf, float64(mj.Timestamp), 'g', -1, 32) buf.WriteString(`,"pid":`) fflib.FormatBits2(buf, uint64(mj.PID), 10, mj.PID < 0) buf.WriteString(`,"clock":`) fflib.FormatBits2(buf, uint64(mj.Clock), 10, mj.Clock < 0) buf.WriteString(`,"utcoffset":`) fflib.FormatBits2(buf, uint64(mj.UTCOffset), 10, mj.UTCOffset < 0) buf.WriteByte('}') return nil }
func (mj *AnyType) MarshalJSONBuf(buf fflib.EncodingBuffer) error { if mj == nil { buf.WriteString("null") return nil } var err error var obj []byte _ = obj _ = err buf.WriteString(`{"Type":`) fflib.WriteJsonString(buf, string(mj.Type)) buf.WriteString(`,"ID":`) fflib.FormatBits2(buf, uint64(mj.ID), 10, mj.ID < 0) buf.WriteString(`,"ExName":`) fflib.WriteJsonString(buf, string(mj.ExName)) buf.WriteString(`,"TargetFormat":`) fflib.WriteJsonString(buf, string(mj.TargetFormat)) buf.WriteString(`,"TargetQuality":`) fflib.WriteJsonString(buf, string(mj.TargetQuality)) if mj.IsSharpen { buf.WriteString(`,"IsSharpen":true`) } else { buf.WriteString(`,"IsSharpen":false`) } buf.WriteString(`,"Radius":`) fflib.FormatBits2(buf, uint64(mj.Radius), 10, mj.Radius < 0) buf.WriteString(`,"Sigma":`) fflib.FormatBits2(buf, uint64(mj.Sigma), 10, mj.Sigma < 0) buf.WriteString(`,"Channels":`) fflib.WriteJsonString(buf, string(mj.Channels)) buf.WriteString(`,"List":`) { err = mj.List.MarshalJSONBuf(buf) if err != nil { return err } } buf.WriteString(`,"Proportion":`) fflib.AppendFloat(buf, float64(mj.Proportion), 'g', -1, 64) buf.WriteString(`,"Transparency":`) fflib.AppendFloat(buf, float64(mj.Transparency), 'g', -1, 64) buf.WriteString(`,"Position":`) fflib.WriteJsonString(buf, string(mj.Position)) buf.WriteString(`,"X":`) fflib.FormatBits2(buf, uint64(mj.X), 10, mj.X < 0) buf.WriteString(`,"Y":`) fflib.FormatBits2(buf, uint64(mj.Y), 10, mj.Y < 0) buf.WriteString(`,"MinWidth":`) fflib.FormatBits2(buf, uint64(mj.MinWidth), 10, mj.MinWidth < 0) buf.WriteString(`,"MinHeight":`) fflib.FormatBits2(buf, uint64(mj.MinHeight), 10, mj.MinHeight < 0) buf.WriteString(`,"FileBytes":`) if mj.FileBytes != nil { buf.WriteString(`"`) { enc := base64.NewEncoder(base64.StdEncoding, buf) enc.Write(reflect.Indirect(reflect.ValueOf(mj.FileBytes)).Bytes()) enc.Close() } buf.WriteString(`"`) } else { buf.WriteString(`null`) } buf.WriteString(`,"Width":`) fflib.FormatBits2(buf, uint64(mj.Width), 10, mj.Width < 0) buf.WriteString(`,"Height":`) fflib.FormatBits2(buf, uint64(mj.Height), 10, mj.Height < 0) buf.WriteString(`,"Taipe":`) fflib.FormatBits2(buf, uint64(mj.Taipe), 10, mj.Taipe < 0) buf.WriteByte('}') return nil }