MCPcopy
hub / github.com/baetyl/baetyl / NewBoltHold

Function NewBoltHold

store/bolthold.go:16–36  ·  view source on GitHub ↗

NewBoltHold creates a new bolt hold

(filename string)

Source from the content-addressed store, hash-verified

14
15// NewBoltHold creates a new bolt hold
16func NewBoltHold(filename string) (*bh.Store, error) {
17 err := os.MkdirAll(filepath.Dir(filename), 0755)
18 if err != nil {
19 return nil, errors.Trace(err)
20 }
21 ops := &bh.Options{}
22 ops.Options = bolt.DefaultOptions
23 ops.Timeout = time.Second * 10
24 ops.Encoder = func(value interface{}) ([]byte, error) {
25 return json.Marshal(value)
26 }
27 ops.Decoder = func(data []byte, value interface{}) error {
28 return json.Unmarshal(data, value)
29 }
30 sto, err := bh.Open(filename, 0666, ops)
31 if err != nil {
32 log.L().Error("failed to open bolthold", log.Any("path", filename))
33 return nil, errors.Trace(err)
34 }
35 return sto, nil
36}

Callers 15

genBoltholdFunction · 0.92
NewCoreFunction · 0.92
prepareFunction · 0.92
TestRecycleFunction · 0.92
initExecKubeAMIFunction · 0.92
initApplyKubeAMIFunction · 0.92
initLogKubeAMIFunction · 0.92
initCollectKubeAMIFunction · 0.92
TestSyncStoreFunction · 0.92
TestSyncResourcesFunction · 0.92
TestReportSyncFunction · 0.92

Calls

no outgoing calls

Tested by 15

genBoltholdFunction · 0.74
prepareFunction · 0.74
TestRecycleFunction · 0.74
initExecKubeAMIFunction · 0.74
initApplyKubeAMIFunction · 0.74
initLogKubeAMIFunction · 0.74
initCollectKubeAMIFunction · 0.74
TestSyncStoreFunction · 0.74
TestSyncResourcesFunction · 0.74
TestReportSyncFunction · 0.74
TestReportAsyncFunction · 0.74