common

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: Apache-2.0 Imports: 15 Imported by: 8

Documentation

Index

Constants

View Source
const RandomUserAgent = "*"

Variables

View Source
var (
	ErrReadOnly    = core.Error(core.ErrInvalidOperation, "read only")
	ErrInvalidPath = core.Error(core.ErrInvalidOperation, "invalid path")
)
View Source
var Attributes = []string{}/* 135 elements not displayed */

Functions

func CloseAll added in v0.10.0

func CloseAll(logger *zerolog.Logger, closers []io.Closer, msg string)

func CollectFrames added in v0.8.0

func CollectFrames(ctx context.Context, receiver *values.Array, doc drivers.HTMLDocument) error

func DeserializeStyles added in v0.7.0

func DeserializeStyles(input values.String) (*values.Object, error)

func FromHTMLType added in v0.8.0

func FromHTMLType(nt html.NodeType) int

func GetInDocument added in v0.7.0

func GetInDocument(ctx context.Context, doc drivers.HTMLDocument, path []core.Value) (core.Value, error)

func GetInElement added in v0.7.0

func GetInElement(ctx context.Context, el drivers.HTMLElement, path []core.Value) (core.Value, error)

func GetInNode added in v0.7.0

func GetInNode(ctx context.Context, node drivers.HTMLNode, path []core.Value) (core.Value, error)

func GetInPage added in v0.8.0

func GetInPage(ctx context.Context, page drivers.HTMLPage, path []core.Value) (core.Value, error)

func GetUserAgent

func GetUserAgent(val string) string

func IsAttribute

func IsAttribute(name string) bool

func NewIterator added in v0.7.0

func NewIterator(
	node drivers.HTMLElement,
) (core.Iterator, error)

func PathToString added in v0.7.0

func PathToString(path []core.Value) string

func SerializeStyles added in v0.7.0

func SerializeStyles(_ context.Context, styles *values.Object) values.String

func SetInDocument added in v0.7.0

func SetInDocument(ctx context.Context, doc drivers.HTMLDocument, path []core.Value, value core.Value) error

func SetInElement added in v0.7.0

func SetInElement(ctx context.Context, el drivers.HTMLElement, path []core.Value, value core.Value) error

func SetInNode added in v0.7.0

func SetInNode(_ context.Context, _ drivers.HTMLNode, path []core.Value, _ core.Value) error

func SetInPage added in v0.8.0

func SetInPage(ctx context.Context, page drivers.HTMLPage, path []core.Value, value core.Value) error

func ToHTMLType

func ToHTMLType(input int) html.NodeType

Types

type AtomicValue added in v0.8.0

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

AtomicValue represents an atomic value

func NewAtomicValue added in v0.8.0

func NewAtomicValue(value core.Value) *AtomicValue

func (*AtomicValue) Read added in v0.8.0

func (av *AtomicValue) Read() core.Value

Read returns an underlying value. @returns (Value) - Underlying value

func (*AtomicValue) Write added in v0.8.0

func (av *AtomicValue) Write(writer AtomicValueWriter) error

Write sets a new underlying value. If writer fails, the operations gets terminated and an underlying value remains. @param (AtomicValueWriter) - Writer function that receives a current value and returns new one. @returns (Error) - Error if write operation failed

type AtomicValueWriter added in v0.8.0

type AtomicValueWriter func(current core.Value) (core.Value, error)

AtomicValueWriter represents an atomic value writer

type Iterator added in v0.7.0

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

func (*Iterator) Next added in v0.7.0

func (iterator *Iterator) Next(ctx context.Context) (value core.Value, key core.Value, err error)

type LazyValue

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

LazyValue represents a value with late initialization

func NewLazyValue

func NewLazyValue(factory LazyValueFactory) *LazyValue

func (*LazyValue) Mutate added in v0.8.0

func (lv *LazyValue) Mutate(ctx context.Context, mutator func(v core.Value, err error))

Mutate safely mutates an underlying value. Loads a value if it's not ready. Thread safe.

func (*LazyValue) MutateIfReady added in v0.8.0

func (lv *LazyValue) MutateIfReady(mutator func(v core.Value, err error))

MutateIfReady safely mutates an underlying value only if it's ready.

func (*LazyValue) Read

func (lv *LazyValue) Read(ctx context.Context) (core.Value, error)

Read returns an underlying value. Not thread safe. Should not mutated. @returns (Value) - Underlying value if successfully loaded, otherwise error

func (*LazyValue) Ready

func (lv *LazyValue) Ready() bool

Ready indicates whether the value is ready. @returns (Boolean) - Boolean value indicating whether the value is ready.

func (*LazyValue) Reload added in v0.8.0

func (lv *LazyValue) Reload(ctx context.Context)

Reload resets the storage and loads data.

func (*LazyValue) Reset

func (lv *LazyValue) Reset()

Reset resets the storage. Next call of Read will trigger the factory function again.

type LazyValueFactory added in v0.7.0

type LazyValueFactory func(ctx context.Context) (core.Value, error)

LazyValueFactory represents a value initializer

Jump to

Keyboard shortcuts

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