forked from xmcy0011/CoffeeChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
173 changed files
with
13,408 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
syntax = "proto3"; | ||
|
||
package apigw.v1; | ||
|
||
import "google/api/annotations.proto"; | ||
|
||
option go_package = "apigw/api/apigw/v1;v1"; | ||
option java_multiple_files = true; | ||
option java_package = "dev.kratos.api.helloworld.v1"; | ||
option java_outer_classname = "HelloworldProtoV1"; | ||
|
||
// The greeting service definition. | ||
service Greeter { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) { | ||
option (google.api.http) = { | ||
get: "/helloworld/{name}" | ||
}; | ||
} | ||
} | ||
|
||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
|
||
package helloworld.v1; | ||
|
||
option go_package = "apigw/api/helloworld/v1;v1"; | ||
option java_multiple_files = true; | ||
option java_package = "helloworld.v1"; | ||
option objc_class_prefix = "APIHelloworldV1"; | ||
|
||
enum ErrorReason { | ||
GEETER_UNSPECIFIED = 0; | ||
USER_NOT_FOUND = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
|
||
"apigw/internal/conf" | ||
"github.com/go-kratos/kratos/v2" | ||
"github.com/go-kratos/kratos/v2/config" | ||
"github.com/go-kratos/kratos/v2/config/file" | ||
"github.com/go-kratos/kratos/v2/log" | ||
"github.com/go-kratos/kratos/v2/middleware/tracing" | ||
"github.com/go-kratos/kratos/v2/transport/grpc" | ||
"github.com/go-kratos/kratos/v2/transport/http" | ||
) | ||
|
||
// go build -ldflags "-X main.Version=x.y.z" | ||
var ( | ||
// Name is the name of the compiled software. | ||
Name string | ||
// Version is the version of the compiled software. | ||
Version string | ||
// flagconf is the config flag. | ||
flagconf string | ||
|
||
id, _ = os.Hostname() | ||
) | ||
|
||
func init() { | ||
flag.StringVar(&flagconf, "conf", "../../configs", "config path, eg: -conf config.yaml") | ||
} | ||
|
||
func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server) *kratos.App { | ||
return kratos.New( | ||
kratos.ID(id), | ||
kratos.Name(Name), | ||
kratos.Version(Version), | ||
kratos.Metadata(map[string]string{}), | ||
kratos.Logger(logger), | ||
kratos.Server( | ||
gs, | ||
hs, | ||
), | ||
) | ||
} | ||
|
||
func main() { | ||
flag.Parse() | ||
logger := log.With(log.NewStdLogger(os.Stdout), | ||
"ts", log.DefaultTimestamp, | ||
"caller", log.DefaultCaller, | ||
"service.id", id, | ||
"service.name", Name, | ||
"service.version", Version, | ||
"trace.id", tracing.TraceID(), | ||
"span.id", tracing.SpanID(), | ||
) | ||
c := config.New( | ||
config.WithSource( | ||
file.NewSource(flagconf), | ||
), | ||
) | ||
defer c.Close() | ||
|
||
if err := c.Load(); err != nil { | ||
panic(err) | ||
} | ||
|
||
var bc conf.Bootstrap | ||
if err := c.Scan(&bc); err != nil { | ||
panic(err) | ||
} | ||
|
||
app, cleanup, err := wireApp(bc.Server, bc.Data, logger) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer cleanup() | ||
|
||
// start and wait for stop signal | ||
if err := app.Run(); err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// +build wireinject | ||
|
||
// The build tag makes sure the stub is not built in the final build. | ||
|
||
package main | ||
|
||
import ( | ||
"apigw/internal/biz" | ||
"apigw/internal/conf" | ||
"apigw/internal/data" | ||
"apigw/internal/server" | ||
"apigw/internal/service" | ||
"github.com/go-kratos/kratos/v2" | ||
"github.com/go-kratos/kratos/v2/log" | ||
"github.com/google/wire" | ||
) | ||
|
||
// wireApp init kratos application. | ||
func wireApp(*conf.Server, *conf.Data, log.Logger) (*kratos.App, func(), error) { | ||
panic(wire.Build(server.ProviderSet, data.ProviderSet, biz.ProviderSet, service.ProviderSet, newApp)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module httpapi | ||
|
||
go 1.17 | ||
|
||
require ( | ||
github.com/go-kratos/kratos/v2 v2.4.0 | ||
github.com/google/wire v0.5.0 | ||
google.golang.org/genproto v0.0.0-20220524023933-508584e28198 | ||
google.golang.org/grpc v1.46.2 | ||
google.golang.org/protobuf v1.28.0 | ||
) | ||
|
||
require ( | ||
github.com/fsnotify/fsnotify v1.5.4 // indirect | ||
github.com/go-logr/logr v1.2.3 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/go-playground/form/v4 v4.2.0 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/gorilla/mux v1.8.0 // indirect | ||
github.com/imdario/mergo v0.3.12 // indirect | ||
go.opentelemetry.io/otel v1.7.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.7.0 // indirect | ||
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect | ||
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect | ||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
gopkg.in/yaml.v3 v3.0.0 // indirect | ||
) |
Oops, something went wrong.