Documentation ¶
Index ¶
- Variables
- func Cancel()
- func GetRow(rows *sql.Rows) ([]string, error)
- func RowsToJson(rows *sql.Rows) []string
- type Generator
- type GeneratorOptions
- type LG
- func (lg *LG) AbortCustomMetrics(keys ...string)
- func (lg *LG) BeginCustomMetrics(keys ...string)
- func (lg *LG) Context() context.Context
- func (lg *LG) EndCustomMetrics(keys ...string) error
- func (lg *LG) EndCustomMetricsWithError(keys ...string) error
- func (lg *LG) RecordRawMetrics(key string, value int64)
- func (lg *LG) SetTickDataFile(f string)
- func (lg *LG) ShouldQuit() bool
- type MarkovChain
- type MarkovPrefix
Constants ¶
This section is empty.
Variables ¶
var (
)Shared across all workers
Functions ¶
func GetRow ¶
sql.Rows.Scan requires pointer args, not sure how to pass that from Lua world, via luar (we can deference a pointer by using '-', not sure how to instruct luar to pass something by pointer). So for now, we can have a helper method that returns a row as an array.
func RowsToJson ¶
Types ¶
type Generator ¶
type Generator struct { Script string ScriptDir string Args []string L *lua.LState LG *LG // contains filtered or unexported fields }
func NewGenerator ¶
type GeneratorOptions ¶
func NewOptions ¶
func NewOptions() *GeneratorOptions
type LG ¶
type LG struct { Id int Concurrency int Map *sync.Map RequestRate int ScriptDir string ScriptArgs *lua.LTable // contains filtered or unexported fields }
func (*LG) AbortCustomMetrics ¶
func (*LG) BeginCustomMetrics ¶
func (*LG) EndCustomMetrics ¶
func (*LG) EndCustomMetricsWithError ¶
func (*LG) RecordRawMetrics ¶
func (*LG) SetTickDataFile ¶
func (*LG) ShouldQuit ¶
type MarkovChain ¶
type MarkovChain struct {
// contains filtered or unexported fields
}
MarkovChain contains a map ("chain") of prefixes to a list of suffixes. A prefix is a string of prefixLen words joined with spaces. A suffix is a single word. A prefix can have multiple suffixes.
func NewMarkovChain ¶
func NewMarkovChain(prefixLen int) *MarkovChain
NewMarkovChain returns a new MarkovChain with prefixes of prefixLen words.
func (*MarkovChain) Build ¶
func (c *MarkovChain) Build()
Build reads text from the provided Reader and parses it into prefixes and suffixes that are stored in MarkovChain.
func (*MarkovChain) Generate ¶
func (c *MarkovChain) Generate(n int) string
Generate returns a string of at most n words generated from MarkovChain.
func (*MarkovChain) GenerateText ¶
func (c *MarkovChain) GenerateText(size int, paraNumWords int) string
GenerateText returns a string of >= given size in bytes, with a para for even N words specified
type MarkovPrefix ¶
type MarkovPrefix []string
MarkovPrefix is a Markov chain prefix of one or more words.
func (MarkovPrefix) Shift ¶
func (p MarkovPrefix) Shift(word string)
Shift removes the first word from the MarkovPrefix and appends the given word.
func (MarkovPrefix) String ¶
func (p MarkovPrefix) String() string
String returns the MarkovPrefix as a string (for use as a map key).