parser

package
v1.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2021 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Overview

Copyright [2019] housepower

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright [2019] housepower

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	Layouts = []string{

		"2006-01-02T15:04:05Z07:00",
		"2006-01-02T15:04:05Z0700",
		"2006-01-02T15:04:05",

		"2006-01-02 15:04:05Z07:00",
		"2006-01-02 15:04:05Z0700",
		"2006-01-02 15:04:05",

		"Mon Jan _2 15:04:05 2006",
		"Mon Jan _2 15:04:05 MST 2006",
		"Mon Jan 02 15:04:05 -0700 2006",
		"02 Jan 06 15:04 MST",
		"02 Jan 06 15:04 -0700",
		"Monday, 02-Jan-06 15:04:05 MST",
		"Mon, 02 Jan 2006 15:04:05 MST",
		"Mon, 02 Jan 2006 15:04:05 -0700",

		"Mon Jan 02 15:04:05 MST 2006",
		"Mon 02 Jan 2006 03:04:05 PM MST",

		"Jan 02, 2006 15:04:05Z07:00",
		"Jan 02, 2006 15:04:05Z0700",
		"Jan 02, 2006 15:04:05",
		"02/Jan/2006 15:04:05 Z07:00",
		"02/Jan/2006 15:04:05 Z0700",
		"02/Jan/2006 15:04:05",

		"2006-01-02",
		"02/01/2006",
		"02/Jan/2006",
		"Jan 02, 2006",
		"Mon Jan 02, 2006",
	}
	Epoch            = time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)
	ErrParseDateTime = errors.Errorf("value doesn't contain DateTime")
)

Functions

func UnixFloat added in v1.5.2

func UnixFloat(sec float64) (t time.Time)

func UnixInt added in v1.8.13

func UnixInt(sec int64) (t time.Time)

Types

type CsvMetric

type CsvMetric struct {
	// contains filtered or unexported fields
}

CsvMetic

func (*CsvMetric) GetArray

func (c *CsvMetric) GetArray(key string, typ int) (val interface{})

GetArray parse an CSV encoded array

func (*CsvMetric) GetDateTime added in v1.5.2

func (c *CsvMetric) GetDateTime(key string, nullable bool) (val interface{})

func (*CsvMetric) GetElasticDateTime

func (c *CsvMetric) GetElasticDateTime(key string, nullable bool) (val interface{})

func (*CsvMetric) GetFloat

func (c *CsvMetric) GetFloat(key string, nullable bool) (val interface{})

GetFloat returns the value as float

func (*CsvMetric) GetInt

func (c *CsvMetric) GetInt(key string, nullable bool) (val interface{})

GetInt returns int

func (*CsvMetric) GetNewKeys added in v1.5.2

func (c *CsvMetric) GetNewKeys(knownKeys *sync.Map, newKeys *sync.Map) bool

func (*CsvMetric) GetString

func (c *CsvMetric) GetString(key string, nullable bool) (val interface{})

GetString get the value as string

type CsvParser

type CsvParser struct {
	// contains filtered or unexported fields
}

CsvParser implementation to parse input from a CSV format per RFC 4180

func (*CsvParser) Parse

func (p *CsvParser) Parse(bs []byte) (metric model.Metric, err error)

Parse extract a list of comma-separated values from the data

type FastjsonMetric

type FastjsonMetric struct {
	// contains filtered or unexported fields
}

func (*FastjsonMetric) GetArray

func (c *FastjsonMetric) GetArray(key string, typ int) (val interface{})

func (*FastjsonMetric) GetDateTime added in v1.5.2

func (c *FastjsonMetric) GetDateTime(key string, nullable bool) (val interface{})

func (*FastjsonMetric) GetElasticDateTime

func (c *FastjsonMetric) GetElasticDateTime(key string, nullable bool) (val interface{})

func (*FastjsonMetric) GetFloat

func (c *FastjsonMetric) GetFloat(key string, nullable bool) (val interface{})

func (*FastjsonMetric) GetInt

func (c *FastjsonMetric) GetInt(key string, nullable bool) (val interface{})

func (*FastjsonMetric) GetNewKeys added in v1.5.2

func (c *FastjsonMetric) GetNewKeys(knownKeys *sync.Map, newKeys *sync.Map) (foundNew bool)

func (*FastjsonMetric) GetString

func (c *FastjsonMetric) GetString(key string, nullable bool) (val interface{})

type FastjsonParser

type FastjsonParser struct {
	// contains filtered or unexported fields
}

FastjsonParser, parser for get data in json format

func (*FastjsonParser) Parse

func (p *FastjsonParser) Parse(bs []byte) (metric model.Metric, err error)

type GjsonMetric

type GjsonMetric struct {
	// contains filtered or unexported fields
}

func (*GjsonMetric) GetArray

func (c *GjsonMetric) GetArray(key string, typ int) (val interface{})

func (*GjsonMetric) GetDateTime added in v1.5.2

func (c *GjsonMetric) GetDateTime(key string, nullable bool) (val interface{})

func (*GjsonMetric) GetElasticDateTime

func (c *GjsonMetric) GetElasticDateTime(key string, nullable bool) (val interface{})

func (*GjsonMetric) GetFloat

func (c *GjsonMetric) GetFloat(key string, nullable bool) (val interface{})

func (*GjsonMetric) GetInt

func (c *GjsonMetric) GetInt(key string, nullable bool) (val interface{})

func (*GjsonMetric) GetNewKeys added in v1.5.2

func (c *GjsonMetric) GetNewKeys(knownKeys *sync.Map, newKeys *sync.Map) bool

func (*GjsonMetric) GetString

func (c *GjsonMetric) GetString(key string, nullable bool) (val interface{})

type GjsonParser

type GjsonParser struct {
	// contains filtered or unexported fields
}

func (*GjsonParser) Parse

func (p *GjsonParser) Parse(bs []byte) (metric model.Metric, err error)

type Parser

type Parser interface {
	Parse(bs []byte) (metric model.Metric, err error)
}

Parse is the Parser interface

type Pool added in v1.5.2

type Pool struct {
	// contains filtered or unexported fields
}

Pool may be used for pooling Parsers for similarly typed JSONs.

func NewParserPool added in v1.5.2

func NewParserPool(name string, csvFormat []string, delimiter string, timezone string) (pp *Pool, err error)

NewParserPool creates a parser pool

func (*Pool) Get added in v1.5.2

func (pp *Pool) Get() Parser

Get returns a Parser from pp.

The Parser must be Put to pp after use.

func (*Pool) ParseDateTime added in v1.5.2

func (pp *Pool) ParseDateTime(key string, val string) (t time.Time, err error)

Assuming that all values of a field of kafka message has the same layout, and layouts of each field are unrelated. Automatically detect the layout from till the first successful detection and reuse that layout forever. Return time in UTC.

func (*Pool) Put added in v1.5.2

func (pp *Pool) Put(p Parser)

Put returns p to pp.

p and objects recursively returned from p cannot be used after p is put into pp.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL