Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2a270e8f
Commit
2a270e8f
authored
Mar 10, 2017
by
Karol Kraśkiewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update influxdb to v1.1.1 and change client to v2
parent
0ea3e9a2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
424 additions
and
48 deletions
+424
-48
Godeps.json
Godeps/Godeps.json
+11
-6
LICENSES
Godeps/LICENSES
+28
-0
monitoring.go
test/e2e/monitoring.go
+1
-1
LICENSE_OF_DEPENDENCIES.md
...github.com/influxdata/influxdb/LICENSE_OF_DEPENDENCIES.md
+3
-7
README.md
vendor/github.com/influxdata/influxdb/client/README.md
+29
-9
influxdb.go
vendor/github.com/influxdata/influxdb/client/influxdb.go
+48
-13
client.go
vendor/github.com/influxdata/influxdb/client/v2/client.go
+0
-0
udp.go
vendor/github.com/influxdata/influxdb/client/v2/udp.go
+112
-0
inline_fnv.go
vendor/github.com/influxdata/influxdb/models/inline_fnv.go
+27
-0
inline_strconv_parse.go
...ub.com/influxdata/influxdb/models/inline_strconv_parse.go
+38
-0
points.go
vendor/github.com/influxdata/influxdb/models/points.go
+0
-0
rows.go
vendor/github.com/influxdata/influxdb/models/rows.go
+1
-3
statistic.go
vendor/github.com/influxdata/influxdb/models/statistic.go
+40
-0
time.go
vendor/github.com/influxdata/influxdb/models/time.go
+31
-8
bytes.go
vendor/github.com/influxdata/influxdb/pkg/escape/bytes.go
+51
-1
strings.go
vendor/github.com/influxdata/influxdb/pkg/escape/strings.go
+4
-0
No files found.
Godeps/Godeps.json
View file @
2a270e8f
...
@@ -1622,18 +1622,23 @@
...
@@ -1622,18 +1622,23 @@
},
},
{
{
"ImportPath"
:
"github.com/influxdata/influxdb/client"
,
"ImportPath"
:
"github.com/influxdata/influxdb/client"
,
"Comment"
:
"v0.12.2"
,
"Comment"
:
"v1.1.1"
,
"Rev"
:
"383332daed5595926c235f250b11433f67229c35"
"Rev"
:
"e47cf1f2e83a02443d7115c54f838be8ee959644"
},
{
"ImportPath"
:
"github.com/influxdata/influxdb/client/v2"
,
"Comment"
:
"v1.1.1"
,
"Rev"
:
"e47cf1f2e83a02443d7115c54f838be8ee959644"
},
},
{
{
"ImportPath"
:
"github.com/influxdata/influxdb/models"
,
"ImportPath"
:
"github.com/influxdata/influxdb/models"
,
"Comment"
:
"v
0.12.2
"
,
"Comment"
:
"v
1.1.1
"
,
"Rev"
:
"
383332daed5595926c235f250b11433f67229c35
"
"Rev"
:
"
e47cf1f2e83a02443d7115c54f838be8ee959644
"
},
},
{
{
"ImportPath"
:
"github.com/influxdata/influxdb/pkg/escape"
,
"ImportPath"
:
"github.com/influxdata/influxdb/pkg/escape"
,
"Comment"
:
"v
0.12.2
"
,
"Comment"
:
"v
1.1.1
"
,
"Rev"
:
"
383332daed5595926c235f250b11433f67229c35
"
"Rev"
:
"
e47cf1f2e83a02443d7115c54f838be8ee959644
"
},
},
{
{
"ImportPath"
:
"github.com/jmespath/go-jmespath"
,
"ImportPath"
:
"github.com/jmespath/go-jmespath"
,
...
...
Godeps/LICENSES
View file @
2a270e8f
...
@@ -57979,6 +57979,34 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
...
@@ -57979,6 +57979,34 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================================================
================================================================================
=
vendor
/
github
.
com
/
influxdata
/
influxdb
/
client
/
v2
licensed
under
:
=
The
MIT
License
(
MIT
)
Copyright
(
c
)
2013
-
2016
Errplane
Inc
.
Permission
is
hereby
granted
,
free
of
charge
,
to
any
person
obtaining
a
copy
of
this
software
and
associated
documentation
files
(
the
"Software"
),
to
deal
in
the
Software
without
restriction
,
including
without
limitation
the
rights
to
use
,
copy
,
modify
,
merge
,
publish
,
distribute
,
sublicense
,
and
/
or
sell
copies
of
the
Software
,
and
to
permit
persons
to
whom
the
Software
is
furnished
to
do
so
,
subject
to
the
following
conditions
:
The
above
copyright
notice
and
this
permission
notice
shall
be
included
in
all
copies
or
substantial
portions
of
the
Software
.
THE
SOFTWARE
IS
PROVIDED
"AS IS"
,
WITHOUT
WARRANTY
OF
ANY
KIND
,
EXPRESS
OR
IMPLIED
,
INCLUDING
BUT
NOT
LIMITED
TO
THE
WARRANTIES
OF
MERCHANTABILITY
,
FITNESS
FOR
A
PARTICULAR
PURPOSE
AND
NONINFRINGEMENT
.
IN
NO
EVENT
SHALL
THE
AUTHORS
OR
COPYRIGHT
HOLDERS
BE
LIABLE
FOR
ANY
CLAIM
,
DAMAGES
OR
OTHER
LIABILITY
,
WHETHER
IN
AN
ACTION
OF
CONTRACT
,
TORT
OR
OTHERWISE
,
ARISING
FROM
,
OUT
OF
OR
IN
CONNECTION
WITH
THE
SOFTWARE
OR
THE
USE
OR
OTHER
DEALINGS
IN
THE
SOFTWARE
.
=
vendor
/
github
.
com
/
influxdata
/
influxdb
/
LICENSE
ba8146ad9cc2a128209983265136e06a
-
================================================================================
================================================================================
=
vendor
/
github
.
com
/
influxdata
/
influxdb
/
models
licensed
under
:
=
=
vendor
/
github
.
com
/
influxdata
/
influxdb
/
models
licensed
under
:
=
The
MIT
License
(
MIT
)
The
MIT
License
(
MIT
)
test/e2e/monitoring.go
View file @
2a270e8f
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"fmt"
"fmt"
"time"
"time"
influxdb
"github.com/influxdata/influxdb/client"
influxdb
"github.com/influxdata/influxdb/client
/v2
"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
...
...
vendor/github.com/influxdata/influxdb/LICENSE_OF_DEPENDENCIES.md
View file @
2a270e8f
# List
# List
-
bootstrap 3.3.5
[
MIT LICENSE
](
https://github.com/twbs/bootstrap/blob/master/LICENSE
)
-
bootstrap 3.3.5
[
MIT LICENSE
](
https://github.com/twbs/bootstrap/blob/master/LICENSE
)
-
collectd.org
[
ISC LICENSE
](
https://github.com/collectd/go-collectd/blob/master/LICENSE
)
-
collectd.org
[
ISC LICENSE
](
https://github.com/collectd/go-collectd/blob/master/LICENSE
)
-
github.com/armon/go-metrics
[
MIT LICENSE
](
https://github.com/armon/go-metrics/blob/master/LICENSE
)
-
github.com/BurntSushi/toml
[
WTFPL LICENSE
](
https://github.com/BurntSushi/toml/blob/master/COPYING
)
-
github.com/BurntSushi/toml
[
WTFPL LICENSE
](
https://github.com/BurntSushi/toml/blob/master/COPYING
)
-
github.com/bmizerany/pat
[
MIT LICENSE
](
https://github.com/bmizerany/pat#license
)
-
github.com/bmizerany/pat
[
MIT LICENSE
](
https://github.com/bmizerany/pat#license
)
-
github.com/boltdb/bolt
[
MIT LICENSE
](
https://github.com/boltdb/bolt/blob/master/LICENSE
)
-
github.com/boltdb/bolt
[
MIT LICENSE
](
https://github.com/boltdb/bolt/blob/master/LICENSE
)
-
github.com/davecgh/go-spew/spew
[
ISC LICENSE
](
https://github.com/davecgh/go-spew/blob/master/LICENSE
)
-
github.com/dgrijalva/jwt-go
[
MIT LICENSE
](
https://github.com/dgrijalva/jwt-go/blob/master/LICENSE
)
-
github.com/dgryski/go-bits
[
MIT LICENSE
](
https://github.com/dgryski/go-bits/blob/master/LICENSE
)
-
github.com/dgryski/go-bits
[
MIT LICENSE
](
https://github.com/dgryski/go-bits/blob/master/LICENSE
)
-
github.com/dgryski/go-bitstream
[
MIT LICENSE
](
https://github.com/dgryski/go-bitstream/blob/master/LICENSE
)
-
github.com/dgryski/go-bitstream
[
MIT LICENSE
](
https://github.com/dgryski/go-bitstream/blob/master/LICENSE
)
-
github.com/gogo/protobuf/proto
[
BSD LICENSE
](
https://github.com/gogo/protobuf/blob/master/LICENSE
)
-
github.com/gogo/protobuf/proto
[
BSD LICENSE
](
https://github.com/gogo/protobuf/blob/master/LICENSE
)
-
github.com/davecgh/go-spew/spew
[
ISC LICENSE
](
https://github.com/davecgh/go-spew/blob/master/LICENSE
)
-
github.com/golang/snappy
[
BSD LICENSE
](
https://github.com/golang/snappy/blob/master/LICENSE
)
-
github.com/golang/snappy
[
BSD LICENSE
](
https://github.com/golang/snappy/blob/master/LICENSE
)
-
github.com/hashicorp/go-msgpack
[
BSD LICENSE
](
https://github.com/hashicorp/go-msgpack/blob/master/LICENSE
)
-
github.com/hashicorp/raft
[
MPL LICENSE
](
https://github.com/hashicorp/raft/blob/master/LICENSE
)
-
github.com/hashicorp/raft-boltdb
[
MOZILLA PUBLIC LICENSE
](
https://github.com/hashicorp/raft-boltdb/blob/master/LICENSE
)
-
github.com/influxdata/usage-client
[
MIT LICENSE
](
https://github.com/influxdata/usage-client/blob/master/LICENSE.txt
)
-
github.com/influxdata/usage-client
[
MIT LICENSE
](
https://github.com/influxdata/usage-client/blob/master/LICENSE.txt
)
-
github.com/jwilder/encoding
[
MIT LICENSE
](
https://github.com/jwilder/encoding/blob/master/LICENSE
)
-
github.com/jwilder/encoding
[
MIT LICENSE
](
https://github.com/jwilder/encoding/blob/master/LICENSE
)
-
github.com/kimor79/gollectd
[
BSD LICENSE
](
https://github.com/kimor79/gollectd/blob/master/LICENSE
)
-
github.com/kimor79/gollectd
[
BSD LICENSE
](
https://github.com/kimor79/gollectd/blob/master/LICENSE
)
-
github.com/paulbellamy/ratecounter
[
MIT LICENSE
](
https://github.com/paulbellamy/ratecounter/blob/master/LICENSE
)
-
github.com/paulbellamy/ratecounter
[
MIT LICENSE
](
https://github.com/paulbellamy/ratecounter/blob/master/LICENSE
)
-
github.com/peterh/liner
[
MIT LICENSE
](
https://github.com/peterh/liner/blob/master/COPYING
)
-
github.com/peterh/liner
[
MIT LICENSE
](
https://github.com/peterh/liner/blob/master/COPYING
)
-
github.com/rakyll/statik
[
APACHE LICENSE
](
https://github.com/rakyll/statik/blob/master/LICENSE
)
-
github.com/rakyll/statik
[
APACHE LICENSE
](
https://github.com/rakyll/statik/blob/master/LICENSE
)
-
github.com/retailnext/hllpp
[
BSD LICENSE
](
https://github.com/retailnext/hllpp/blob/master/LICENSE
)
-
glyphicons
[
LICENSE
](
http://glyphicons.com/license/
)
-
glyphicons
[
LICENSE
](
http://glyphicons.com/license/
)
-
golang.org/x/crypto
[
BSD LICENSE
](
https://github.com/golang/crypto/blob/master/LICENSE
)
-
golang.org/x/crypto
[
BSD LICENSE
](
https://github.com/golang/crypto/blob/master/LICENSE
)
-
golang.org/x/tools
[
BSD LICENSE
](
https://github.com/golang/tools/blob/master/LICENSE
)
-
gopkg.in/fatih/pool.v2
[
MIT LICENSE
](
https://github.com/fatih/pool/blob/v2.0.0/LICENSE
)
-
jquery 2.1.4
[
MIT LICENSE
](
https://github.com/jquery/jquery/blob/master/LICENSE.txt
)
-
jquery 2.1.4
[
MIT LICENSE
](
https://github.com/jquery/jquery/blob/master/LICENSE.txt
)
-
react 0.13.3
[
BSD LICENSE
](
https://github.com/facebook/react/blob/master/LICENSE
)
-
react 0.13.3
[
BSD LICENSE
](
https://github.com/facebook/react/blob/master/LICENSE
)
vendor/github.com/influxdata/influxdb/client/README.md
View file @
2a270e8f
...
@@ -26,7 +26,7 @@ Though not necessary for experimentation, you may want to create a new user
...
@@ -26,7 +26,7 @@ Though not necessary for experimentation, you may want to create a new user
and authenticate the connection to your database.
and authenticate the connection to your database.
For more information please check out the
For more information please check out the
[
Admin Docs
](
https://docs.influxdata.com/influxdb/
v0.10/administration
)
.
[
Admin Docs
](
https://docs.influxdata.com/influxdb/
latest/administration/
)
.
For the impatient, you can create a new admin user _bubba_ by firing off the
For the impatient, you can create a new admin user _bubba_ by firing off the
[
InfluxDB CLI
](
https://github.com/influxdata/influxdb/blob/master/cmd/influx/main.go
)
.
[
InfluxDB CLI
](
https://github.com/influxdata/influxdb/blob/master/cmd/influx/main.go
)
.
...
@@ -49,10 +49,8 @@ the configuration below.
...
@@ -49,10 +49,8 @@ the configuration below.
package
main
package
main
import
(
import
(
"net/url"
"fmt"
"log"
"log"
"
os
"
"
time
"
"github.com/influxdata/influxdb/client/v2"
"github.com/influxdata/influxdb/client/v2"
)
)
...
@@ -70,17 +68,17 @@ func main() {
...
@@ -70,17 +68,17 @@ func main() {
Username
:
username
,
Username
:
username
,
Password
:
password
,
Password
:
password
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalln
(
"Error: "
,
err
)
log
.
Fatalln
(
"Error: "
,
err
)
}
}
// Create a new point batch
// Create a new point batch
bp
,
err
:=
client
.
NewBatchPoints
(
client
.
BatchPointsConfig
{
bp
,
err
:=
client
.
NewBatchPoints
(
client
.
BatchPointsConfig
{
Database
:
MyDB
,
Database
:
MyDB
,
Precision
:
"s"
,
Precision
:
"s"
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalln
(
"Error: "
,
err
)
log
.
Fatalln
(
"Error: "
,
err
)
}
}
...
@@ -93,11 +91,11 @@ func main() {
...
@@ -93,11 +91,11 @@ func main() {
"user"
:
46.6
,
"user"
:
46.6
,
}
}
pt
,
err
:=
client
.
NewPoint
(
"cpu_usage"
,
tags
,
fields
,
time
.
Now
())
pt
,
err
:=
client
.
NewPoint
(
"cpu_usage"
,
tags
,
fields
,
time
.
Now
())
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalln
(
"Error: "
,
err
)
log
.
Fatalln
(
"Error: "
,
err
)
}
}
bp
.
AddPoint
(
pt
)
bp
.
AddPoint
(
pt
)
// Write the batch
// Write the batch
...
@@ -257,6 +255,28 @@ func WriteUDP() {
...
@@ -257,6 +255,28 @@ func WriteUDP() {
}
}
```
```
### Point Splitting
The UDP client now supports splitting single points that exceed the configured
payload size. The logic for processing each point is listed here, starting with
an empty payload.
1.
If adding the point to the current (non-empty) payload would exceed the
configured size, send the current payload. Otherwise, add it to the current
payload.
1.
If the point is smaller than the configured size, add it to the payload.
1.
If the point has no timestamp, just try to send the entire point as a single
UDP payload, and process the next point.
1.
Since the point has a timestamp, re-use the existing measurement name,
tagset, and timestamp and create multiple new points by splitting up the
fields. The per-point length will be kept close to the configured size,
staying under it if possible. This does mean that one large field, maybe a
long string, could be sent as a larger-than-configured payload.
The above logic attempts to respect configured payload sizes, but not sacrifice
any data integrity. Points without a timestamp can't be split, as that may
cause fields to have differing timestamps when processed by the server.
## Go Docs
## Go Docs
Please refer to
Please refer to
...
...
vendor/github.com/influxdata/influxdb/client/influxdb.go
View file @
2a270e8f
...
@@ -181,7 +181,7 @@ func (c *Client) Query(q Query) (*Response, error) {
...
@@ -181,7 +181,7 @@ func (c *Client) Query(q Query) (*Response, error) {
}
}
u
.
RawQuery
=
values
.
Encode
()
u
.
RawQuery
=
values
.
Encode
()
req
,
err
:=
http
.
NewRequest
(
"
GE
T"
,
u
.
String
(),
nil
)
req
,
err
:=
http
.
NewRequest
(
"
POS
T"
,
u
.
String
(),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -387,22 +387,31 @@ func (c *Client) Ping() (time.Duration, string, error) {
...
@@ -387,22 +387,31 @@ func (c *Client) Ping() (time.Duration, string, error) {
// Structs
// Structs
// Message represents a user message.
type
Message
struct
{
Level
string
`json:"level,omitempty"`
Text
string
`json:"text,omitempty"`
}
// Result represents a resultset returned from a single statement.
// Result represents a resultset returned from a single statement.
type
Result
struct
{
type
Result
struct
{
Series
[]
models
.
Row
Series
[]
models
.
Row
Err
error
Messages
[]
*
Message
Err
error
}
}
// MarshalJSON encodes the result into JSON.
// MarshalJSON encodes the result into JSON.
func
(
r
*
Result
)
MarshalJSON
()
([]
byte
,
error
)
{
func
(
r
*
Result
)
MarshalJSON
()
([]
byte
,
error
)
{
// Define a struct that outputs "error" as a string.
// Define a struct that outputs "error" as a string.
var
o
struct
{
var
o
struct
{
Series
[]
models
.
Row
`json:"series,omitempty"`
Series
[]
models
.
Row
`json:"series,omitempty"`
Err
string
`json:"error,omitempty"`
Messages
[]
*
Message
`json:"messages,omitempty"`
Err
string
`json:"error,omitempty"`
}
}
// Copy fields to output struct.
// Copy fields to output struct.
o
.
Series
=
r
.
Series
o
.
Series
=
r
.
Series
o
.
Messages
=
r
.
Messages
if
r
.
Err
!=
nil
{
if
r
.
Err
!=
nil
{
o
.
Err
=
r
.
Err
.
Error
()
o
.
Err
=
r
.
Err
.
Error
()
}
}
...
@@ -413,8 +422,9 @@ func (r *Result) MarshalJSON() ([]byte, error) {
...
@@ -413,8 +422,9 @@ func (r *Result) MarshalJSON() ([]byte, error) {
// UnmarshalJSON decodes the data into the Result struct
// UnmarshalJSON decodes the data into the Result struct
func
(
r
*
Result
)
UnmarshalJSON
(
b
[]
byte
)
error
{
func
(
r
*
Result
)
UnmarshalJSON
(
b
[]
byte
)
error
{
var
o
struct
{
var
o
struct
{
Series
[]
models
.
Row
`json:"series,omitempty"`
Series
[]
models
.
Row
`json:"series,omitempty"`
Err
string
`json:"error,omitempty"`
Messages
[]
*
Message
`json:"messages,omitempty"`
Err
string
`json:"error,omitempty"`
}
}
dec
:=
json
.
NewDecoder
(
bytes
.
NewBuffer
(
b
))
dec
:=
json
.
NewDecoder
(
bytes
.
NewBuffer
(
b
))
...
@@ -424,6 +434,7 @@ func (r *Result) UnmarshalJSON(b []byte) error {
...
@@ -424,6 +434,7 @@ func (r *Result) UnmarshalJSON(b []byte) error {
return
err
return
err
}
}
r
.
Series
=
o
.
Series
r
.
Series
=
o
.
Series
r
.
Messages
=
o
.
Messages
if
o
.
Err
!=
""
{
if
o
.
Err
!=
""
{
r
.
Err
=
errors
.
New
(
o
.
Err
)
r
.
Err
=
errors
.
New
(
o
.
Err
)
}
}
...
@@ -487,17 +498,36 @@ func (r *Response) Error() error {
...
@@ -487,17 +498,36 @@ func (r *Response) Error() error {
return
nil
return
nil
}
}
// duplexReader reads responses and writes it to another writer while
// satisfying the reader interface.
type
duplexReader
struct
{
r
io
.
Reader
w
io
.
Writer
}
func
(
r
*
duplexReader
)
Read
(
p
[]
byte
)
(
n
int
,
err
error
)
{
n
,
err
=
r
.
r
.
Read
(
p
)
if
err
==
nil
{
r
.
w
.
Write
(
p
[
:
n
])
}
return
n
,
err
}
// ChunkedResponse represents a response from the server that
// ChunkedResponse represents a response from the server that
// uses chunking to stream the output.
// uses chunking to stream the output.
type
ChunkedResponse
struct
{
type
ChunkedResponse
struct
{
dec
*
json
.
Decoder
dec
*
json
.
Decoder
duplex
*
duplexReader
buf
bytes
.
Buffer
}
}
// NewChunkedResponse reads a stream and produces responses from the stream.
// NewChunkedResponse reads a stream and produces responses from the stream.
func
NewChunkedResponse
(
r
io
.
Reader
)
*
ChunkedResponse
{
func
NewChunkedResponse
(
r
io
.
Reader
)
*
ChunkedResponse
{
dec
:=
json
.
NewDecoder
(
r
)
resp
:=
&
ChunkedResponse
{}
dec
.
UseNumber
()
resp
.
duplex
=
&
duplexReader
{
r
:
r
,
w
:
&
resp
.
buf
}
return
&
ChunkedResponse
{
dec
:
dec
}
resp
.
dec
=
json
.
NewDecoder
(
resp
.
duplex
)
resp
.
dec
.
UseNumber
()
return
resp
}
}
// NextResponse reads the next line of the stream and returns a response.
// NextResponse reads the next line of the stream and returns a response.
...
@@ -507,8 +537,13 @@ func (r *ChunkedResponse) NextResponse() (*Response, error) {
...
@@ -507,8 +537,13 @@ func (r *ChunkedResponse) NextResponse() (*Response, error) {
if
err
==
io
.
EOF
{
if
err
==
io
.
EOF
{
return
nil
,
nil
return
nil
,
nil
}
}
return
nil
,
err
// A decoding error happened. This probably means the server crashed
// and sent a last-ditch error message to us. Ensure we have read the
// entirety of the connection to get any remaining error text.
io
.
Copy
(
ioutil
.
Discard
,
r
.
duplex
)
return
nil
,
errors
.
New
(
strings
.
TrimSpace
(
r
.
buf
.
String
()))
}
}
r
.
buf
.
Reset
()
return
&
response
,
nil
return
&
response
,
nil
}
}
...
@@ -551,7 +586,7 @@ func (p *Point) MarshalJSON() ([]byte, error) {
...
@@ -551,7 +586,7 @@ func (p *Point) MarshalJSON() ([]byte, error) {
// MarshalString renders string representation of a Point with specified
// MarshalString renders string representation of a Point with specified
// precision. The default precision is nanoseconds.
// precision. The default precision is nanoseconds.
func
(
p
*
Point
)
MarshalString
()
string
{
func
(
p
*
Point
)
MarshalString
()
string
{
pt
,
err
:=
models
.
NewPoint
(
p
.
Measurement
,
p
.
Tags
,
p
.
Fields
,
p
.
Time
)
pt
,
err
:=
models
.
NewPoint
(
p
.
Measurement
,
models
.
NewTags
(
p
.
Tags
)
,
p
.
Fields
,
p
.
Time
)
if
err
!=
nil
{
if
err
!=
nil
{
return
"# ERROR: "
+
err
.
Error
()
+
" "
+
p
.
Measurement
return
"# ERROR: "
+
err
.
Error
()
+
" "
+
p
.
Measurement
}
}
...
...
vendor/github.com/influxdata/influxdb/client/v2/client.go
0 → 100644
View file @
2a270e8f
This diff is collapsed.
Click to expand it.
vendor/github.com/influxdata/influxdb/client/v2/udp.go
0 → 100644
View file @
2a270e8f
package
client
import
(
"fmt"
"io"
"net"
"time"
)
const
(
// UDPPayloadSize is a reasonable default payload size for UDP packets that
// could be travelling over the internet.
UDPPayloadSize
=
512
)
// UDPConfig is the config data needed to create a UDP Client
type
UDPConfig
struct
{
// Addr should be of the form "host:port"
// or "[ipv6-host%zone]:port".
Addr
string
// PayloadSize is the maximum size of a UDP client message, optional
// Tune this based on your network. Defaults to UDPPayloadSize.
PayloadSize
int
}
// NewUDPClient returns a client interface for writing to an InfluxDB UDP
// service from the given config.
func
NewUDPClient
(
conf
UDPConfig
)
(
Client
,
error
)
{
var
udpAddr
*
net
.
UDPAddr
udpAddr
,
err
:=
net
.
ResolveUDPAddr
(
"udp"
,
conf
.
Addr
)
if
err
!=
nil
{
return
nil
,
err
}
conn
,
err
:=
net
.
DialUDP
(
"udp"
,
nil
,
udpAddr
)
if
err
!=
nil
{
return
nil
,
err
}
payloadSize
:=
conf
.
PayloadSize
if
payloadSize
==
0
{
payloadSize
=
UDPPayloadSize
}
return
&
udpclient
{
conn
:
conn
,
payloadSize
:
payloadSize
,
},
nil
}
// Close releases the udpclient's resources.
func
(
uc
*
udpclient
)
Close
()
error
{
return
uc
.
conn
.
Close
()
}
type
udpclient
struct
{
conn
io
.
WriteCloser
payloadSize
int
}
func
(
uc
*
udpclient
)
Write
(
bp
BatchPoints
)
error
{
var
b
=
make
([]
byte
,
0
,
uc
.
payloadSize
)
// initial buffer size, it will grow as needed
var
d
,
_
=
time
.
ParseDuration
(
"1"
+
bp
.
Precision
())
var
delayedError
error
var
checkBuffer
=
func
(
n
int
)
{
if
len
(
b
)
>
0
&&
len
(
b
)
+
n
>
uc
.
payloadSize
{
if
_
,
err
:=
uc
.
conn
.
Write
(
b
);
err
!=
nil
{
delayedError
=
err
}
b
=
b
[
:
0
]
}
}
for
_
,
p
:=
range
bp
.
Points
()
{
p
.
pt
.
Round
(
d
)
pointSize
:=
p
.
pt
.
StringSize
()
+
1
// include newline in size
//point := p.pt.RoundedString(d) + "\n"
checkBuffer
(
pointSize
)
if
p
.
Time
()
.
IsZero
()
||
pointSize
<=
uc
.
payloadSize
{
b
=
p
.
pt
.
AppendString
(
b
)
b
=
append
(
b
,
'\n'
)
continue
}
points
:=
p
.
pt
.
Split
(
uc
.
payloadSize
-
1
)
// account for newline character
for
_
,
sp
:=
range
points
{
checkBuffer
(
sp
.
StringSize
()
+
1
)
b
=
sp
.
AppendString
(
b
)
b
=
append
(
b
,
'\n'
)
}
}
if
len
(
b
)
>
0
{
if
_
,
err
:=
uc
.
conn
.
Write
(
b
);
err
!=
nil
{
return
err
}
}
return
delayedError
}
func
(
uc
*
udpclient
)
Query
(
q
Query
)
(
*
Response
,
error
)
{
return
nil
,
fmt
.
Errorf
(
"Querying via UDP is not supported"
)
}
func
(
uc
*
udpclient
)
Ping
(
timeout
time
.
Duration
)
(
time
.
Duration
,
string
,
error
)
{
return
0
,
""
,
nil
}
vendor/github.com/influxdata/influxdb/models/inline_fnv.go
0 → 100644
View file @
2a270e8f
package
models
// from stdlib hash/fnv/fnv.go
const
(
prime64
=
1099511628211
offset64
=
14695981039346656037
)
// InlineFNV64a is an alloc-free port of the standard library's fnv64a.
type
InlineFNV64a
uint64
func
NewInlineFNV64a
()
InlineFNV64a
{
return
offset64
}
func
(
s
*
InlineFNV64a
)
Write
(
data
[]
byte
)
(
int
,
error
)
{
hash
:=
uint64
(
*
s
)
for
_
,
c
:=
range
data
{
hash
^=
uint64
(
c
)
hash
*=
prime64
}
*
s
=
InlineFNV64a
(
hash
)
return
len
(
data
),
nil
}
func
(
s
*
InlineFNV64a
)
Sum64
()
uint64
{
return
uint64
(
*
s
)
}
vendor/github.com/influxdata/influxdb/models/inline_strconv_parse.go
0 → 100644
View file @
2a270e8f
package
models
import
(
"reflect"
"strconv"
"unsafe"
)
// parseIntBytes is a zero-alloc wrapper around strconv.ParseInt.
func
parseIntBytes
(
b
[]
byte
,
base
int
,
bitSize
int
)
(
i
int64
,
err
error
)
{
s
:=
unsafeBytesToString
(
b
)
return
strconv
.
ParseInt
(
s
,
base
,
bitSize
)
}
// parseFloatBytes is a zero-alloc wrapper around strconv.ParseFloat.
func
parseFloatBytes
(
b
[]
byte
,
bitSize
int
)
(
float64
,
error
)
{
s
:=
unsafeBytesToString
(
b
)
return
strconv
.
ParseFloat
(
s
,
bitSize
)
}
// parseBoolBytes is a zero-alloc wrapper around strconv.ParseBool.
func
parseBoolBytes
(
b
[]
byte
)
(
bool
,
error
)
{
return
strconv
.
ParseBool
(
unsafeBytesToString
(
b
))
}
// unsafeBytesToString converts a []byte to a string without a heap allocation.
//
// It is unsafe, and is intended to prepare input to short-lived functions
// that require strings.
func
unsafeBytesToString
(
in
[]
byte
)
string
{
src
:=
*
(
*
reflect
.
SliceHeader
)(
unsafe
.
Pointer
(
&
in
))
dst
:=
reflect
.
StringHeader
{
Data
:
src
.
Data
,
Len
:
src
.
Len
,
}
s
:=
*
(
*
string
)(
unsafe
.
Pointer
(
&
dst
))
return
s
}
vendor/github.com/influxdata/influxdb/models/points.go
View file @
2a270e8f
This diff is collapsed.
Click to expand it.
vendor/github.com/influxdata/influxdb/models/rows.go
View file @
2a270e8f
package
models
package
models
import
(
import
(
"hash/fnv"
"sort"
"sort"
)
)
...
@@ -11,7 +10,6 @@ type Row struct {
...
@@ -11,7 +10,6 @@ type Row struct {
Tags
map
[
string
]
string
`json:"tags,omitempty"`
Tags
map
[
string
]
string
`json:"tags,omitempty"`
Columns
[]
string
`json:"columns,omitempty"`
Columns
[]
string
`json:"columns,omitempty"`
Values
[][]
interface
{}
`json:"values,omitempty"`
Values
[][]
interface
{}
`json:"values,omitempty"`
Err
error
`json:"err,omitempty"`
}
}
// SameSeries returns true if r contains values for the same series as o.
// SameSeries returns true if r contains values for the same series as o.
...
@@ -21,7 +19,7 @@ func (r *Row) SameSeries(o *Row) bool {
...
@@ -21,7 +19,7 @@ func (r *Row) SameSeries(o *Row) bool {
// tagsHash returns a hash of tag key/value pairs.
// tagsHash returns a hash of tag key/value pairs.
func
(
r
*
Row
)
tagsHash
()
uint64
{
func
(
r
*
Row
)
tagsHash
()
uint64
{
h
:=
fnv
.
New
64a
()
h
:=
NewInlineFNV
64a
()
keys
:=
r
.
tagsKeys
()
keys
:=
r
.
tagsKeys
()
for
_
,
k
:=
range
keys
{
for
_
,
k
:=
range
keys
{
h
.
Write
([]
byte
(
k
))
h
.
Write
([]
byte
(
k
))
...
...
vendor/github.com/influxdata/influxdb/models/statistic.go
0 → 100644
View file @
2a270e8f
package
models
type
Statistic
struct
{
Name
string
`json:"name"`
Tags
map
[
string
]
string
`json:"tags"`
Values
map
[
string
]
interface
{}
`json:"values"`
}
func
NewStatistic
(
name
string
)
Statistic
{
return
Statistic
{
Name
:
name
,
Tags
:
make
(
map
[
string
]
string
),
Values
:
make
(
map
[
string
]
interface
{}),
}
}
// StatisticTags is a map that can be merged with others without causing
// mutations to either map.
type
StatisticTags
map
[
string
]
string
// Merge creates a new map containing the merged contents of tags and t.
// If both tags and the receiver map contain the same key, the value in tags
// is used in the resulting map.
//
// Merge always returns a usable map.
func
(
t
StatisticTags
)
Merge
(
tags
map
[
string
]
string
)
map
[
string
]
string
{
// Add everything in tags to the result.
out
:=
make
(
map
[
string
]
string
,
len
(
tags
))
for
k
,
v
:=
range
tags
{
out
[
k
]
=
v
}
// Only add values from t that don't appear in tags.
for
k
,
v
:=
range
t
{
if
_
,
ok
:=
tags
[
k
];
!
ok
{
out
[
k
]
=
v
}
}
return
out
}
vendor/github.com/influxdata/influxdb/models/time.go
View file @
2a270e8f
...
@@ -9,14 +9,36 @@ import (
...
@@ -9,14 +9,36 @@ import (
"time"
"time"
)
)
const
(
// MinNanoTime is the minumum time that can be represented.
//
// 1677-09-21 00:12:43.145224194 +0000 UTC
//
// The two lowest minimum integers are used as sentinel values. The
// minimum value needs to be used as a value lower than any other value for
// comparisons and another separate value is needed to act as a sentinel
// default value that is unusable by the user, but usable internally.
// Because these two values need to be used for a special purpose, we do
// not allow users to write points at these two times.
MinNanoTime
=
int64
(
math
.
MinInt64
)
+
2
// MaxNanoTime is the maximum time that can be represented.
//
// 2262-04-11 23:47:16.854775806 +0000 UTC
//
// The highest time represented by a nanosecond needs to be used for an
// exclusive range in the shard group, so the maximum time needs to be one
// less than the possible maximum number of nanoseconds representable by an
// int64 so that we don't lose a point at that one time.
MaxNanoTime
=
int64
(
math
.
MaxInt64
)
-
1
)
var
(
var
(
// MaxNanoTime is the maximum time that can be represented via int64 nanoseconds since the epoch.
minNanoTime
=
time
.
Unix
(
0
,
MinNanoTime
)
.
UTC
()
MaxNanoTime
=
time
.
Unix
(
0
,
math
.
MaxInt64
)
.
UTC
()
maxNanoTime
=
time
.
Unix
(
0
,
MaxNanoTime
)
.
UTC
()
// MinNanoTime is the minumum time that can be represented via int64 nanoseconds since the epoch.
MinNanoTime
=
time
.
Unix
(
0
,
math
.
MinInt64
)
.
UTC
()
// ErrTimeOutOfRange gets returned when time is out of the representable range using int64 nanoseconds since the epoch.
// ErrTimeOutOfRange gets returned when time is out of the representable range using int64 nanoseconds since the epoch.
ErrTimeOutOfRange
=
fmt
.
Errorf
(
"time outside range %
s - %s
"
,
MinNanoTime
,
MaxNanoTime
)
ErrTimeOutOfRange
=
fmt
.
Errorf
(
"time outside range %
d - %d
"
,
MinNanoTime
,
MaxNanoTime
)
)
)
// SafeCalcTime safely calculates the time given. Will return error if the time is outside the
// SafeCalcTime safely calculates the time given. Will return error if the time is outside the
...
@@ -24,7 +46,8 @@ var (
...
@@ -24,7 +46,8 @@ var (
func
SafeCalcTime
(
timestamp
int64
,
precision
string
)
(
time
.
Time
,
error
)
{
func
SafeCalcTime
(
timestamp
int64
,
precision
string
)
(
time
.
Time
,
error
)
{
mult
:=
GetPrecisionMultiplier
(
precision
)
mult
:=
GetPrecisionMultiplier
(
precision
)
if
t
,
ok
:=
safeSignedMult
(
timestamp
,
mult
);
ok
{
if
t
,
ok
:=
safeSignedMult
(
timestamp
,
mult
);
ok
{
return
time
.
Unix
(
0
,
t
)
.
UTC
(),
nil
tme
:=
time
.
Unix
(
0
,
t
)
.
UTC
()
return
tme
,
CheckTime
(
tme
)
}
}
return
time
.
Time
{},
ErrTimeOutOfRange
return
time
.
Time
{},
ErrTimeOutOfRange
...
@@ -32,7 +55,7 @@ func SafeCalcTime(timestamp int64, precision string) (time.Time, error) {
...
@@ -32,7 +55,7 @@ func SafeCalcTime(timestamp int64, precision string) (time.Time, error) {
// CheckTime checks that a time is within the safe range.
// CheckTime checks that a time is within the safe range.
func
CheckTime
(
t
time
.
Time
)
error
{
func
CheckTime
(
t
time
.
Time
)
error
{
if
t
.
Before
(
MinNanoTime
)
||
t
.
After
(
M
axNanoTime
)
{
if
t
.
Before
(
minNanoTime
)
||
t
.
After
(
m
axNanoTime
)
{
return
ErrTimeOutOfRange
return
ErrTimeOutOfRange
}
}
return
nil
return
nil
...
@@ -43,7 +66,7 @@ func safeSignedMult(a, b int64) (int64, bool) {
...
@@ -43,7 +66,7 @@ func safeSignedMult(a, b int64) (int64, bool) {
if
a
==
0
||
b
==
0
||
a
==
1
||
b
==
1
{
if
a
==
0
||
b
==
0
||
a
==
1
||
b
==
1
{
return
a
*
b
,
true
return
a
*
b
,
true
}
}
if
a
==
math
.
MinInt64
||
b
==
math
.
MaxInt64
{
if
a
==
MinNanoTime
||
b
==
MaxNanoTime
{
return
0
,
false
return
0
,
false
}
}
c
:=
a
*
b
c
:=
a
*
b
...
...
vendor/github.com/influxdata/influxdb/pkg/escape/bytes.go
View file @
2a270e8f
package
escape
package
escape
import
"bytes"
import
(
"bytes"
"strings"
)
func
Bytes
(
in
[]
byte
)
[]
byte
{
func
Bytes
(
in
[]
byte
)
[]
byte
{
for
b
,
esc
:=
range
Codes
{
for
b
,
esc
:=
range
Codes
{
...
@@ -9,7 +12,54 @@ func Bytes(in []byte) []byte {
...
@@ -9,7 +12,54 @@ func Bytes(in []byte) []byte {
return
in
return
in
}
}
const
escapeChars
=
`," =`
func
IsEscaped
(
b
[]
byte
)
bool
{
for
len
(
b
)
>
0
{
i
:=
bytes
.
IndexByte
(
b
,
'\\'
)
if
i
<
0
{
return
false
}
if
i
+
1
<
len
(
b
)
&&
strings
.
IndexByte
(
escapeChars
,
b
[
i
+
1
])
>=
0
{
return
true
}
b
=
b
[
i
+
1
:
]
}
return
false
}
func
AppendUnescaped
(
dst
,
src
[]
byte
)
[]
byte
{
var
pos
int
for
len
(
src
)
>
0
{
next
:=
bytes
.
IndexByte
(
src
[
pos
:
],
'\\'
)
if
next
<
0
||
pos
+
next
+
1
>=
len
(
src
)
{
return
append
(
dst
,
src
...
)
}
if
pos
+
next
+
1
<
len
(
src
)
&&
strings
.
IndexByte
(
escapeChars
,
src
[
pos
+
next
+
1
])
>=
0
{
if
pos
+
next
>
0
{
dst
=
append
(
dst
,
src
[
:
pos
+
next
]
...
)
}
src
=
src
[
pos
+
next
+
1
:
]
pos
=
0
}
else
{
pos
+=
next
+
1
}
}
return
dst
}
func
Unescape
(
in
[]
byte
)
[]
byte
{
func
Unescape
(
in
[]
byte
)
[]
byte
{
if
len
(
in
)
==
0
{
return
nil
}
if
bytes
.
IndexByte
(
in
,
'\\'
)
==
-
1
{
return
in
}
i
:=
0
i
:=
0
inLen
:=
len
(
in
)
inLen
:=
len
(
in
)
var
out
[]
byte
var
out
[]
byte
...
...
vendor/github.com/influxdata/influxdb/pkg/escape/strings.go
View file @
2a270e8f
...
@@ -20,6 +20,10 @@ func init() {
...
@@ -20,6 +20,10 @@ func init() {
}
}
func
UnescapeString
(
in
string
)
string
{
func
UnescapeString
(
in
string
)
string
{
if
strings
.
IndexByte
(
in
,
'\\'
)
==
-
1
{
return
in
}
for
b
,
esc
:=
range
codesStr
{
for
b
,
esc
:=
range
codesStr
{
in
=
strings
.
Replace
(
in
,
esc
,
b
,
-
1
)
in
=
strings
.
Replace
(
in
,
esc
,
b
,
-
1
)
}
}
...
...
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