tangled
alpha
login
or
join now
hailey.at
/
vylet-go
1
fork
atom
this repo has no description
1
fork
atom
overview
issues
pulls
pipelines
full profile implementation
hailey.at
3 months ago
d4e3b6b2
45183b99
+386
-30
6 changed files
expand all
collapse all
unified
split
database
proto
profile.pb.go
profile.proto
profile_grpc.pb.go
server
profile.go
indexer
actorprofile.go
migrations
000001_create_profiles_table.up.cql
+233
-19
database/proto/profile.pb.go
···
10
10
_ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
11
11
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
12
12
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
13
13
-
_ "google.golang.org/protobuf/types/known/timestamppb"
13
13
+
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
14
14
reflect "reflect"
15
15
sync "sync"
16
16
unsafe "unsafe"
···
69
69
70
70
type GetProfileResponse struct {
71
71
state protoimpl.MessageState `protogen:"open.v1"`
72
72
-
Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"`
72
72
+
Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
73
73
+
Did string `protobuf:"bytes,2,opt,name=did,proto3" json:"did,omitempty"`
74
74
+
DisplayName *string `protobuf:"bytes,3,opt,name=display_name,json=displayName,proto3,oneof" json:"display_name,omitempty"`
75
75
+
Description *string `protobuf:"bytes,4,opt,name=description,proto3,oneof" json:"description,omitempty"`
76
76
+
Pronouns *string `protobuf:"bytes,5,opt,name=pronouns,proto3,oneof" json:"pronouns,omitempty"`
77
77
+
Avatar *string `protobuf:"bytes,6,opt,name=avatar,proto3,oneof" json:"avatar,omitempty"`
78
78
+
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3,oneof" json:"created_at,omitempty"`
79
79
+
IndexedAt *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=indexed_at,json=indexedAt,proto3" json:"indexed_at,omitempty"`
73
80
unknownFields protoimpl.UnknownFields
74
81
sizeCache protoimpl.SizeCache
75
82
}
···
104
111
return file_profile_proto_rawDescGZIP(), []int{1}
105
112
}
106
113
114
114
+
func (x *GetProfileResponse) GetError() string {
115
115
+
if x != nil && x.Error != nil {
116
116
+
return *x.Error
117
117
+
}
118
118
+
return ""
119
119
+
}
120
120
+
107
121
func (x *GetProfileResponse) GetDid() string {
108
122
if x != nil {
109
123
return x.Did
···
111
125
return ""
112
126
}
113
127
128
128
+
func (x *GetProfileResponse) GetDisplayName() string {
129
129
+
if x != nil && x.DisplayName != nil {
130
130
+
return *x.DisplayName
131
131
+
}
132
132
+
return ""
133
133
+
}
134
134
+
135
135
+
func (x *GetProfileResponse) GetDescription() string {
136
136
+
if x != nil && x.Description != nil {
137
137
+
return *x.Description
138
138
+
}
139
139
+
return ""
140
140
+
}
141
141
+
142
142
+
func (x *GetProfileResponse) GetPronouns() string {
143
143
+
if x != nil && x.Pronouns != nil {
144
144
+
return *x.Pronouns
145
145
+
}
146
146
+
return ""
147
147
+
}
148
148
+
149
149
+
func (x *GetProfileResponse) GetAvatar() string {
150
150
+
if x != nil && x.Avatar != nil {
151
151
+
return *x.Avatar
152
152
+
}
153
153
+
return ""
154
154
+
}
155
155
+
156
156
+
func (x *GetProfileResponse) GetCreatedAt() *timestamppb.Timestamp {
157
157
+
if x != nil {
158
158
+
return x.CreatedAt
159
159
+
}
160
160
+
return nil
161
161
+
}
162
162
+
163
163
+
func (x *GetProfileResponse) GetIndexedAt() *timestamppb.Timestamp {
164
164
+
if x != nil {
165
165
+
return x.IndexedAt
166
166
+
}
167
167
+
return nil
168
168
+
}
169
169
+
114
170
type CreateProfileRequest struct {
115
171
state protoimpl.MessageState `protogen:"open.v1"`
116
172
Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"`
117
173
CreatedAt *string `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3,oneof" json:"created_at,omitempty"`
174
174
+
DisplayName *string `protobuf:"bytes,3,opt,name=display_name,json=displayName,proto3,oneof" json:"display_name,omitempty"`
175
175
+
Description *string `protobuf:"bytes,4,opt,name=description,proto3,oneof" json:"description,omitempty"`
176
176
+
Pronouns *string `protobuf:"bytes,5,opt,name=pronouns,proto3,oneof" json:"pronouns,omitempty"`
177
177
+
Avatar *string `protobuf:"bytes,6,opt,name=avatar,proto3,oneof" json:"avatar,omitempty"`
118
178
unknownFields protoimpl.UnknownFields
119
179
sizeCache protoimpl.SizeCache
120
180
}
···
163
223
return ""
164
224
}
165
225
226
226
+
func (x *CreateProfileRequest) GetDisplayName() string {
227
227
+
if x != nil && x.DisplayName != nil {
228
228
+
return *x.DisplayName
229
229
+
}
230
230
+
return ""
231
231
+
}
232
232
+
233
233
+
func (x *CreateProfileRequest) GetDescription() string {
234
234
+
if x != nil && x.Description != nil {
235
235
+
return *x.Description
236
236
+
}
237
237
+
return ""
238
238
+
}
239
239
+
240
240
+
func (x *CreateProfileRequest) GetPronouns() string {
241
241
+
if x != nil && x.Pronouns != nil {
242
242
+
return *x.Pronouns
243
243
+
}
244
244
+
return ""
245
245
+
}
246
246
+
247
247
+
func (x *CreateProfileRequest) GetAvatar() string {
248
248
+
if x != nil && x.Avatar != nil {
249
249
+
return *x.Avatar
250
250
+
}
251
251
+
return ""
252
252
+
}
253
253
+
166
254
type CreateProfileResponse struct {
167
255
state protoimpl.MessageState `protogen:"open.v1"`
168
256
Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
···
207
295
return ""
208
296
}
209
297
298
298
+
type DeleteProfileRequest struct {
299
299
+
state protoimpl.MessageState `protogen:"open.v1"`
300
300
+
Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"`
301
301
+
unknownFields protoimpl.UnknownFields
302
302
+
sizeCache protoimpl.SizeCache
303
303
+
}
304
304
+
305
305
+
func (x *DeleteProfileRequest) Reset() {
306
306
+
*x = DeleteProfileRequest{}
307
307
+
mi := &file_profile_proto_msgTypes[4]
308
308
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
309
309
+
ms.StoreMessageInfo(mi)
310
310
+
}
311
311
+
312
312
+
func (x *DeleteProfileRequest) String() string {
313
313
+
return protoimpl.X.MessageStringOf(x)
314
314
+
}
315
315
+
316
316
+
func (*DeleteProfileRequest) ProtoMessage() {}
317
317
+
318
318
+
func (x *DeleteProfileRequest) ProtoReflect() protoreflect.Message {
319
319
+
mi := &file_profile_proto_msgTypes[4]
320
320
+
if x != nil {
321
321
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
322
322
+
if ms.LoadMessageInfo() == nil {
323
323
+
ms.StoreMessageInfo(mi)
324
324
+
}
325
325
+
return ms
326
326
+
}
327
327
+
return mi.MessageOf(x)
328
328
+
}
329
329
+
330
330
+
// Deprecated: Use DeleteProfileRequest.ProtoReflect.Descriptor instead.
331
331
+
func (*DeleteProfileRequest) Descriptor() ([]byte, []int) {
332
332
+
return file_profile_proto_rawDescGZIP(), []int{4}
333
333
+
}
334
334
+
335
335
+
func (x *DeleteProfileRequest) GetDid() string {
336
336
+
if x != nil {
337
337
+
return x.Did
338
338
+
}
339
339
+
return ""
340
340
+
}
341
341
+
342
342
+
type DeleteProfileResponse struct {
343
343
+
state protoimpl.MessageState `protogen:"open.v1"`
344
344
+
Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
345
345
+
unknownFields protoimpl.UnknownFields
346
346
+
sizeCache protoimpl.SizeCache
347
347
+
}
348
348
+
349
349
+
func (x *DeleteProfileResponse) Reset() {
350
350
+
*x = DeleteProfileResponse{}
351
351
+
mi := &file_profile_proto_msgTypes[5]
352
352
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
353
353
+
ms.StoreMessageInfo(mi)
354
354
+
}
355
355
+
356
356
+
func (x *DeleteProfileResponse) String() string {
357
357
+
return protoimpl.X.MessageStringOf(x)
358
358
+
}
359
359
+
360
360
+
func (*DeleteProfileResponse) ProtoMessage() {}
361
361
+
362
362
+
func (x *DeleteProfileResponse) ProtoReflect() protoreflect.Message {
363
363
+
mi := &file_profile_proto_msgTypes[5]
364
364
+
if x != nil {
365
365
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
366
366
+
if ms.LoadMessageInfo() == nil {
367
367
+
ms.StoreMessageInfo(mi)
368
368
+
}
369
369
+
return ms
370
370
+
}
371
371
+
return mi.MessageOf(x)
372
372
+
}
373
373
+
374
374
+
// Deprecated: Use DeleteProfileResponse.ProtoReflect.Descriptor instead.
375
375
+
func (*DeleteProfileResponse) Descriptor() ([]byte, []int) {
376
376
+
return file_profile_proto_rawDescGZIP(), []int{5}
377
377
+
}
378
378
+
379
379
+
func (x *DeleteProfileResponse) GetError() string {
380
380
+
if x != nil && x.Error != nil {
381
381
+
return *x.Error
382
382
+
}
383
383
+
return ""
384
384
+
}
385
385
+
210
386
var File_profile_proto protoreflect.FileDescriptor
211
387
212
388
const file_profile_proto_rawDesc = "" +
213
389
"\n" +
214
390
"\rprofile.proto\x12\rvyletdatabase\x1a\x1bbuf/validate/validate.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"-\n" +
215
391
"\x11GetProfileRequest\x12\x18\n" +
216
216
-
"\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\".\n" +
217
217
-
"\x12GetProfileResponse\x12\x18\n" +
218
218
-
"\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\"c\n" +
392
392
+
"\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\"\xa3\x03\n" +
393
393
+
"\x12GetProfileResponse\x12\x19\n" +
394
394
+
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01\x12\x18\n" +
395
395
+
"\x03did\x18\x02 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\x12&\n" +
396
396
+
"\fdisplay_name\x18\x03 \x01(\tH\x01R\vdisplayName\x88\x01\x01\x12%\n" +
397
397
+
"\vdescription\x18\x04 \x01(\tH\x02R\vdescription\x88\x01\x01\x12\x1f\n" +
398
398
+
"\bpronouns\x18\x05 \x01(\tH\x03R\bpronouns\x88\x01\x01\x12\x1b\n" +
399
399
+
"\x06avatar\x18\x06 \x01(\tH\x04R\x06avatar\x88\x01\x01\x12>\n" +
400
400
+
"\n" +
401
401
+
"created_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampH\x05R\tcreatedAt\x88\x01\x01\x129\n" +
402
402
+
"\n" +
403
403
+
"indexed_at\x18\b \x01(\v2\x1a.google.protobuf.TimestampR\tindexedAtB\b\n" +
404
404
+
"\x06_errorB\x0f\n" +
405
405
+
"\r_display_nameB\x0e\n" +
406
406
+
"\f_descriptionB\v\n" +
407
407
+
"\t_pronounsB\t\n" +
408
408
+
"\a_avatarB\r\n" +
409
409
+
"\v_created_at\"\xa9\x02\n" +
219
410
"\x14CreateProfileRequest\x12\x18\n" +
220
411
"\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\x12\"\n" +
221
412
"\n" +
222
222
-
"created_at\x18\x02 \x01(\tH\x00R\tcreatedAt\x88\x01\x01B\r\n" +
223
223
-
"\v_created_at\"<\n" +
413
413
+
"created_at\x18\x02 \x01(\tH\x00R\tcreatedAt\x88\x01\x01\x12&\n" +
414
414
+
"\fdisplay_name\x18\x03 \x01(\tH\x01R\vdisplayName\x88\x01\x01\x12%\n" +
415
415
+
"\vdescription\x18\x04 \x01(\tH\x02R\vdescription\x88\x01\x01\x12\x1f\n" +
416
416
+
"\bpronouns\x18\x05 \x01(\tH\x03R\bpronouns\x88\x01\x01\x12\x1b\n" +
417
417
+
"\x06avatar\x18\x06 \x01(\tH\x04R\x06avatar\x88\x01\x01B\r\n" +
418
418
+
"\v_created_atB\x0f\n" +
419
419
+
"\r_display_nameB\x0e\n" +
420
420
+
"\f_descriptionB\v\n" +
421
421
+
"\t_pronounsB\t\n" +
422
422
+
"\a_avatar\"<\n" +
224
423
"\x15CreateProfileResponse\x12\x19\n" +
225
424
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01B\b\n" +
226
226
-
"\x06_error2\xbf\x01\n" +
425
425
+
"\x06_error\"0\n" +
426
426
+
"\x14DeleteProfileRequest\x12\x18\n" +
427
427
+
"\x03did\x18\x01 \x01(\tB\x06\xbaH\x03\xc8\x01\x01R\x03did\"<\n" +
428
428
+
"\x15DeleteProfileResponse\x12\x19\n" +
429
429
+
"\x05error\x18\x01 \x01(\tH\x00R\x05error\x88\x01\x01B\b\n" +
430
430
+
"\x06_error2\x9b\x02\n" +
227
431
"\x0eProfileService\x12Q\n" +
228
432
"\n" +
229
433
"GetProfile\x12 .vyletdatabase.GetProfileRequest\x1a!.vyletdatabase.GetProfileResponse\x12Z\n" +
434
434
+
"\rDeleteProfile\x12#.vyletdatabase.DeleteProfileRequest\x1a$.vyletdatabase.DeleteProfileResponse\x12Z\n" +
230
435
"\rCreateProfile\x12#.vyletdatabase.CreateProfileRequest\x1a$.vyletdatabase.CreateProfileResponseB\x87\x01\n" +
231
436
"\x11com.vyletdatabaseB\fProfileProtoP\x01Z\x10./;vyletdatabase\xa2\x02\x03VXX\xaa\x02\rVyletdatabase\xca\x02\rVyletdatabase\xe2\x02\x19Vyletdatabase\\GPBMetadata\xea\x02\rVyletdatabaseb\x06proto3"
232
437
···
242
447
return file_profile_proto_rawDescData
243
448
}
244
449
245
245
-
var file_profile_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
450
450
+
var file_profile_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
246
451
var file_profile_proto_goTypes = []any{
247
452
(*GetProfileRequest)(nil), // 0: vyletdatabase.GetProfileRequest
248
453
(*GetProfileResponse)(nil), // 1: vyletdatabase.GetProfileResponse
249
454
(*CreateProfileRequest)(nil), // 2: vyletdatabase.CreateProfileRequest
250
455
(*CreateProfileResponse)(nil), // 3: vyletdatabase.CreateProfileResponse
456
456
+
(*DeleteProfileRequest)(nil), // 4: vyletdatabase.DeleteProfileRequest
457
457
+
(*DeleteProfileResponse)(nil), // 5: vyletdatabase.DeleteProfileResponse
458
458
+
(*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp
251
459
}
252
460
var file_profile_proto_depIdxs = []int32{
253
253
-
0, // 0: vyletdatabase.ProfileService.GetProfile:input_type -> vyletdatabase.GetProfileRequest
254
254
-
2, // 1: vyletdatabase.ProfileService.CreateProfile:input_type -> vyletdatabase.CreateProfileRequest
255
255
-
1, // 2: vyletdatabase.ProfileService.GetProfile:output_type -> vyletdatabase.GetProfileResponse
256
256
-
3, // 3: vyletdatabase.ProfileService.CreateProfile:output_type -> vyletdatabase.CreateProfileResponse
257
257
-
2, // [2:4] is the sub-list for method output_type
258
258
-
0, // [0:2] is the sub-list for method input_type
259
259
-
0, // [0:0] is the sub-list for extension type_name
260
260
-
0, // [0:0] is the sub-list for extension extendee
261
261
-
0, // [0:0] is the sub-list for field type_name
461
461
+
6, // 0: vyletdatabase.GetProfileResponse.created_at:type_name -> google.protobuf.Timestamp
462
462
+
6, // 1: vyletdatabase.GetProfileResponse.indexed_at:type_name -> google.protobuf.Timestamp
463
463
+
0, // 2: vyletdatabase.ProfileService.GetProfile:input_type -> vyletdatabase.GetProfileRequest
464
464
+
4, // 3: vyletdatabase.ProfileService.DeleteProfile:input_type -> vyletdatabase.DeleteProfileRequest
465
465
+
2, // 4: vyletdatabase.ProfileService.CreateProfile:input_type -> vyletdatabase.CreateProfileRequest
466
466
+
1, // 5: vyletdatabase.ProfileService.GetProfile:output_type -> vyletdatabase.GetProfileResponse
467
467
+
5, // 6: vyletdatabase.ProfileService.DeleteProfile:output_type -> vyletdatabase.DeleteProfileResponse
468
468
+
3, // 7: vyletdatabase.ProfileService.CreateProfile:output_type -> vyletdatabase.CreateProfileResponse
469
469
+
5, // [5:8] is the sub-list for method output_type
470
470
+
2, // [2:5] is the sub-list for method input_type
471
471
+
2, // [2:2] is the sub-list for extension type_name
472
472
+
2, // [2:2] is the sub-list for extension extendee
473
473
+
0, // [0:2] is the sub-list for field type_name
262
474
}
263
475
264
476
func init() { file_profile_proto_init() }
···
266
478
if File_profile_proto != nil {
267
479
return
268
480
}
481
481
+
file_profile_proto_msgTypes[1].OneofWrappers = []any{}
269
482
file_profile_proto_msgTypes[2].OneofWrappers = []any{}
270
483
file_profile_proto_msgTypes[3].OneofWrappers = []any{}
484
484
+
file_profile_proto_msgTypes[5].OneofWrappers = []any{}
271
485
type x struct{}
272
486
out := protoimpl.TypeBuilder{
273
487
File: protoimpl.DescBuilder{
274
488
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
275
489
RawDescriptor: unsafe.Slice(unsafe.StringData(file_profile_proto_rawDesc), len(file_profile_proto_rawDesc)),
276
490
NumEnums: 0,
277
277
-
NumMessages: 4,
491
491
+
NumMessages: 6,
278
492
NumExtensions: 0,
279
493
NumServices: 1,
280
494
},
+23
-1
database/proto/profile.proto
···
9
9
10
10
service ProfileService {
11
11
rpc GetProfile(GetProfileRequest) returns (GetProfileResponse);
12
12
+
rpc DeleteProfile(DeleteProfileRequest) returns (DeleteProfileResponse);
12
13
rpc CreateProfile(CreateProfileRequest) returns (CreateProfileResponse);
13
14
}
14
15
···
19
20
}
20
21
21
22
message GetProfileResponse {
22
22
-
string did = 1 [
23
23
+
optional string error = 1;
24
24
+
25
25
+
string did = 2 [
23
26
(buf.validate.field).required = true
24
27
];
28
28
+
optional string display_name = 3;
29
29
+
optional string description = 4;
30
30
+
optional string pronouns = 5;
31
31
+
optional string avatar = 6;
32
32
+
optional google.protobuf.Timestamp created_at = 7;
33
33
+
google.protobuf.Timestamp indexed_at = 8;
25
34
}
26
35
27
36
message CreateProfileRequest {
···
29
38
(buf.validate.field).required = true
30
39
];
31
40
optional string created_at = 2;
41
41
+
optional string display_name = 3;
42
42
+
optional string description = 4;
43
43
+
optional string pronouns = 5;
44
44
+
optional string avatar = 6;
32
45
}
33
46
34
47
message CreateProfileResponse {
35
48
optional string error = 1;
36
49
}
37
50
51
51
+
message DeleteProfileRequest {
52
52
+
string did = 1 [
53
53
+
(buf.validate.field).required = true
54
54
+
];
55
55
+
}
56
56
+
57
57
+
message DeleteProfileResponse {
58
58
+
optional string error = 1;
59
59
+
}
+38
database/proto/profile_grpc.pb.go
···
20
20
21
21
const (
22
22
ProfileService_GetProfile_FullMethodName = "/vyletdatabase.ProfileService/GetProfile"
23
23
+
ProfileService_DeleteProfile_FullMethodName = "/vyletdatabase.ProfileService/DeleteProfile"
23
24
ProfileService_CreateProfile_FullMethodName = "/vyletdatabase.ProfileService/CreateProfile"
24
25
)
25
26
···
28
29
// 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.
29
30
type ProfileServiceClient interface {
30
31
GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error)
32
32
+
DeleteProfile(ctx context.Context, in *DeleteProfileRequest, opts ...grpc.CallOption) (*DeleteProfileResponse, error)
31
33
CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error)
32
34
}
33
35
···
49
51
return out, nil
50
52
}
51
53
54
54
+
func (c *profileServiceClient) DeleteProfile(ctx context.Context, in *DeleteProfileRequest, opts ...grpc.CallOption) (*DeleteProfileResponse, error) {
55
55
+
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
56
56
+
out := new(DeleteProfileResponse)
57
57
+
err := c.cc.Invoke(ctx, ProfileService_DeleteProfile_FullMethodName, in, out, cOpts...)
58
58
+
if err != nil {
59
59
+
return nil, err
60
60
+
}
61
61
+
return out, nil
62
62
+
}
63
63
+
52
64
func (c *profileServiceClient) CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error) {
53
65
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
54
66
out := new(CreateProfileResponse)
···
64
76
// for forward compatibility.
65
77
type ProfileServiceServer interface {
66
78
GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error)
79
79
+
DeleteProfile(context.Context, *DeleteProfileRequest) (*DeleteProfileResponse, error)
67
80
CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error)
68
81
mustEmbedUnimplementedProfileServiceServer()
69
82
}
···
77
90
78
91
func (UnimplementedProfileServiceServer) GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) {
79
92
return nil, status.Error(codes.Unimplemented, "method GetProfile not implemented")
93
93
+
}
94
94
+
func (UnimplementedProfileServiceServer) DeleteProfile(context.Context, *DeleteProfileRequest) (*DeleteProfileResponse, error) {
95
95
+
return nil, status.Error(codes.Unimplemented, "method DeleteProfile not implemented")
80
96
}
81
97
func (UnimplementedProfileServiceServer) CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error) {
82
98
return nil, status.Error(codes.Unimplemented, "method CreateProfile not implemented")
···
120
136
return interceptor(ctx, in, info, handler)
121
137
}
122
138
139
139
+
func _ProfileService_DeleteProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
140
140
+
in := new(DeleteProfileRequest)
141
141
+
if err := dec(in); err != nil {
142
142
+
return nil, err
143
143
+
}
144
144
+
if interceptor == nil {
145
145
+
return srv.(ProfileServiceServer).DeleteProfile(ctx, in)
146
146
+
}
147
147
+
info := &grpc.UnaryServerInfo{
148
148
+
Server: srv,
149
149
+
FullMethod: ProfileService_DeleteProfile_FullMethodName,
150
150
+
}
151
151
+
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
152
152
+
return srv.(ProfileServiceServer).DeleteProfile(ctx, req.(*DeleteProfileRequest))
153
153
+
}
154
154
+
return interceptor(ctx, in, info, handler)
155
155
+
}
156
156
+
123
157
func _ProfileService_CreateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
124
158
in := new(CreateProfileRequest)
125
159
if err := dec(in); err != nil {
···
148
182
{
149
183
MethodName: "GetProfile",
150
184
Handler: _ProfileService_GetProfile_Handler,
185
185
+
},
186
186
+
{
187
187
+
MethodName: "DeleteProfile",
188
188
+
Handler: _ProfileService_DeleteProfile_Handler,
151
189
},
152
190
{
153
191
MethodName: "CreateProfile",
+61
-4
database/server/profile.go
···
6
6
7
7
vyletdatabase "github.com/vylet-app/go/database/proto"
8
8
"github.com/vylet-app/go/internal/helpers"
9
9
+
"google.golang.org/protobuf/types/known/timestamppb"
9
10
)
10
11
11
12
func (s *Server) CreateProfile(ctx context.Context, req *vyletdatabase.CreateProfileRequest) (*vyletdatabase.CreateProfileResponse, error) {
···
26
27
if err := s.cqlSession.Query(
27
28
`
28
29
INSERT INTO profiles
29
29
-
(did, created_at, indexed_at, updated_at)
30
30
+
(did, display_name, description, pronouns, avatar, created_at, indexed_at, updated_at)
30
31
VALUES
31
31
-
(?, ?, ?, ?)
32
32
-
`, req.Did, createdAtTime, now, now,
32
32
+
(?, ?, ?, ?, ?, ?, ?, ?)
33
33
+
`,
34
34
+
req.Did,
35
35
+
req.DisplayName,
36
36
+
req.Description,
37
37
+
req.Pronouns,
38
38
+
req.Avatar,
39
39
+
createdAtTime,
40
40
+
now,
41
41
+
now,
33
42
).WithContext(ctx).Exec(); err != nil {
34
43
logger.Error("failed to create profile", "did", req.Did, "err", err)
35
44
return &vyletdatabase.CreateProfileResponse{
···
41
50
}
42
51
43
52
func (s *Server) GetProfile(ctx context.Context, req *vyletdatabase.GetProfileRequest) (*vyletdatabase.GetProfileResponse, error) {
44
44
-
return nil, nil
53
53
+
logger := s.logger.With("name", "GetProfile")
54
54
+
55
55
+
resp := &vyletdatabase.GetProfileResponse{}
56
56
+
var createdAt, indexedAt time.Time
57
57
+
58
58
+
if err := s.cqlSession.Query(
59
59
+
`SELECT
60
60
+
did, display_name, description, pronouns, avatar, created_at, indexed_at
61
61
+
FROM profiles
62
62
+
WHERE did = ?
63
63
+
`,
64
64
+
req.Did,
65
65
+
).WithContext(ctx).Scan(
66
66
+
&resp.Did,
67
67
+
&resp.DisplayName,
68
68
+
&resp.Description,
69
69
+
&resp.Pronouns,
70
70
+
&resp.Avatar,
71
71
+
&createdAt,
72
72
+
&indexedAt,
73
73
+
); err != nil {
74
74
+
logger.Error("failed to get profile", "did", req.Did, "err", err)
75
75
+
return &vyletdatabase.GetProfileResponse{
76
76
+
Error: helpers.ToStringPtr(err.Error()),
77
77
+
}, nil
78
78
+
}
79
79
+
80
80
+
resp.CreatedAt = timestamppb.New(createdAt)
81
81
+
resp.IndexedAt = timestamppb.New(indexedAt)
82
82
+
83
83
+
return resp, nil
84
84
+
}
85
85
+
86
86
+
func (s *Server) DeleteProfile(ctx context.Context, req *vyletdatabase.DeleteProfileRequest) (*vyletdatabase.DeleteProfileResponse, error) {
87
87
+
logger := s.logger.With("name", "DeleteProfile")
88
88
+
89
89
+
if err := s.cqlSession.Query(
90
90
+
`
91
91
+
DELETE FROM profiles WHERE did = ?
92
92
+
`,
93
93
+
req.Did,
94
94
+
).WithContext(ctx).Exec(); err != nil {
95
95
+
logger.Error("failed to delete profile", "did", req.Did, "err", err)
96
96
+
return &vyletdatabase.DeleteProfileResponse{
97
97
+
Error: helpers.ToStringPtr(err.Error()),
98
98
+
}, nil
99
99
+
}
100
100
+
101
101
+
return &vyletdatabase.DeleteProfileResponse{}, nil
45
102
}
+27
-6
indexer/actorprofile.go
···
8
8
vyletkafka "github.com/vylet-app/go/bus/proto"
9
9
vyletdatabase "github.com/vylet-app/go/database/proto"
10
10
"github.com/vylet-app/go/generated/vylet"
11
11
+
"github.com/vylet-app/go/internal/helpers"
11
12
)
12
13
13
14
func (s *Server) handleActorProfile(ctx context.Context, evt *vyletkafka.FirehoseEvent) error {
14
15
var rec vylet.ActorProfile
15
16
op := evt.Commit
16
17
17
17
-
if op.Operation == vyletkafka.CommitOperation_COMMIT_OPERATION_CREATE {
18
18
+
switch op.Operation {
19
19
+
case vyletkafka.CommitOperation_COMMIT_OPERATION_CREATE:
18
20
if err := json.Unmarshal(op.Record, &rec); err != nil {
19
21
return fmt.Errorf("failed to unmarshal profile record: %w", err)
20
22
}
21
23
22
22
-
resp, err := s.db.Profile.CreateProfile(ctx, &vyletdatabase.CreateProfileRequest{
23
23
-
Did: evt.Did,
24
24
-
CreatedAt: rec.CreatedAt,
25
25
-
})
24
24
+
req := vyletdatabase.CreateProfileRequest{
25
25
+
Did: evt.Did,
26
26
+
DisplayName: rec.DisplayName,
27
27
+
Description: rec.Description,
28
28
+
Pronouns: rec.Pronouns,
29
29
+
CreatedAt: rec.CreatedAt,
30
30
+
}
31
31
+
32
32
+
if rec.Avatar != nil {
33
33
+
req.Avatar = helpers.ToStringPtr(rec.Avatar.Ref.String())
34
34
+
}
35
35
+
36
36
+
resp, err := s.db.Profile.CreateProfile(ctx, &req)
26
37
if err != nil {
27
38
return fmt.Errorf("failed to create create profile request: %w", err)
28
39
}
29
40
if resp.Error != nil {
30
41
return fmt.Errorf("error creating profile: %s", *resp.Error)
31
42
}
32
32
-
} else {
43
43
+
case vyletkafka.CommitOperation_COMMIT_OPERATION_UPDATE:
33
44
return fmt.Errorf("unhandled operation")
45
45
+
case vyletkafka.CommitOperation_COMMIT_OPERATION_DELETE:
46
46
+
resp, err := s.db.Profile.DeleteProfile(ctx, &vyletdatabase.DeleteProfileRequest{
47
47
+
Did: evt.Did,
48
48
+
})
49
49
+
if err != nil {
50
50
+
return fmt.Errorf("failed to create delete profile request: %w", err)
51
51
+
}
52
52
+
if resp.Error != nil {
53
53
+
return fmt.Errorf("error deleting profile: %s", *resp.Error)
54
54
+
}
34
55
}
35
56
36
57
return nil
+4
migrations/000001_create_profiles_table.up.cql
···
1
1
CREATE TABLE IF NOT EXISTS profiles (
2
2
did TEXT PRIMARY KEY,
3
3
+
display_name TEXT,
4
4
+
description TEXT,
5
5
+
pronouns TEXT,
6
6
+
avatar TEXT,
3
7
created_at TIMESTAMP,
4
8
indexed_at TIMESTAMP,
5
9
updated_at TIMESTAMP,