file

package
v1.2.11 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a wrapper around the file client

func New

func New(filepath string, opts ...Option) (*Client, error)

New returns a new FileClient The filepath can be a local path to a file or a remote http/https location.

func (*Client) Close

func (c *Client) Close()

Close is only meant to fulfill the easykv.ReadWatcher interface. Does nothing.

func (*Client) GetValues

func (c *Client) GetValues(keys []string) (map[string]string, error)

GetValues returns all key-value pairs from the yaml or json file where the keys begins with one of the prefixes specified in the keys array.

func (*Client) WatchPrefix

func (c *Client) WatchPrefix(ctx context.Context, prefix string, opts ...easykv.WatchOption) (uint64, error)

WatchPrefix watches the file for changes with fsnotify. Prefix, keys and waitIndex are only here to implement the StoreClient interface. WatchPrefix is only supported for local files. Remote files over http/https arent supported. Remote filesystems like nfs are also not supported.

type Option added in v1.2.5

type Option func(*Options)

Option configures the file client.

func WithHeaders added in v1.2.5

func WithHeaders(headers map[string]string) Option

WithHeaders sets the headers for the HTTP request made when fetching remote files.

type Options added in v1.2.5

type Options struct {
	Headers map[string]string
}

Options contains all (possibly optional) values that are needed to fetch JSON or YAML files (either locally or remotely).

Jump to

Keyboard shortcuts

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