MCPcopy Index your code
hub / github.com/FunctionStream/function-stream / loadFile

Method loadFile

server/function_store.go:107–131  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

105}
106
107func (f *FunctionStoreImpl) loadFile(path string) error {
108 data, err := os.ReadFile(path)
109 if err != nil {
110 return err
111 }
112 dec := yaml.NewDecoder(strings.NewReader(string(data)))
113 for {
114 var function model.Function
115 err := dec.Decode(&function)
116 if err != nil {
117 if err == io.EOF {
118 break
119 }
120 return err
121 }
122 if err := function.Validate(); err != nil {
123 return errors.Wrapf(err, "function %s is invalid", function.Name)
124 }
125 if _, ok := f.loadingFunctions[function.Name]; ok {
126 return errors.Errorf("duplicated function %s", function.Name)
127 }
128 f.loadingFunctions[function.Name] = &function
129 }
130 return nil
131}
132
133func NewFunctionStoreImpl(fm fs.FunctionManager, path string) (FunctionStore, error) {
134 return &FunctionStoreImpl{

Callers 1

LoadMethod · 0.95

Calls 1

ValidateMethod · 0.95

Tested by

no test coverage detected