illust-data: first commit
This commit is contained in:
parent
2dbd49300d
commit
915a021491
|
@ -1,4 +1,4 @@
|
|||
package dev.usbharu.dev.usbharu.unos.illust.crud
|
||||
package dev.usbharu.unos.illust.crud
|
||||
|
||||
import illust.IllustOuterClass
|
||||
import illust.crud.IllustCRUDServiceGrpcKt.IllustCRUDServiceCoroutineImplBase
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
version: 3
|
||||
includes:
|
||||
|
||||
tasks:
|
||||
build:
|
||||
deps:
|
||||
- generate
|
||||
cmds:
|
||||
- cmd: go build
|
||||
generate:
|
||||
cmds:
|
||||
- cmd: protoc -I ../unos-proto/src/main/proto --go_out=. ../unos-proto/src/main/proto/illust/data/illust_data.proto --go_opt=module=git.usbharu.dev/usbharu/unos --go-grpc_opt=module=git.usbharu.dev/usbharu/unos --go-grpc_out=.
|
||||
- cmd: protoc -I ../unos-proto/src/main/proto --go_out=. ../unos-proto/src/main/proto/illust/illust.proto --go_opt=module=git.usbharu.dev/usbharu/unos --go-grpc_opt=module=git.usbharu.dev/usbharu/unos --go-grpc_out=.
|
|
@ -0,0 +1,27 @@
|
|||
module git.usbharu.dev/usbharu/unos
|
||||
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
google.golang.org/grpc v1.62.1
|
||||
google.golang.org/protobuf v1.33.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golang/snappy v0.0.1 // indirect
|
||||
github.com/klauspost/compress v1.13.6 // indirect
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.1.2 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
|
||||
go.mongodb.org/mongo-driver v1.14.0 // indirect
|
||||
golang.org/x/crypto v0.18.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.16.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
)
|
|
@ -0,0 +1,67 @@
|
|||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
|
||||
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
|
||||
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
|
||||
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80=
|
||||
go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
|
||||
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
|
||||
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
|
@ -0,0 +1,75 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.25.3
|
||||
// source: illust/data/illust_data.proto
|
||||
|
||||
package data
|
||||
|
||||
import (
|
||||
illust "git.usbharu.dev/usbharu/unos/illust"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
var File_illust_data_illust_data_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_illust_data_illust_data_proto_rawDesc = []byte{
|
||||
0x0a, 0x1d, 0x69, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x69, 0x6c,
|
||||
0x6c, 0x75, 0x73, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x0b, 0x69, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x13, 0x69, 0x6c,
|
||||
0x6c, 0x75, 0x73, 0x74, 0x2f, 0x69, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x32, 0x3b, 0x0a, 0x11, 0x49, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x44, 0x61, 0x74, 0x61, 0x53,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x26, 0x0a, 0x04, 0x73, 0x61, 0x76, 0x65, 0x12, 0x0e,
|
||||
0x2e, 0x69, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2e, 0x49, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x1a, 0x0e,
|
||||
0x2e, 0x69, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2e, 0x49, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x42, 0x2a,
|
||||
0x5a, 0x28, 0x67, 0x69, 0x74, 0x2e, 0x75, 0x73, 0x62, 0x68, 0x61, 0x72, 0x75, 0x2e, 0x64, 0x65,
|
||||
0x76, 0x2f, 0x75, 0x73, 0x62, 0x68, 0x61, 0x72, 0x75, 0x2f, 0x75, 0x6e, 0x6f, 0x73, 0x2f, 0x69,
|
||||
0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var file_illust_data_illust_data_proto_goTypes = []interface{}{
|
||||
(*illust.Illust)(nil), // 0: illust.Illust
|
||||
}
|
||||
var file_illust_data_illust_data_proto_depIdxs = []int32{
|
||||
0, // 0: illust.data.IllustDataService.save:input_type -> illust.Illust
|
||||
0, // 1: illust.data.IllustDataService.save:output_type -> illust.Illust
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_illust_data_illust_data_proto_init() }
|
||||
func file_illust_data_illust_data_proto_init() {
|
||||
if File_illust_data_illust_data_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_illust_data_illust_data_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 0,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_illust_data_illust_data_proto_goTypes,
|
||||
DependencyIndexes: file_illust_data_illust_data_proto_depIdxs,
|
||||
}.Build()
|
||||
File_illust_data_illust_data_proto = out.File
|
||||
file_illust_data_illust_data_proto_rawDesc = nil
|
||||
file_illust_data_illust_data_proto_goTypes = nil
|
||||
file_illust_data_illust_data_proto_depIdxs = nil
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package data
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.usbharu.dev/usbharu/unos/illust"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
type IllustDataServiceImpl struct {
|
||||
UnimplementedIllustDataServiceServer
|
||||
mongo.Collection
|
||||
}
|
||||
|
||||
func NewIllustDataServiceImpl(database mongo.Database) *IllustDataServiceImpl {
|
||||
return &IllustDataServiceImpl{Collection: *database.Collection("illusts")}
|
||||
}
|
||||
|
||||
func (s *IllustDataServiceImpl) Save(ctx context.Context, req *illust.Illust) (*illust.Illust, error) {
|
||||
if _, err := s.ReplaceOne(context.TODO(), bson.D{{"_id", req.Id}}, req, options.Replace().SetUpsert(true)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return req, nil
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v4.25.3
|
||||
// source: illust/data/illust_data.proto
|
||||
|
||||
package data
|
||||
|
||||
import (
|
||||
context "context"
|
||||
illust "git.usbharu.dev/usbharu/unos/illust"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// IllustDataServiceClient is the client API for IllustDataService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type IllustDataServiceClient interface {
|
||||
Save(ctx context.Context, in *illust.Illust, opts ...grpc.CallOption) (*illust.Illust, error)
|
||||
}
|
||||
|
||||
type illustDataServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewIllustDataServiceClient(cc grpc.ClientConnInterface) IllustDataServiceClient {
|
||||
return &illustDataServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *illustDataServiceClient) Save(ctx context.Context, in *illust.Illust, opts ...grpc.CallOption) (*illust.Illust, error) {
|
||||
out := new(illust.Illust)
|
||||
err := c.cc.Invoke(ctx, "/illust.data.IllustDataService/save", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// IllustDataServiceServer is the server API for IllustDataService service.
|
||||
// All implementations must embed UnimplementedIllustDataServiceServer
|
||||
// for forward compatibility
|
||||
type IllustDataServiceServer interface {
|
||||
Save(context.Context, *illust.Illust) (*illust.Illust, error)
|
||||
mustEmbedUnimplementedIllustDataServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedIllustDataServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedIllustDataServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedIllustDataServiceServer) Save(context.Context, *illust.Illust) (*illust.Illust, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Save not implemented")
|
||||
}
|
||||
func (UnimplementedIllustDataServiceServer) mustEmbedUnimplementedIllustDataServiceServer() {}
|
||||
|
||||
// UnsafeIllustDataServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to IllustDataServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeIllustDataServiceServer interface {
|
||||
mustEmbedUnimplementedIllustDataServiceServer()
|
||||
}
|
||||
|
||||
func RegisterIllustDataServiceServer(s grpc.ServiceRegistrar, srv IllustDataServiceServer) {
|
||||
s.RegisterService(&IllustDataService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _IllustDataService_Save_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(illust.Illust)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(IllustDataServiceServer).Save(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/illust.data.IllustDataService/save",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(IllustDataServiceServer).Save(ctx, req.(*illust.Illust))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// IllustDataService_ServiceDesc is the grpc.ServiceDesc for IllustDataService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var IllustDataService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "illust.data.IllustDataService",
|
||||
HandlerType: (*IllustDataServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "save",
|
||||
Handler: _IllustDataService_Save_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "illust/data/illust_data.proto",
|
||||
}
|
|
@ -0,0 +1,233 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.25.3
|
||||
// source: illust/illust.proto
|
||||
|
||||
package illust
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Illust struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Sha256 []byte `protobuf:"bytes,3,opt,name=sha256,proto3" json:"sha256,omitempty"`
|
||||
S3Id string `protobuf:"bytes,16,opt,name=s3_id,json=s3Id,proto3" json:"s3_id,omitempty"`
|
||||
Tags map[string]string `protobuf:"bytes,17,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Originals map[string]string `protobuf:"bytes,18,rep,name=originals,proto3" json:"originals,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Characters map[string]string `protobuf:"bytes,19,rep,name=characters,proto3" json:"characters,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Description string `protobuf:"bytes,20,opt,name=description,proto3" json:"description,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Illust) Reset() {
|
||||
*x = Illust{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_illust_illust_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Illust) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Illust) ProtoMessage() {}
|
||||
|
||||
func (x *Illust) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_illust_illust_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Illust.ProtoReflect.Descriptor instead.
|
||||
func (*Illust) Descriptor() ([]byte, []int) {
|
||||
return file_illust_illust_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Illust) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Illust) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Illust) GetSha256() []byte {
|
||||
if x != nil {
|
||||
return x.Sha256
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Illust) GetS3Id() string {
|
||||
if x != nil {
|
||||
return x.S3Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Illust) GetTags() map[string]string {
|
||||
if x != nil {
|
||||
return x.Tags
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Illust) GetOriginals() map[string]string {
|
||||
if x != nil {
|
||||
return x.Originals
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Illust) GetCharacters() map[string]string {
|
||||
if x != nil {
|
||||
return x.Characters
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Illust) GetDescription() string {
|
||||
if x != nil {
|
||||
return x.Description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_illust_illust_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_illust_illust_proto_rawDesc = []byte{
|
||||
0x0a, 0x13, 0x69, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2f, 0x69, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x69, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x22, 0xdc, 0x03,
|
||||
0x0a, 0x06, 0x49, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68,
|
||||
0x61, 0x32, 0x35, 0x36, 0x12, 0x13, 0x0a, 0x05, 0x73, 0x33, 0x5f, 0x69, 0x64, 0x18, 0x10, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x33, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x04, 0x74, 0x61, 0x67,
|
||||
0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x69, 0x6c, 0x6c, 0x75, 0x73, 0x74,
|
||||
0x2e, 0x49, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72,
|
||||
0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x3b, 0x0a, 0x09, 0x6f, 0x72, 0x69, 0x67, 0x69,
|
||||
0x6e, 0x61, 0x6c, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x69, 0x6c, 0x6c,
|
||||
0x75, 0x73, 0x74, 0x2e, 0x49, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2e, 0x4f, 0x72, 0x69, 0x67, 0x69,
|
||||
0x6e, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6f, 0x72, 0x69, 0x67, 0x69,
|
||||
0x6e, 0x61, 0x6c, 0x73, 0x12, 0x3e, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74, 0x65,
|
||||
0x72, 0x73, 0x18, 0x13, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x6c, 0x6c, 0x75, 0x73,
|
||||
0x74, 0x2e, 0x49, 0x6c, 0x6c, 0x75, 0x73, 0x74, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74,
|
||||
0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x72, 0x61, 0x63,
|
||||
0x74, 0x65, 0x72, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72,
|
||||
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e,
|
||||
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a,
|
||||
0x3c, 0x0a, 0x0e, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72,
|
||||
0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
|
||||
0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3d, 0x0a,
|
||||
0x0f, 0x43, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
|
||||
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
|
||||
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x25, 0x5a, 0x23,
|
||||
0x67, 0x69, 0x74, 0x2e, 0x75, 0x73, 0x62, 0x68, 0x61, 0x72, 0x75, 0x2e, 0x64, 0x65, 0x76, 0x2f,
|
||||
0x75, 0x73, 0x62, 0x68, 0x61, 0x72, 0x75, 0x2f, 0x75, 0x6e, 0x6f, 0x73, 0x2f, 0x69, 0x6c, 0x6c,
|
||||
0x75, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_illust_illust_proto_rawDescOnce sync.Once
|
||||
file_illust_illust_proto_rawDescData = file_illust_illust_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_illust_illust_proto_rawDescGZIP() []byte {
|
||||
file_illust_illust_proto_rawDescOnce.Do(func() {
|
||||
file_illust_illust_proto_rawDescData = protoimpl.X.CompressGZIP(file_illust_illust_proto_rawDescData)
|
||||
})
|
||||
return file_illust_illust_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_illust_illust_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_illust_illust_proto_goTypes = []interface{}{
|
||||
(*Illust)(nil), // 0: illust.Illust
|
||||
nil, // 1: illust.Illust.TagsEntry
|
||||
nil, // 2: illust.Illust.OriginalsEntry
|
||||
nil, // 3: illust.Illust.CharactersEntry
|
||||
}
|
||||
var file_illust_illust_proto_depIdxs = []int32{
|
||||
1, // 0: illust.Illust.tags:type_name -> illust.Illust.TagsEntry
|
||||
2, // 1: illust.Illust.originals:type_name -> illust.Illust.OriginalsEntry
|
||||
3, // 2: illust.Illust.characters:type_name -> illust.Illust.CharactersEntry
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_illust_illust_proto_init() }
|
||||
func file_illust_illust_proto_init() {
|
||||
if File_illust_illust_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_illust_illust_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Illust); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_illust_illust_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_illust_illust_proto_goTypes,
|
||||
DependencyIndexes: file_illust_illust_proto_depIdxs,
|
||||
MessageInfos: file_illust_illust_proto_msgTypes,
|
||||
}.Build()
|
||||
File_illust_illust_proto = out.File
|
||||
file_illust_illust_proto_rawDesc = nil
|
||||
file_illust_illust_proto_goTypes = nil
|
||||
file_illust_illust_proto_depIdxs = nil
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.usbharu.dev/usbharu/unos/illust/data"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
"gopkg.in/ini.v1"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
)
|
||||
|
||||
func main() {
|
||||
load, err := ini.Load("config.ini")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
port := load.Section("gRPC").Key("port").MustInt(50051)
|
||||
mongoUrl := load.Section("mongodb").Key("url").MustString("mongodb://localhost:20071")
|
||||
|
||||
listen, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
server := grpc.NewServer()
|
||||
|
||||
connect, err := mongo.Connect(context.Background(), options.Client().ApplyURI(mongoUrl))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
database := connect.Database("")
|
||||
|
||||
data.RegisterIllustDataServiceServer(server, data.NewIllustDataServiceImpl(*database))
|
||||
|
||||
reflection.Register(server)
|
||||
|
||||
go func() {
|
||||
log.Printf("start gRPC server port: %v", port)
|
||||
server.Serve(listen)
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
if err := connect.Disconnect(context.Background()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
quit := make(chan os.Signal, 1)
|
||||
signal.Notify(quit, os.Interrupt)
|
||||
<-quit
|
||||
|
||||
server.GracefulStop()
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
package main
|
|
@ -0,0 +1,9 @@
|
|||
syntax = "proto3";
|
||||
import "illust/illust.proto";
|
||||
|
||||
package illust.data;
|
||||
option go_package = "git.usbharu.dev/usbharu/unos/illust/data";
|
||||
|
||||
service IllustDataService{
|
||||
rpc save (illust.Illust) returns (illust.Illust);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package illust;
|
||||
|
||||
option go_package = "git.usbharu.dev/usbharu/unos/illust";
|
||||
message Illust{
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
|
|
Loading…
Reference in New Issue