mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
29 lines
452 B
Go
29 lines
452 B
Go
package ballast
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
func Module(ballastSizeInBytes uint) fx.Option {
|
|
if ballastSizeInBytes == 0 {
|
|
return fx.Options()
|
|
}
|
|
|
|
return fx.Options(
|
|
fx.Invoke(func(lc fx.Lifecycle) {
|
|
lc.Append(fx.Hook{
|
|
OnStart: func(ctx context.Context) error {
|
|
Allocate(ballastSizeInBytes)
|
|
return nil
|
|
},
|
|
OnStop: func(ctx context.Context) error {
|
|
ReleaseForGC()
|
|
return nil
|
|
},
|
|
})
|
|
}),
|
|
)
|
|
}
|