Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
51536738
Unverified
Commit
51536738
authored
Apr 09, 2020
by
Kyle Brandt
Committed by
GitHub
Apr 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BackendPlugins: update to sdk v0.42.0
misc cleanup
parent
712564f6
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
98 additions
and
59 deletions
+98
-59
go.mod
+1
-1
go.sum
+4
-0
pkg/plugins/transform_plugin.go
+2
-3
pkg/services/alerting/conditions/query.go
+2
-1
pkg/services/alerting/conditions/query_test.go
+1
-1
pkg/tsdb/frame_util.go
+0
-13
vendor/github.com/grafana/grafana-plugin-sdk-go/data/arrow.go
+15
-10
vendor/github.com/grafana/grafana-plugin-sdk-go/data/conversion_input.go
+5
-5
vendor/github.com/grafana/grafana-plugin-sdk-go/data/field.go
+42
-15
vendor/github.com/grafana/grafana-plugin-sdk-go/data/frame.go
+25
-9
vendor/modules.txt
+1
-1
No files found.
go.mod
View file @
51536738
...
...
@@ -30,7 +30,7 @@ require (
github.com/gorilla/websocket v1.4.1
github.com/gosimple/slug v1.4.2
github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4
github.com/grafana/grafana-plugin-sdk-go v0.
39
.0
github.com/grafana/grafana-plugin-sdk-go v0.
42
.0
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd
github.com/hashicorp/go-plugin v1.2.2
github.com/hashicorp/go-version v1.1.0
...
...
go.sum
View file @
51536738
...
...
@@ -135,6 +135,10 @@ github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4 h1:SP
github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4/go.mod h1:nc0XxBzjeGcrMltCDw269LoWF9S8ibhgxolCdA1R8To=
github.com/grafana/grafana-plugin-sdk-go v0.39.0 h1:tPP83HeY9gN4q8O3tYka1vd82OQ/3CFdwx4QeEhJ0Qc=
github.com/grafana/grafana-plugin-sdk-go v0.39.0/go.mod h1:xRhfTHl+Dkqf2Py6Lr4pcHBC5pm8/N+IwPJ0R/iAHMM=
github.com/grafana/grafana-plugin-sdk-go v0.40.1-0.20200409163705-fd66aee09a52 h1:WEfl8G9uHk31r3pnAmsK+NRcHGpXnXauWmbhic3KuVU=
github.com/grafana/grafana-plugin-sdk-go v0.40.1-0.20200409163705-fd66aee09a52/go.mod h1:xRhfTHl+Dkqf2Py6Lr4pcHBC5pm8/N+IwPJ0R/iAHMM=
github.com/grafana/grafana-plugin-sdk-go v0.42.0 h1:8oiAQa/uABBFT70GDAv3BnqHfdMOxy/P8SzYVURJH6Y=
github.com/grafana/grafana-plugin-sdk-go v0.42.0/go.mod h1:xRhfTHl+Dkqf2Py6Lr4pcHBC5pm8/N+IwPJ0R/iAHMM=
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd h1:rNuUHR+CvK1IS89MMtcF0EpcVMZtjKfPRp4MEmt/aTs=
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI=
github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY=
...
...
pkg/plugins/transform_plugin.go
View file @
51536738
...
...
@@ -7,7 +7,6 @@ import (
"path"
"strconv"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/simplejson"
...
...
@@ -198,7 +197,7 @@ func (s *transformCallback) QueryData(ctx context.Context, req *pluginv2.QueryDa
if
err
!=
nil
{
return
nil
,
err
}
encFrame
,
err
:=
data
.
MarshalArrow
(
frame
)
encFrame
,
err
:=
frame
.
MarshalArrow
(
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -207,7 +206,7 @@ func (s *transformCallback) QueryData(ctx context.Context, req *pluginv2.QueryDa
if
res
.
Meta
!=
nil
{
b
,
err
:=
res
.
Meta
.
MarshalJSON
()
if
err
!=
nil
{
s
.
logger
.
Error
(
"failed to mar
hs
al json metadata"
,
err
)
s
.
logger
.
Error
(
"failed to mar
sh
al json metadata"
,
err
)
}
pRes
.
JsonMeta
=
b
}
...
...
pkg/services/alerting/conditions/query.go
View file @
51536738
...
...
@@ -7,6 +7,7 @@ import (
gocontext
"context"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/null"
"github.com/grafana/grafana/pkg/components/simplejson"
...
...
@@ -173,7 +174,7 @@ func (c *QueryCondition) executeQuery(context *alerting.EvalContext, timeRange *
useDataframes
:=
v
.
Dataframes
!=
nil
&&
(
v
.
Series
==
nil
||
len
(
v
.
Series
)
==
0
)
if
useDataframes
{
// convert the dataframes to tsdb.TimeSeries
frames
,
err
:=
tsdb
.
FramesFromByt
es
(
v
.
Dataframes
)
frames
,
err
:=
data
.
UnmarshalArrowFram
es
(
v
.
Dataframes
)
if
err
!=
nil
{
return
nil
,
errutil
.
Wrap
(
"tsdb.HandleRequest() failed to unmarshal arrow dataframes from bytes"
,
err
)
}
...
...
pkg/services/alerting/conditions/query_test.go
View file @
51536738
...
...
@@ -198,7 +198,7 @@ func (ctx *queryConditionTestContext) exec() (*alerting.ConditionResult, error)
}
if
ctx
.
frame
!=
nil
{
bFrame
,
err
:=
data
.
MarshalArrow
(
ctx
.
frame
)
bFrame
,
err
:=
ctx
.
frame
.
MarshalArrow
(
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/tsdb/frame_util.go
View file @
51536738
...
...
@@ -94,16 +94,3 @@ func FrameToSeriesSlice(frame *data.Frame) (TimeSeriesSlice, error) {
return
seriesSlice
,
nil
}
// FramesFromBytes returns a data.Frame slice from marshalled arrow dataframes.
func
FramesFromBytes
(
bFrames
[][]
byte
)
([]
*
data
.
Frame
,
error
)
{
frames
:=
make
([]
*
data
.
Frame
,
len
(
bFrames
))
for
i
,
bFrame
:=
range
bFrames
{
var
err
error
frames
[
i
],
err
=
data
.
UnmarshalArrow
(
bFrame
)
if
err
!=
nil
{
return
nil
,
err
}
}
return
frames
,
nil
}
vendor/github.com/grafana/grafana-plugin-sdk-go/data/arrow.go
View file @
51536738
...
...
@@ -17,7 +17,7 @@ import (
// MarshalArrow converts the Frame to an arrow table and returns a byte
// representation of that table.
func
MarshalArrow
(
f
*
Frame
)
([]
byte
,
error
)
{
func
(
f
*
Frame
)
MarshalArrow
(
)
([]
byte
,
error
)
{
arrowFields
,
err
:=
buildArrowFields
(
f
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -640,8 +640,8 @@ func populateFrameFields(fR *ipc.FileReader, nullable []bool, frame *Frame) erro
return
nil
}
// UnmarshalArrow
converts a byte representation of an arrow table to a Frame
func
UnmarshalArrow
(
b
[]
byte
)
(
*
Frame
,
error
)
{
// UnmarshalArrow
Frame converts a byte representation of an arrow table to a Frame.
func
UnmarshalArrow
Frame
(
b
[]
byte
)
(
*
Frame
,
error
)
{
fB
:=
filebuffer
.
New
(
b
)
fR
,
err
:=
ipc
.
NewFileReader
(
fB
)
if
err
!=
nil
{
...
...
@@ -693,12 +693,15 @@ func toJSONString(val interface{}) (string, error) {
return
string
(
b
),
nil
}
// BytesSliceToFrames decodes a slice of encoded Arrow frames to a slice of *Frame.
func
BytesSliceToFrames
(
bFrames
[][]
byte
)
([]
*
Frame
,
error
)
{
frames
:=
make
([]
*
Frame
,
len
(
bFrames
))
// UnmarshalArrowFrames decodes a slice of Arrow encoded frames to Frames ([]*Frame) by calling
// the UnmarshalArrow function on each encoded frame.
// If an error occurs Frames will be nil.
// See Frames.UnMarshalArrow() for the inverse operation.
func
UnmarshalArrowFrames
(
bFrames
[][]
byte
)
(
Frames
,
error
)
{
frames
:=
make
(
Frames
,
len
(
bFrames
))
var
err
error
for
i
,
encodedFrame
:=
range
bFrames
{
frames
[
i
],
err
=
UnmarshalArrow
(
encodedFrame
)
frames
[
i
],
err
=
UnmarshalArrow
Frame
(
encodedFrame
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -706,12 +709,14 @@ func BytesSliceToFrames(bFrames [][]byte) ([]*Frame, error) {
return
frames
,
nil
}
// FramesToBytesSlice encodes a slice of Frames into a slice of []byte.
func
FramesToBytesSlice
(
frames
[]
*
Frame
)
([][]
byte
,
error
)
{
// MarshalArrow encodes Frames into a slice of []byte using *Frame's MarshalArrow method on each Frame.
// If an error occurs [][]byte will be nil.
// See UnmarshalArrowFrames for the inverse operation.
func
(
frames
Frames
)
MarshalArrow
()
([][]
byte
,
error
)
{
bs
:=
make
([][]
byte
,
len
(
frames
))
var
err
error
for
i
,
frame
:=
range
frames
{
bs
[
i
],
err
=
MarshalArrow
(
frame
)
bs
[
i
],
err
=
frame
.
MarshalArrow
(
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
vendor/github.com/grafana/grafana-plugin-sdk-go/data/conversion_input.go
View file @
51536738
...
...
@@ -46,16 +46,16 @@ func NewFrameInputConverter(fieldConvs []FieldConverter, rowLen int) (*FrameInpu
// Converter is not nil, then the Converter function is called before setting the value (otherwise Frame.Set is called directly).
// If an error is returned from the Converter function this function returns that error.
// Like Frame.Set and Field.Set, it will panic if fieldIdx or rowIdx are out of range.
func
(
f
cb
*
FrameInputConverter
)
Set
(
fieldIdx
,
rowIdx
int
,
val
interface
{})
error
{
if
f
cb
.
fieldConverters
[
fieldIdx
]
.
Converter
==
nil
{
f
cb
.
Frame
.
Set
(
fieldIdx
,
rowIdx
,
val
)
func
(
f
ic
*
FrameInputConverter
)
Set
(
fieldIdx
,
rowIdx
int
,
val
interface
{})
error
{
if
f
ic
.
fieldConverters
[
fieldIdx
]
.
Converter
==
nil
{
f
ic
.
Frame
.
Set
(
fieldIdx
,
rowIdx
,
val
)
return
nil
}
convertedVal
,
err
:=
f
cb
.
fieldConverters
[
fieldIdx
]
.
Converter
(
val
)
convertedVal
,
err
:=
f
ic
.
fieldConverters
[
fieldIdx
]
.
Converter
(
val
)
if
err
!=
nil
{
return
err
}
f
cb
.
Frame
.
Set
(
fieldIdx
,
rowIdx
,
convertedVal
)
f
ic
.
Frame
.
Set
(
fieldIdx
,
rowIdx
,
convertedVal
)
return
nil
}
...
...
vendor/github.com/grafana/grafana-plugin-sdk-go/data/field.go
View file @
51536738
...
...
@@ -8,23 +8,41 @@ import (
)
// Field represents a typed column of data within a Frame.
// The data in the Field is a not exported, so methods on the Field are used to to manipulate its data.
//
// A Field is essentially a slice of various types with extra properties and methods.
// See NewField() for supported types.
//
// The slice data in the Field is a not exported, so methods on the Field are used to to manipulate its data.
type
Field
struct
{
Name
string
// Name is default identifer of the field. The name does not have to be unique, but the combination
// of name and Labels should be unique for proper behavior in all situations.
Name
string
// Labels is an optional set of key=value pairs that in addition to the name, should uniquely
// identify a Field within a Frame.
Labels
Labels
// Config is optional display configuration information for Grafana
Config
*
FieldConfig
// vector is the unexported values. it is unexported so we can change the underlying structure without
// major breaking changes.
vector
vector
Labels
Labels
}
// Fields is a slice of Field pointers.
type
Fields
[]
*
Field
// NewField returns a instance of *Field.
// NewField returns a instance of *Field.
Supported types for values are:
//
// Supported types for values are: []int8, []*int8, []int16, []*int16, []int32, []*int32, []int64, []*int64,
// []uint8, []*uint8, []uint16, []*uint16, []uint32, []*uint32, []uint64, []*uint64,
// []float32, []*float32, []float64, []*float64,
// []string, []*string, []bool, []*bool, []time.Time, and []*time.Time.
// Integers:
// []int8, []*int8, []int16, []*int16, []int32, []*int32, []int64, []*int64
// Unsigned Integers:
// []uint8, []*uint8, []uint16, []*uint16, []uint32, []*uint32, []uint64, []*uint64
// Floats:
// []float32, []*float32, []float64, []*float64
// String, Bool, and Time:
// []string, []*string, []bool, []*bool, []time.Time, and []*time.Time.
//
// If an unsupported values type is passed, NewField will panic.
func
NewField
(
name
string
,
labels
Labels
,
values
interface
{})
*
Field
{
...
...
@@ -172,17 +190,21 @@ func NewField(name string, labels Labels, values interface{}) *Field {
}
// Set sets the Field's value at index idx to val.
// It will panic if idx is out of range.
// It will panic if idx is out of range or if
// the underlying type of val does not match the element type of the Field.
func
(
f
*
Field
)
Set
(
idx
int
,
val
interface
{})
{
f
.
vector
.
Set
(
idx
,
val
)
}
// Append appends element i to the Field.
func
(
f
*
Field
)
Append
(
i
interface
{})
{
f
.
vector
.
Append
(
i
)
// Append appends element e to the Field.
// it will panic if the underlying type of e does not match the element type of the Field.
func
(
f
*
Field
)
Append
(
e
interface
{})
{
f
.
vector
.
Append
(
e
)
}
// Extend extends the Field length by i.
// Consider using Frame.Extend() when possible since all Fields within
// a Frame need to be of the same length before marshalling and transmission.
func
(
f
*
Field
)
Extend
(
i
int
)
{
f
.
vector
.
Extend
(
i
)
}
...
...
@@ -198,7 +220,7 @@ func (f *Field) Len() int {
return
f
.
vector
.
Len
()
}
// Type returns the
underlying primitive type of the Field
.
// Type returns the
FieldType of the Field, which indicates what type of slice it is
.
func
(
f
*
Field
)
Type
()
FieldType
{
return
f
.
vector
.
Type
()
}
...
...
@@ -228,12 +250,17 @@ func (f *Field) Nullable() bool {
return
f
.
Type
()
.
Nullable
()
}
// FloatAt returns a float64 at the specified index idx.
// FloatAt returns a float64 at the specified index idx
for all supported Field types
.
// It will panic if idx is out of range.
// If the Field type is numeric and the value at idx is nil, NaN is returned. Precision may be lost on large numbers.
//
// If the Field type is numeric and the value at idx is nil, NaN is returned.
// Precision may be lost on large numbers.
//
// If the Field type is a bool then 0 is return if false or nil, and 1 if true.
//
// If the Field type is time.Time, then the millisecond epoch representation of the time
// is returned, or NaN is the value is nil.
//
// If the Field type is a string, then strconv.ParseFloat is called on it and will return
// an error if ParseFloat errors. If the value is nil, NaN is returned.
func
(
f
*
Field
)
FloatAt
(
idx
int
)
(
float64
,
error
)
{
...
...
vendor/github.com/grafana/grafana-plugin-sdk-go/data/frame.go
View file @
51536738
...
...
@@ -20,18 +20,33 @@ import (
"github.com/olekukonko/tablewriter"
)
// Frame represents a columnar storage with optional labels.
// Each Field in Fields represents a column, all Fields
// must be of the same the length.
// Frame is a columnar data structure where each column is a Field.
//
// Each Field is well typed by its FieldType and supports optional Labels.
//
// A Frame is a general data container for Grafana. A Frame can be table data
// or time series data depending on its content and field types.
type
Frame
struct
{
Name
string
// Name is used in some Grafana visualizations.
Name
string
// Fields are the columns of a frame.
// All Fields must be of the same the length when marshalling the Frame for transmission.
Fields
[]
*
Field
RefID
string
Meta
*
FrameMeta
Warnings
[]
Warning
// RefID is a property that can be set to match a Frame to its orginating query
RefID
string
// Meta is metadata about the Frame, and includes space for custom metadata.
Meta
*
FrameMeta
Warnings
[]
Warning
// TODO: Remove, will be replaced with FrameMeta.Notices.
}
// Frames is a slice of Frame pointers.
// It is the main data container within a backend.DataResponse.
type
Frames
[]
*
Frame
// AppendRow adds a new row to the Frame by appending to each element of vals to
// the corresponding Field in the data.
// The Frame's Fields must be initalized or AppendRow will panic.
...
...
@@ -188,7 +203,8 @@ func (f *Frame) CopyAt(fieldIdx int, rowIdx int) interface{} {
}
// Set set the val to the specified fieldIdx and rowIdx.
// It will panic if either the fieldIdx or rowIdx are out of range.
// It will panic if either the fieldIdx or rowIdx are out of range or
// if the underlying type of val does not match the element type of the Field.
func
(
f
*
Frame
)
Set
(
fieldIdx
int
,
rowIdx
int
,
val
interface
{})
{
f
.
Fields
[
fieldIdx
]
.
vector
.
Set
(
rowIdx
,
val
)
}
...
...
@@ -255,7 +271,7 @@ func (f *Frame) SetFieldNames(names ...string) error {
return
nil
}
// FrameTestCompareOptions returns go-cmp testing options to allow testing of Frame equiv
el
nce.
// FrameTestCompareOptions returns go-cmp testing options to allow testing of Frame equiv
ale
nce.
// Since the data within a Frame's Fields is not exported, this function allows the unexported
// values to be tested.
// The intent is to only use this for testing.
...
...
vendor/modules.txt
View file @
51536738
...
...
@@ -175,7 +175,7 @@ github.com/gosimple/slug
## explicit
github.com/grafana/grafana-plugin-model/go/datasource
github.com/grafana/grafana-plugin-model/go/renderer
# github.com/grafana/grafana-plugin-sdk-go v0.
39
.0
# github.com/grafana/grafana-plugin-sdk-go v0.
42
.0
## explicit
github.com/grafana/grafana-plugin-sdk-go/backend/grpcplugin
github.com/grafana/grafana-plugin-sdk-go/data
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment