Skip to content

Commit eff2c88

Browse files
committed
Add journal body memory limit flag
1 parent 54b53b7 commit eff2c88

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

core/cmd/hoverfly/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var logOutputFlags arrayFlags
6464
var responseBodyFilesPath string
6565
var responseBodyFilesAllowedOriginFlags arrayFlags
6666
var journalIndexingKeyFlags arrayFlags
67+
var journalBodyMemoryLimit util.MemorySize
6768

6869
const boltBackend = "boltdb"
6970
const inmemoryBackend = "memory"
@@ -210,6 +211,7 @@ func main() {
210211
flag.StringVar(&responseBodyFilesPath, "response-body-files-path", "", "When a response contains a relative bodyFile, it will be resolved against this absolute path (default is CWD)")
211212
flag.Var(&responseBodyFilesAllowedOriginFlags, "response-body-files-allow-origin", "When a response contains a url in bodyFile, it will be loaded only if the origin is allowed")
212213
flag.Var(&journalIndexingKeyFlags, "journal-indexing-key", "Key to setup indexing on journal")
214+
flag.Var(&journalBodyMemoryLimit, "journal-body-memory-limit", "Memory size limit for a request or response body in the journal (e.g., '128KB', '2MB'). Memory size is unbounded by default")
213215

214216
flag.Parse()
215217

@@ -234,6 +236,10 @@ func main() {
234236
*journalSize = 0
235237
}
236238

239+
if journalBodyMemoryLimit > 0 {
240+
log.Infof("Journal body memory limit is set to: %s", journalBodyMemoryLimit.String())
241+
}
242+
237243
if *logsSize < 0 {
238244
*logsSize = 0
239245
}

core/util/memory_size.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type MemorySize int64
1111

1212
// String returns the string representation of the memory size
1313
func (m *MemorySize) String() string {
14-
return fmt.Sprintf("%d", *m)
14+
return fmt.Sprintf("%d bytes", *m)
1515
}
1616

1717
// ToBytes returns the memory size as an int64 in bytes.

0 commit comments

Comments
 (0)