From 72b213352899b0c2cd9175800675183a99046f98 Mon Sep 17 00:00:00 2001 From: Jack Cook Date: Tue, 4 Oct 2022 17:12:22 -0400 Subject: [PATCH] Add option to publish message on object update --- update.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/update.go b/update.go index 647c68d..9894fc8 100644 --- a/update.go +++ b/update.go @@ -13,6 +13,10 @@ import ( // UpdateOptions provides options that may be passed to UpdateWithOptions if // the default behavior of Update needs to be changed. type UpdateOptions struct { + // Notify should be set to true if you would like a message to be published + // to the : channel once this update completes. + Notify bool + // SetZeroValues should be set to true if you would like to update all zero // values in Redis (e.g. empty strings, 0 ints). By default, when creating // a struct to pass to Update, you may not set each value, which is why @@ -211,6 +215,11 @@ func updateInternal(id string, ptr interface{}, opts *UpdateOptions) error { } } + if opts.Notify { + // Publish message if notify is enabled + pip.Publish(ctx, prefix+":"+id, "") + } + // Don't exec if a pipeline was provided to us if opts.Pipeline == nil { if _, err := pip.Exec(ctx); err != nil {