Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
costaQuanta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
costaQuanta
Commits
a08f277e
Commit
a08f277e
authored
1 month ago
by
Neil-Jocelyn Schark
Browse files
Options
Downloads
Patches
Plain Diff
renamed
parent
3f01751c
No related branches found
No related tags found
No related merge requests found
Pipeline
#272086
passed
1 month ago
Stage: prepare
Stage: build
Stage: lint
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ctrl/internal/core/ports/configWatcher.go
+0
-0
0 additions, 0 deletions
ctrl/internal/core/ports/configWatcher.go
ctrl/internal/infrastructure/interaction/fileWatcher.go
+12
-11
12 additions, 11 deletions
ctrl/internal/infrastructure/interaction/fileWatcher.go
with
12 additions
and
11 deletions
ctrl/internal/core/ports/config
_w
atcher.go
→
ctrl/internal/core/ports/config
W
atcher.go
+
0
−
0
View file @
a08f277e
File moved
This diff is collapsed.
Click to expand it.
ctrl/internal/infrastructure/interaction/
yaml_w
atcher.go
→
ctrl/internal/infrastructure/interaction/
fileW
atcher.go
+
12
−
11
View file @
a08f277e
...
...
@@ -9,8 +9,8 @@ import (
"go.uber.org/zap"
)
// Implement the ConfigWatcher interface for
yaml
configuration files.
type
Yaml
Watcher
struct
{
// Implement the ConfigWatcher interface for configuration files.
type
File
Watcher
struct
{
// This channel is used to communicate with the outside
outgoingChannel
chan
ports
.
ChangeNotification
directoryPathToWatch
string
...
...
@@ -24,26 +24,27 @@ type YamlWatcher struct {
}
// NewYamlWatcher creates a new YamlWatcher instance.
func
NewYamlWatcher
(
logger
*
zap
.
SugaredLogger
)
*
Yaml
Watcher
{
func
NewYamlWatcher
(
logger
*
zap
.
SugaredLogger
)
*
File
Watcher
{
// Create buffered channel. 1024 is just an arbitrary number.
// We expect each notification event to be 32bytes, so 1024 has no meaningful impact to performance.
channel
:=
make
(
chan
ports
.
ChangeNotification
,
1024
)
return
&
Yaml
Watcher
{
logger
:
logger
,
outgoingChannel
:
channel
}
return
&
File
Watcher
{
logger
:
logger
,
outgoingChannel
:
channel
}
}
// ConfigureWatcher configures the watcher with a path and a channel.
func
(
y
*
YamlWatcher
)
ConfigureWatcher
(
path
string
)
{
// ConfigureWatcher configures the watcher with a path and options.
// Options is here used for the file suffixes the watcher should look for.
func
(
y
*
FileWatcher
)
ConfigureWatcher
(
path
string
)
{
y
.
directoryPathToWatch
=
path
}
// GetChannel returns the channel that is used to communicate with the outside.
func
(
y
*
Yaml
Watcher
)
GetChannel
()
chan
ports
.
ChangeNotification
{
func
(
y
*
File
Watcher
)
GetChannel
()
chan
ports
.
ChangeNotification
{
return
y
.
outgoingChannel
}
// StartWatcher starts the watcher.
func
(
y
*
Yaml
Watcher
)
StartWatcher
()
error
{
func
(
y
*
File
Watcher
)
StartWatcher
()
error
{
y
.
logger
.
Infof
(
"starting watcher for path %s"
,
y
.
directoryPathToWatch
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
...
...
@@ -55,7 +56,7 @@ func (y *YamlWatcher) StartWatcher() error {
}
// StopWatcher stops the watcher. Uses the generic Close() interface.
func
(
y
*
Yaml
Watcher
)
StopWatcher
()
error
{
func
(
y
*
File
Watcher
)
StopWatcher
()
error
{
y
.
logger
.
Infof
(
"stopping watcher for path %s"
,
y
.
directoryPathToWatch
)
err
:=
y
.
Close
()
...
...
@@ -67,14 +68,14 @@ func (y *YamlWatcher) StopWatcher() error {
}
// Close stops the watcher.
func
(
y
*
Yaml
Watcher
)
Close
()
error
{
func
(
y
*
File
Watcher
)
Close
()
error
{
close
(
y
.
outgoingChannel
)
y
.
watcherCancel
()
return
nil
}
func
(
y
*
Yaml
Watcher
)
watching
(
ctx
context
.
Context
)
{
func
(
y
*
File
Watcher
)
watching
(
ctx
context
.
Context
)
{
watcher
,
err
:=
fsnotify
.
NewWatcher
()
if
err
!=
nil
{
y
.
logger
.
Errorw
(
"failed to create watcher"
,
"error"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment