Skip to content

Commit

Permalink
[feature] Use Read/Write lock for config (#1969)
Browse files Browse the repository at this point in the history
  • Loading branch information
daenney committed Jul 10, 2023
1 parent 6de5ca4 commit f0dad43
Show file tree
Hide file tree
Showing 3 changed files with 323 additions and 323 deletions.
4 changes: 2 additions & 2 deletions internal/config/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ func generateFields(output io.Writer, prefixes []string, t reflect.Type) {
// ConfigState structure helper methods
fmt.Fprintf(output, "// Get%s safely fetches the Configuration value for state's '%s' field\n", name, fieldPath)
fmt.Fprintf(output, "func (st *ConfigState) Get%s() (v %s) {\n", name, fieldType)
fmt.Fprintf(output, "\tst.mutex.Lock()\n")
fmt.Fprintf(output, "\tst.mutex.RLock()\n")
fmt.Fprintf(output, "\tv = st.config.%s\n", fieldPath)
fmt.Fprintf(output, "\tst.mutex.Unlock()\n")
fmt.Fprintf(output, "\tst.mutex.RUnlock()\n")
fmt.Fprintf(output, "\treturn\n")
fmt.Fprintf(output, "}\n\n")
fmt.Fprintf(output, "// Set%s safely sets the Configuration value for state's '%s' field\n", name, fieldPath)
Expand Down

0 comments on commit f0dad43

Please sign in to comment.