Skip to content

Commit fb67e04

Browse files
committed
cmd/server: read env variables for data filepaths
1 parent abd6866 commit fb67e04

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Package `github.com/moov-io/fed` implements utility services for searching the U
1515
Go library
1616
github.com/moov-io/fed offers a Go based search for FEDACH and FEDWIRE Participants.
1717

18+
### Configuration
19+
20+
| Environmental Variable | Description | Default |
21+
|-----|-----|-----|
22+
| `FEDACH_DATA_PATH` | Filepath to FEDACH data file | `./data/FedACHdir.txt` |
23+
| `FEDWIRE_DATA_PATH` | Filepath to FedWIRE data file | `./data/fpddir.txt` |
24+
1825
## FedWire and FedACH data from the Federal Reserve Bank Services
1926

2027
The data and formats in this repository represent a compilation of the **FedWire** and **FedACH** data from the [Federal Reserve Bank Services site](https://frbservices.org/).
@@ -35,7 +42,7 @@ The data and formats in this repository represent a compilation of the **FedWire
3542

3643
(c) Federal Reserve Banks
3744

38-
By accessing the [data](./data/) in this repository you agree to the [Federal Reserve Banks' Terms of Use](https://frbservices.org/terms/index.html) and the [E-Payments Routing Directory Terms of Use Agreement](https://www.frbservices.org/EPaymentsDirectory/agreement.html).
45+
By accessing the [data](./data/) in this repository you agree to the [Federal Reserve Banks' Terms of Use](https://frbservices.org/terms/index.html) and the [E-Payments Routing Directory Terms of Use Agreement](https://www.frbservices.org/EPaymentsDirectory/agreement.html).
3946

4047
## Disclaimer
4148

cmd/server/reader.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,28 @@ import (
77
"github.com/moov-io/fed"
88
)
99

10+
var (
11+
fedACHDataFilepath = os.Getenv("FEDACH_DATA_PATH")
12+
fedWIREDataFilepath = os.Getenv("FEDWIRE_DATA_PATH")
13+
)
14+
15+
func init() {
16+
if fedACHDataFilepath == "" {
17+
fedACHDataFilepath = "./data/FedACHdir.txt"
18+
}
19+
if fedWIREDataFilepath == "" {
20+
fedWIREDataFilepath = "./data/fpddir.txt"
21+
}
22+
}
23+
1024
// readFEDACHData opens and reads FedACHdir.txt then runs ACHDictionary.Read() to
1125
// parse and define ACHDictionary properties
1226
func (s *searcher) readFEDACHData() error {
1327
if s.logger != nil {
1428
s.logger.Log("read", "Read of FED data")
1529
}
1630

17-
f, err := os.Open("./data/FedACHdir.txt")
31+
f, err := os.Open(fedACHDataFilepath)
1832
if err != nil {
1933
return fmt.Errorf("ERROR: opening FedACHdir.txt %v", err)
2034
}
@@ -39,7 +53,7 @@ func (s *searcher) readFEDWIREData() error {
3953
s.logger.Log("read", "Read of FED data")
4054
}
4155

42-
f, err := os.Open("./data/fpddir.txt")
56+
f, err := os.Open(fedWIREDataFilepath)
4357
if err != nil {
4458
return fmt.Errorf("ERROR: opening fpddir.txt %v", err)
4559
}

0 commit comments

Comments
 (0)