package servers import "time" // getOpts - iterate the inbound Options and return a struct func getOpts(opt ...Option) options { opts := getDefaultOptions() for _, o := range opt { o(&opts) } return opts } // Option - how Options are passed as arguments type Option func(*options) // options = how options are represented type options struct { withLimit int withLiveness time.Duration } func getDefaultOptions() options { return options{ withLimit: 0, withLiveness: 0, } } // WithLimit provides an option to provide a limit. Intentionally allowing // negative integers. If WithLimit < 0, then unlimited results are returned. // If WithLimit == 0, then default limits are used for results. func WithLimit(limit int) Option { return func(o *options) { o.withLimit = limit } } // WithSkipVetForWrite provides an option to allow skipping vet checks to allow // testing lower-level SQL triggers and constraints func WithLiveness(liveness time.Duration) Option { return func(o *options) { o.withLiveness = liveness } }