pkg

package
v0.0.10-0...-18cefe0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const RedisTemplateChannel = "redis-template-channel"

RedisTemplateChannel is the default channel in which redis-template will notify/listen that changes have been made upon. Redis doesn't have a watch mechanism we decided to not use polling to implement the redis template, and instead rely upon redis's pub sub feature.

Variables

This section is empty.

Functions

func Listen

func Listen(cfg Config) error

Listen listens to the redis pubsub channel and when it detects any changes it will rerun all of its templates. If the results of the templates have changed then the new templated results is written to disk and the templates action is performed. If the template target is nil then the results are not persisted to disk.

Types

type Config

type Config struct {
	Logger    *log.Logger
	Pool      *redis.Pool
	Templates []Template
	Splay     time.Duration
	Channel   string
}

Config is the configuration that redis-template uses to perform its templating operations.

type Template

type Template struct {
	SourceTemplate *template.Template
	Target         *string
	Action         func() error
}

Template is a processed version of a TemplateFlag. Instead of having a path to a source, it has the contents of the source. Otherwise it is the same as a TemplateFlag.

func (Template) Execute

func (t Template) Execute() error

Execute executes the command

type TemplateFlag

type TemplateFlag struct {
	Source string
	Target string
	Action string
}

TemplateFlag denotes a templating action to perform. It has a source, the template to process. A target, the file to write to. And an action, a command to execute once the template has been updated.

func ParseTemplateFlag

func ParseTemplateFlag(input string) (TemplateFlag, error)

ParseTemplateFlag parses Templates from strings.

func (TemplateFlag) String

func (t TemplateFlag) String() string

String prints the original source of the template flag.

func (TemplateFlag) ToTemplate

func (t TemplateFlag) ToTemplate(p *redis.Pool) (Template, error)

ToTemplate creates a Template from the given redis pool.

type TemplateFlags

type TemplateFlags []TemplateFlag

TemplateFlags is a

func (*TemplateFlags) Set

func (t *TemplateFlags) Set(value string) error

Set implements the flag.Value interface's Set function. It takes a string from the cli arg and has it parsed.

func (*TemplateFlags) String

func (t *TemplateFlags) String() string

String implements flag.Value interface's String function. It is a pretty print form of the flags

Jump to

Keyboard shortcuts

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