-
Notifications
You must be signed in to change notification settings - Fork 3
/
schema.go
56 lines (42 loc) · 1.23 KB
/
schema.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2017 Author: Ruslan Bikchentaev. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package services
import (
"github.com/ruslanBik4/httpgo/models/db"
DBschema "github.com/ruslanBik4/httpgo/models/db/schema"
)
type schemaService struct {
name string
status string
}
var (
schema *schemaService = &schemaService{name: "schema", status: "create"}
)
func (schema *schemaService) Init() error {
schema.status = "starting"
db.InitSchema()
schema.status = "ready"
return nil
}
func (schema *schemaService) Send(messages ...interface{}) error {
return nil
}
func (schema *schemaService) Get(messages ...interface{}) (response interface{}, err error) {
if tableName, ok := messages[0].(string); ok {
return DBschema.GetFieldsTable(tableName), nil
}
return nil, &ErrServiceNotCorrectParamType{Name: schema.name, Param: messages[0]}
}
func (schema *schemaService) Connect(in <-chan interface{}) (out chan interface{}, err error) {
return nil, nil
}
func (schema *schemaService) Close(out chan<- interface{}) error {
return nil
}
func (schema *schemaService) Status() string {
return schema.status
}
func init() {
AddService(schema.name, schema)
}