json

package
v0.0.0-...-ad801e6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjectKeyFilterFn

type ObjectKeyFilterFn func(key string) bool

ObjectKeyFilterFn filters out values associated with keys matching the filter.

type Options

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

Options provide a set of parsing options. TODO(xichen): limit the maximum capacity of each caching array via options. TODO(xichen): limit the maximum capacity of cached value arrays and KV arrays via options.

func NewOptions

func NewOptions() *Options

NewOptions creates a new set of parsing options.

func (*Options) MaxDepth

func (o *Options) MaxDepth() int

MaxDepth returns the maximum depth eligible for parsing.

func (*Options) ObjectKeyFilterFn

func (o *Options) ObjectKeyFilterFn() ObjectKeyFilterFn

ObjectKeyFilterFn returns the object key matching function.

func (*Options) SetMaxDepth

func (o *Options) SetMaxDepth(v int) *Options

SetMaxDepth sets the maximum depth eligible for parsing.

func (*Options) SetObjectKeyFilterFn

func (o *Options) SetObjectKeyFilterFn(v ObjectKeyFilterFn) *Options

SetObjectKeyFilterFn sets the object key matching function.

type Parser

type Parser interface {
	// Parse parses a JSON-encoded value and returns the parse result.
	// The value returned remains valid till the next Parse or ParseBytes call.
	Parse(str string) (*value.Value, error)

	// ParseBytes parses a byte slice and returns the parse result.
	// The value returned remains valid till the next Parse or ParseBytes call.
	ParseBytes(b []byte) (*value.Value, error)
}

Parser parses JSON-encoded values.

func NewParser

func NewParser(opts *Options) Parser

NewParser creates a JSON parser.

type ParserPool

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

ParserPool is a value pool.

func NewParserPool

func NewParserPool(opts *ParserPoolOptions) *ParserPool

NewParserPool creates a new pool.

func (*ParserPool) Get

func (p *ParserPool) Get() Parser

Get gets a value from the pool.

func (*ParserPool) Init

func (p *ParserPool) Init(alloc func() Parser)

Init initializes the pool.

func (*ParserPool) Put

func (p *ParserPool) Put(v Parser)

Put returns a value to pool.

type ParserPoolConfiguration

type ParserPoolConfiguration struct {
	// The size of the pool.
	Size *int `yaml:"size"`

	// The watermark configuration.
	Watermark ParserPoolWatermarkConfiguration `yaml:"watermark"`
}

ParserPoolConfiguration contains pool configuration.

func (*ParserPoolConfiguration) NewPoolOptions

func (c *ParserPoolConfiguration) NewPoolOptions(
	instrumentOpts instrument.Options,
) *ParserPoolOptions

NewPoolOptions creates a new set of pool options.

type ParserPoolOptions

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

ParserPoolOptions provide a set of options for the value pool.

func NewParserPoolOptions

func NewParserPoolOptions() *ParserPoolOptions

NewParserPoolOptions create a new set of value pool options.

func (*ParserPoolOptions) InstrumentOptions

func (o *ParserPoolOptions) InstrumentOptions() instrument.Options

InstrumentOptions returns the instrument options.

func (*ParserPoolOptions) RefillHighWatermark

func (o *ParserPoolOptions) RefillHighWatermark() float64

RefillHighWatermark returns the high watermark for stop refilling the pool.

func (*ParserPoolOptions) RefillLowWatermark

func (o *ParserPoolOptions) RefillLowWatermark() float64

RefillLowWatermark returns the low watermark for refilling the pool.

func (*ParserPoolOptions) SetInstrumentOptions

func (o *ParserPoolOptions) SetInstrumentOptions(v instrument.Options) *ParserPoolOptions

SetInstrumentOptions sets the instrument options.

func (*ParserPoolOptions) SetRefillHighWatermark

func (o *ParserPoolOptions) SetRefillHighWatermark(v float64) *ParserPoolOptions

SetRefillHighWatermark sets the high watermark for refilling the pool.

func (*ParserPoolOptions) SetRefillLowWatermark

func (o *ParserPoolOptions) SetRefillLowWatermark(v float64) *ParserPoolOptions

SetRefillLowWatermark sets the low watermark for refilling the pool.

func (*ParserPoolOptions) SetSize

func (o *ParserPoolOptions) SetSize(v int) *ParserPoolOptions

SetSize sets the pool size.

func (*ParserPoolOptions) Size

func (o *ParserPoolOptions) Size() int

Size returns pool size.

type ParserPoolWatermarkConfiguration

type ParserPoolWatermarkConfiguration struct {
	// The low watermark to start refilling the pool, if zero none.
	RefillLowWatermark float64 `yaml:"low" validate:"min=0.0,max=1.0"`

	// The high watermark to stop refilling the pool, if zero none.
	RefillHighWatermark float64 `yaml:"high" validate:"min=0.0,max=1.0"`
}

ParserPoolWatermarkConfiguration contains watermark configuration for pools.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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