Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CatalogServicesRegistration ¶
type CatalogServicesRegistration struct { templates.Template // contains filtered or unexported fields }
CatalogServicesRegistration is a custom notifier expected to be used for a template that contains catalogServicesRegistration template function (tmplfunc) and any other tmplfuncs e.g. services tmplfunc.
This notifier only notifies on changes to Catalog Services registration information and once-mode. It suppresses notifications for changes to other tmplfuncs and changes to Catalog Services tag data.
func NewCatalogServicesRegistration ¶
func NewCatalogServicesRegistration(tmpl templates.Template, tmplFuncTotal int) *CatalogServicesRegistration
NewCatalogServicesRegistration creates a new CatalogServicesRegistration notifier.
tmplFuncTotal param: the total number of monitored tmplFuncs in the template. This is the number of monitored tmplfuncs needed for both the catalog-services condition and any module inputs. This number is equivalent to the number of hashicat dependencies.
Examples: - catalog-services: 1 tmplfunc - services-regex: 1 tmplfunc - services-name: len(services) tmplfuncs - consul-kv: 1 tmplfunc
func (*CatalogServicesRegistration) Notify ¶
func (n *CatalogServicesRegistration) Notify(d interface{}) (notify bool)
Notify notifies when Catalog Services registration changes.
Notifications are sent when: A. There is a change in the Catalog Service's dependency ([]*dep.CatalogSnippet)
that is specifically a service _registration_ change.
B. All the dependencies have been received for the first time. This is
regardless of the dependency type that "completes" having received all the dependencies. Note: this is a special notification sent to handle a race condition that causes hanging during once-mode (details below)
Notification are suppressed when:
- There is a change in the Catalog Service's dependency ([]*dep.CatalogSnippet) that is specifically a service _tag_ change.
- Other types of dependencies that are not Catalog Service. For example, Services ([]*dep.HealthService).
Race condition: Once-mode requires a notification when all dependencies are received in order to trigger CTS. It will hang otherwise. This notifier only notifies on Catalog Service registration changes. The dependencies are received by the notifier in any order. Therefore sometimes the last dependency to "complete all dependencies" is a Health Service change, which can lead to no notification even though once-mode requires a notification when all dependencies are received. Resolved by sending a special notification for once-mode. Bullet B above.
func (*CatalogServicesRegistration) Override ¶ added in v0.5.0
func (n *CatalogServicesRegistration) Override()
type ConsulKV ¶ added in v0.4.0
ConsulKV is a custom notifier expected to be used for a template that contains consulKVNotifier template function.
This notifier only notifies on changes to Consul KV pairs and once-mode. It suppresses notifications for changes to other tmplfuncs.
func NewConsulKV ¶ added in v0.4.0
NewConsulKV creates a new ConsulKVNotifier.
tmplFuncTotal param: the total number of monitored tmplFuncs in the template. This is the number of monitored tmplfuncs needed for both the consul-kv condition and any module inputs. This number is equivalent to the number of hashicat dependencies.
Examples: - consul-kv: 1 tmplfunc - services-regex: 1 tmplfunc - services-name: len(services) tmplfuncs
func (*ConsulKV) Notify ¶ added in v0.4.0
Notify notifies when a Consul KV pair or set of pairs changes.
Notifications are sent when: A. There is a change in the Consul KV dependency for a single key
pair (recurse=false) where the pair is returned (*dep.KeyPair)
B. There is a change in the Consul KV dependency for a set of key pairs (recurse=true)
where a list of key pairs is returned ([]*dep.KeyPair)
C. All the dependencies have been received for the first time. This is
regardless of the dependency type that "completes" having received all the dependencies.
Notification are suppressed when:
- Other types of dependencies that are not Consul KV. For example, Services ([]*dep.HealthService).
type Overrider ¶ added in v0.5.0
type Overrider interface {
Override()
}
Overrider is short-term solution to override the notifier's once value and send a notification (depending on the condition) if once is not complete (i.e. true)
This handles an edge-case with the Create Task API where pre-existing dependencies don't cause Notify() for newly created tasks which causes hanging or potentially an extra trigger depending on the condition type. https://github.com/hashicorp/consul-terraform-sync/issues/704
type Services ¶ added in v0.5.0
Services is a custom notifier expected to be used for a template that contains {{ service }} or {{ servicesRegex }} template function (tmplfuncs) for the condition and any other tmplfuncs for module inputs
This notifier only notifies on changes to services instances information and once-mode. It suppresses notifications for changes to other tmplfuncs.
func NewServices ¶ added in v0.5.0
NewServices creates a new Services notifier.
tmplFuncTotal param: the total number of monitored tmplFuncs in the template. This is the number of monitored tmplfuncs needed for both the services condition and any module inputs. This number is equivalent to the number of hashicat dependencies.
Examples: - services-regex: 1 tmplfunc - services-name: len(services) tmplfuncs - consul-kv: 1 tmplfunc
type SuppressNotification ¶ added in v0.4.0
SuppressNotification is a custom notifier expected to be used for tasks that are not triggered by the hcat.watcher and are instead triggered by a separate process.
The watcher is shared by all dynamic tasks as they wait on watcher for dependency changes. On a dependency change, all dynamic tasks are triggered to re-render templates and terraform-apply if there are changes to the template
Non-dynamic tasks, such as scheduled tasks, do not wait on the watcher and therefore should use a SuppressNotification notify to avoid notifying the watcher because it will un-necessarily cause all dynamic tasks to trigger.
func NewSuppressNotification ¶ added in v0.4.0
func NewSuppressNotification(tmpl templates.Template, tmplFuncTotal int) *SuppressNotification
NewSuppressNotification creates a new SuppressNotification notifier.
tmplFuncTotal param: the total number of monitored tmplFuncs in the template. This is the number of monitored tmplfuncs needed for the scheduled task's module inputs. This number is equivalent to the number of hashicat dependencies
Examples: - services-regex: 1 tmplfunc - services-name: len(services) tmplfuncs - consul-kv: 1 tmplfunc
func (*SuppressNotification) Notify ¶ added in v0.4.0
func (n *SuppressNotification) Notify(d interface{}) (notify bool)
Notify suppresses all notifications on any dependency changes. However, it will pass the latest dependency information to the template until the task is triggered by another means.
Once-mode requires a notification when all dependencies are received in order to trigger CTS. Otherwise it will hang.
func (*SuppressNotification) Override ¶ added in v0.5.0
func (n *SuppressNotification) Override()