HW13 WIP
parent
9502e665e2
commit
7cfe6eca89
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/grpc"
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/grpc"
|
||||||
googrpc "google.golang.org/grpc"
|
googrpc "google.golang.org/grpc"
|
||||||
oslog "log"
|
oslog "log"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
|
||||||
|
@ -12,7 +13,6 @@ import (
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/app"
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/app"
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/config"
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/config"
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/logger"
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/logger"
|
||||||
internalgrpc "github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/server/grpc"
|
|
||||||
internalhttp "github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/server/http"
|
internalhttp "github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/server/http"
|
||||||
store "github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/storage"
|
store "github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/storage"
|
||||||
)
|
)
|
||||||
|
@ -46,8 +46,14 @@ func main() {
|
||||||
calendar := app.New(log, st)
|
calendar := app.New(log, st)
|
||||||
|
|
||||||
serverHTTP := internalhttp.NewServer(calendar, conf.Server.Address, conf.Server.Port)
|
serverHTTP := internalhttp.NewServer(calendar, conf.Server.Address, conf.Server.Port)
|
||||||
|
|
||||||
|
listnGrpc, err := net.Listen("tcp", net.JoinHostPort(conf.Grpc.Address, conf.Grpc.Port))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to listen %v", err)
|
||||||
|
}
|
||||||
serverGRPC := googrpc.NewServer()
|
serverGRPC := googrpc.NewServer()
|
||||||
grpc.RegisterGrpcServer(serverGRPC, internalgrpc.Service{})
|
grpc.RegisterGrpcServer(serverGRPC, grpc.Service{*calendar})
|
||||||
|
serverGRPC.Serve(listnGrpc)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
signals := make(chan os.Signal, 1)
|
signals := make(chan os.Signal, 1)
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
Address = "localhost"
|
Address = "localhost"
|
||||||
Port = "8080"
|
Port = "8080"
|
||||||
|
|
||||||
|
[Grpc]
|
||||||
|
Address = "localhost"
|
||||||
|
Port = "50051"
|
||||||
|
|
||||||
[Logger]
|
[Logger]
|
||||||
File = "./calendar.log"
|
File = "./calendar.log"
|
||||||
Level = "INFO"
|
Level = "INFO"
|
||||||
|
|
|
@ -5,12 +5,13 @@ go 1.14
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/amitrai48/logger v0.0.0-20190214092904-448001c055ec
|
github.com/amitrai48/logger v0.0.0-20190214092904-448001c055ec
|
||||||
|
github.com/daixiang0/gci v0.2.4 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.5.0
|
github.com/go-sql-driver/mysql v1.5.0
|
||||||
github.com/golang/protobuf v1.4.2
|
github.com/golang/protobuf v1.4.2
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.15.0
|
github.com/grpc-ecosystem/grpc-gateway v1.15.0
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.4.0
|
||||||
go.uber.org/zap v1.15.0 // indirect
|
go.uber.org/zap v1.15.0 // indirect
|
||||||
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0
|
golang.org/x/net v0.0.0-20200625001655-4c5254603344
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
|
||||||
google.golang.org/grpc v1.32.0
|
google.golang.org/grpc v1.32.0
|
||||||
google.golang.org/protobuf v1.25.0 // indirect
|
google.golang.org/protobuf v1.25.0 // indirect
|
||||||
|
|
|
@ -12,6 +12,10 @@ type Config struct {
|
||||||
Address string
|
Address string
|
||||||
Port string
|
Port string
|
||||||
}
|
}
|
||||||
|
Grpc struct {
|
||||||
|
Address string
|
||||||
|
Port string
|
||||||
|
}
|
||||||
Logger struct {
|
Logger struct {
|
||||||
File string
|
File string
|
||||||
Level string
|
Level string
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package grpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/ptypes/empty"
|
||||||
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
App app.App
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) Create(ctx context.Context, e *Event) (*EventID, error) {
|
||||||
|
var res EventID
|
||||||
|
//var tmp = event.Event{e.Title, e.Date.(time.Time), e.Latency, e.Note, e.UserID, e.NotifyTime}
|
||||||
|
//t, err := s.App.Storage.Create(tmp)
|
||||||
|
//if err != nil { return nil, err }
|
||||||
|
//res.ID = string(t)
|
||||||
|
return &res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) Update(ctx context.Context, e *EventWthID) (*empty.Empty, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) Delete(ctx context.Context, e *EventID) (*empty.Empty, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) List(ctx context.Context, e *empty.Empty) (*EventList, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) GetByID(ctx context.Context, e *EventID) (*EventList, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) GetByDate(ctx context.Context, e *Date) (*EventList, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
|
@ -1,33 +0,0 @@
|
||||||
package grpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"github.com/golang/protobuf/ptypes/empty"
|
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service struct{}
|
|
||||||
|
|
||||||
func (s Service) Create(context.Context, *grpc.Event) (*grpc.EventID, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) Update(context.Context, *grpc.EventWthID) (*empty.Empty, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) Delete(context.Context, *grpc.EventID) (*empty.Empty, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) List(context.Context, *empty.Empty) (*grpc.EventList, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) GetByID(context.Context, *grpc.EventID) (*grpc.EventList, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) GetByDate(context.Context, *grpc.Date) (*grpc.EventList, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
|
@ -1,10 +1,11 @@
|
||||||
package store
|
package store
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/storage/event"
|
"github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/storage/event"
|
||||||
memorystorage "github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/storage/memory"
|
memorystorage "github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/storage/memory"
|
||||||
sqlstorage "github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/storage/sql"
|
sqlstorage "github.com/tiburon-777/HW_OTUS/hw12_13_14_15_calendar/internal/storage/sql"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|
Loading…
Reference in New Issue