-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-store.go
More file actions
35 lines (28 loc) · 802 Bytes
/
app-store.go
File metadata and controls
35 lines (28 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"context"
"fmt"
"github.com/protobuf-orm/protobuf-orm/graph"
"github.com/protobuf-orm/protoc-gen-orm-ent/apps/store/app"
"google.golang.org/protobuf/compiler/protogen"
)
type StoreOpts struct {
Name string
ent protogen.GoImportPath
// TODO: currently, it is expected that the store will be placed in the same package with the server.
// server protogen.GoImportPath
}
func (h *StoreOpts) Run(ctx context.Context, p *protogen.Plugin, g *graph.Graph) error {
opts := []app.Option{}
if h.Name != "" {
opts = append(opts, app.WithName(h.Name))
}
app, err := app.New(h.ent, opts...)
if err != nil {
return fmt.Errorf("initialize store app: %w", err)
}
if err := app.Run(ctx, p, g); err != nil {
return fmt.Errorf("run store app: %w", err)
}
return nil
}