summaryrefslogtreecommitdiffstats
path: root/back/qver/options.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-03-14 10:13:55 -0400
committerSam Anthony <sam@samanthony.xyz>2026-03-14 10:13:55 -0400
commit7d622695ae19e518fded6aa5fbf001dae4652211 (patch)
treecca62a7c6213c824adc0ad8447ff189cb106fcf0 /back/qver/options.go
parent3b8368d665c8818b84557f54681c5ebab35ba22e (diff)
downloadbuth-7d622695ae19e518fded6aa5fbf001dae4652211.zip
back: add qver package to track qid versions
Diffstat (limited to 'back/qver/options.go')
-rw-r--r--back/qver/options.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/back/qver/options.go b/back/qver/options.go
new file mode 100644
index 0000000..41385ce
--- /dev/null
+++ b/back/qver/options.go
@@ -0,0 +1,32 @@
+package qver
+
+type Option func(*options)
+
+type options struct {
+ parent *Version
+ UpdateFunc
+ state interface{}
+}
+
+func parse(opts ...Option) options {
+ var o options
+ for _, opt := range opts {
+ opt(&o)
+ }
+ return o
+}
+
+// Whenever the version changes, bump the parent's version as well.
+func Parent(p *Version) Option {
+ return func(o *options) {
+ o.parent = p
+ }
+}
+
+// Call f(state) to update the version whenever Version.Get() is called.
+func Update(state interface{}, f UpdateFunc) Option {
+ return func(o *options) {
+ o.UpdateFunc = f
+ o.state = state
+ }
+}