init post-service

This commit is contained in:
2023-09-27 16:17:47 +01:00
parent e0bd8ef953
commit 0341a938fd
31 changed files with 5666 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
package consumers
import (
"context"
"github.com/rs/zerolog/log"
"github.com/segmentio/kafka-go"
"google.golang.org/protobuf/proto"
"github.com/hexolan/panels/post-service/internal"
"github.com/hexolan/panels/post-service/internal/kafka/producer"
"github.com/hexolan/panels/post-service/internal/kafka/consumers/panelv1"
)
type PanelEventConsumer struct {
reader *kafka.Reader
dbRepo internal.PostDBRepository
eventProd producer.PostEventProducer
}
func NewPanelEventConsumer(cfg internal.Config, dbRepo internal.PostDBRepository, eventProd producer.PostEventProducer) PanelEventConsumer {
return PanelEventConsumer{
reader: kafka.NewReader(kafka.ReaderConfig{
Brokers: cfg.KafkaBrokers,
GroupID: "post-service",
Topic: "panel",
}),
dbRepo: dbRepo,
eventProd: eventProd,
}
}
func (ec PanelEventConsumer) ProcessEvent(evt *panelv1.PanelEvent) {
if evt.GetData() == nil {
log.Error().Str("src", "panel-event-consumer").Any("event", evt).Msg("no event data provided")
return
}
if evt.Type == "deleted" {
postIds, err := ec.dbRepo.DeletePostsOnPanel(context.Background(), evt.GetData().GetId())
if err == nil {
for _, postId := range postIds {
ec.eventProd.DispatchDeletedEvent(postId)
}
}
log.Debug().Str("src", "panel-event-consumer").Any("event", evt).Msg("processed panel deleted event")
}
}
func (ec PanelEventConsumer) ProcessMessage(msg kafka.Message) {
var evt panelv1.PanelEvent
err := proto.Unmarshal(msg.Value, &evt)
if err != nil {
log.Error().Err(err).Str("src", "panel-event-consumer").Msg("failed to unmarshal event")
return
}
ec.ProcessEvent(&evt)
}
func (ec PanelEventConsumer) Start() {
for {
msg, err := ec.reader.FetchMessage(context.Background())
if err != nil {
log.Error().Err(err).Str("src", "panel-event-consumer").Msg("failed to fetch msg from Kafka")
break
}
ec.ProcessMessage(msg)
}
// Attempt to close the reader connection (after experiencing a Kafka error)
if err := ec.reader.Close(); err != nil {
log.Panic().Err(err).Str("src", "panel-event-consumer").Msg("failed to close Kafka reader")
}
}

View File

@@ -0,0 +1,861 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v4.23.4
// source: panel.proto
package panelv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
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 Panel 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"`
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
}
func (x *Panel) Reset() {
*x = Panel{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Panel) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Panel) ProtoMessage() {}
func (x *Panel) ProtoReflect() protoreflect.Message {
mi := &file_panel_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 Panel.ProtoReflect.Descriptor instead.
func (*Panel) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{0}
}
func (x *Panel) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Panel) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Panel) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
func (x *Panel) GetCreatedAt() *timestamppb.Timestamp {
if x != nil {
return x.CreatedAt
}
return nil
}
func (x *Panel) GetUpdatedAt() *timestamppb.Timestamp {
if x != nil {
return x.UpdatedAt
}
return nil
}
type PanelMutable struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name *string `protobuf:"bytes,1,opt,name=name,proto3,oneof" json:"name,omitempty"`
Description *string `protobuf:"bytes,2,opt,name=description,proto3,oneof" json:"description,omitempty"`
}
func (x *PanelMutable) Reset() {
*x = PanelMutable{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PanelMutable) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PanelMutable) ProtoMessage() {}
func (x *PanelMutable) ProtoReflect() protoreflect.Message {
mi := &file_panel_proto_msgTypes[1]
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 PanelMutable.ProtoReflect.Descriptor instead.
func (*PanelMutable) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{1}
}
func (x *PanelMutable) GetName() string {
if x != nil && x.Name != nil {
return *x.Name
}
return ""
}
func (x *PanelMutable) GetDescription() string {
if x != nil && x.Description != nil {
return *x.Description
}
return ""
}
type CreatePanelRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data *PanelMutable `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *CreatePanelRequest) Reset() {
*x = CreatePanelRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreatePanelRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreatePanelRequest) ProtoMessage() {}
func (x *CreatePanelRequest) ProtoReflect() protoreflect.Message {
mi := &file_panel_proto_msgTypes[2]
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 CreatePanelRequest.ProtoReflect.Descriptor instead.
func (*CreatePanelRequest) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{2}
}
func (x *CreatePanelRequest) GetData() *PanelMutable {
if x != nil {
return x.Data
}
return nil
}
type GetPanelByIdRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *GetPanelByIdRequest) Reset() {
*x = GetPanelByIdRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetPanelByIdRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetPanelByIdRequest) ProtoMessage() {}
func (x *GetPanelByIdRequest) ProtoReflect() protoreflect.Message {
mi := &file_panel_proto_msgTypes[3]
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 GetPanelByIdRequest.ProtoReflect.Descriptor instead.
func (*GetPanelByIdRequest) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{3}
}
func (x *GetPanelByIdRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type GetPanelByNameRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}
func (x *GetPanelByNameRequest) Reset() {
*x = GetPanelByNameRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetPanelByNameRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetPanelByNameRequest) ProtoMessage() {}
func (x *GetPanelByNameRequest) ProtoReflect() protoreflect.Message {
mi := &file_panel_proto_msgTypes[4]
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 GetPanelByNameRequest.ProtoReflect.Descriptor instead.
func (*GetPanelByNameRequest) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{4}
}
func (x *GetPanelByNameRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type UpdatePanelByIdRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Data *PanelMutable `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *UpdatePanelByIdRequest) Reset() {
*x = UpdatePanelByIdRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdatePanelByIdRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdatePanelByIdRequest) ProtoMessage() {}
func (x *UpdatePanelByIdRequest) ProtoReflect() protoreflect.Message {
mi := &file_panel_proto_msgTypes[5]
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 UpdatePanelByIdRequest.ProtoReflect.Descriptor instead.
func (*UpdatePanelByIdRequest) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{5}
}
func (x *UpdatePanelByIdRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *UpdatePanelByIdRequest) GetData() *PanelMutable {
if x != nil {
return x.Data
}
return nil
}
type UpdatePanelByNameRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Data *PanelMutable `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *UpdatePanelByNameRequest) Reset() {
*x = UpdatePanelByNameRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdatePanelByNameRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdatePanelByNameRequest) ProtoMessage() {}
func (x *UpdatePanelByNameRequest) ProtoReflect() protoreflect.Message {
mi := &file_panel_proto_msgTypes[6]
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 UpdatePanelByNameRequest.ProtoReflect.Descriptor instead.
func (*UpdatePanelByNameRequest) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{6}
}
func (x *UpdatePanelByNameRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *UpdatePanelByNameRequest) GetData() *PanelMutable {
if x != nil {
return x.Data
}
return nil
}
type DeletePanelByIdRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *DeletePanelByIdRequest) Reset() {
*x = DeletePanelByIdRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeletePanelByIdRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeletePanelByIdRequest) ProtoMessage() {}
func (x *DeletePanelByIdRequest) ProtoReflect() protoreflect.Message {
mi := &file_panel_proto_msgTypes[7]
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 DeletePanelByIdRequest.ProtoReflect.Descriptor instead.
func (*DeletePanelByIdRequest) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{7}
}
func (x *DeletePanelByIdRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type DeletePanelByNameRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}
func (x *DeletePanelByNameRequest) Reset() {
*x = DeletePanelByNameRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeletePanelByNameRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeletePanelByNameRequest) ProtoMessage() {}
func (x *DeletePanelByNameRequest) ProtoReflect() protoreflect.Message {
mi := &file_panel_proto_msgTypes[8]
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 DeletePanelByNameRequest.ProtoReflect.Descriptor instead.
func (*DeletePanelByNameRequest) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{8}
}
func (x *DeletePanelByNameRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
// Kafka Event Schema
type PanelEvent struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
Data *Panel `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *PanelEvent) Reset() {
*x = PanelEvent{}
if protoimpl.UnsafeEnabled {
mi := &file_panel_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PanelEvent) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PanelEvent) ProtoMessage() {}
func (x *PanelEvent) ProtoReflect() protoreflect.Message {
mi := &file_panel_proto_msgTypes[9]
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 PanelEvent.ProtoReflect.Descriptor instead.
func (*PanelEvent) Descriptor() ([]byte, []int) {
return file_panel_proto_rawDescGZIP(), []int{9}
}
func (x *PanelEvent) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *PanelEvent) GetData() *Panel {
if x != nil {
return x.Data
}
return nil
}
var File_panel_proto protoreflect.FileDescriptor
var file_panel_proto_rawDesc = []byte{
0x0a, 0x0b, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x70,
0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x1a, 0x1b,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f,
0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d,
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc3, 0x01, 0x0a,
0x05, 0x50, 0x61, 0x6e, 0x65, 0x6c, 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, 0x20, 0x0a, 0x0b, 0x64, 0x65,
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x0a,
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72,
0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69,
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
0x41, 0x74, 0x22, 0x67, 0x0a, 0x0c, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x4d, 0x75, 0x74, 0x61, 0x62,
0x6c, 0x65, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x48, 0x00, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x25, 0x0a, 0x0b, 0x64,
0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x48, 0x01, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x88,
0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0e, 0x0a, 0x0c, 0x5f,
0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x47, 0x0a, 0x12, 0x43,
0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x31, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x1d, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76,
0x31, 0x2e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x04,
0x64, 0x61, 0x74, 0x61, 0x22, 0x25, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x50, 0x61, 0x6e, 0x65, 0x6c,
0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x2b, 0x0a, 0x15, 0x47,
0x65, 0x74, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x5b, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
0x69, 0x64, 0x12, 0x31, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x1d, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e,
0x76, 0x31, 0x2e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x61, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50,
0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x31, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e,
0x65, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x4d, 0x75, 0x74, 0x61, 0x62,
0x6c, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x28, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
0x69, 0x64, 0x22, 0x2e, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65,
0x6c, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x22, 0x4c, 0x0a, 0x0a, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74,
0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x74, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65,
0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
0x32, 0xd4, 0x04, 0x0a, 0x0c, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x12, 0x4c, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c,
0x12, 0x23, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e,
0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70,
0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x22, 0x00, 0x12,
0x4a, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x12, 0x24, 0x2e, 0x70, 0x61,
0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65,
0x74, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x16, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c,
0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0e, 0x47,
0x65, 0x74, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x2e,
0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x2e,
0x47, 0x65, 0x74, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70,
0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x22, 0x00, 0x12,
0x50, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x12, 0x27,
0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31,
0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x49, 0x64,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73,
0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x22,
0x00, 0x12, 0x58, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c,
0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e,
0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50,
0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x16, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c,
0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x0b, 0x44,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x12, 0x27, 0x2e, 0x70, 0x61, 0x6e,
0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c,
0x65, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x58, 0x0a,
0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x42, 0x79, 0x4e, 0x61,
0x6d, 0x65, 0x12, 0x29, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x61, 0x6e, 0x65,
0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x61, 0x6e, 0x65, 0x6c,
0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_panel_proto_rawDescOnce sync.Once
file_panel_proto_rawDescData = file_panel_proto_rawDesc
)
func file_panel_proto_rawDescGZIP() []byte {
file_panel_proto_rawDescOnce.Do(func() {
file_panel_proto_rawDescData = protoimpl.X.CompressGZIP(file_panel_proto_rawDescData)
})
return file_panel_proto_rawDescData
}
var file_panel_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_panel_proto_goTypes = []interface{}{
(*Panel)(nil), // 0: panels.panel.v1.Panel
(*PanelMutable)(nil), // 1: panels.panel.v1.PanelMutable
(*CreatePanelRequest)(nil), // 2: panels.panel.v1.CreatePanelRequest
(*GetPanelByIdRequest)(nil), // 3: panels.panel.v1.GetPanelByIdRequest
(*GetPanelByNameRequest)(nil), // 4: panels.panel.v1.GetPanelByNameRequest
(*UpdatePanelByIdRequest)(nil), // 5: panels.panel.v1.UpdatePanelByIdRequest
(*UpdatePanelByNameRequest)(nil), // 6: panels.panel.v1.UpdatePanelByNameRequest
(*DeletePanelByIdRequest)(nil), // 7: panels.panel.v1.DeletePanelByIdRequest
(*DeletePanelByNameRequest)(nil), // 8: panels.panel.v1.DeletePanelByNameRequest
(*PanelEvent)(nil), // 9: panels.panel.v1.PanelEvent
(*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp
(*emptypb.Empty)(nil), // 11: google.protobuf.Empty
}
var file_panel_proto_depIdxs = []int32{
10, // 0: panels.panel.v1.Panel.created_at:type_name -> google.protobuf.Timestamp
10, // 1: panels.panel.v1.Panel.updated_at:type_name -> google.protobuf.Timestamp
1, // 2: panels.panel.v1.CreatePanelRequest.data:type_name -> panels.panel.v1.PanelMutable
1, // 3: panels.panel.v1.UpdatePanelByIdRequest.data:type_name -> panels.panel.v1.PanelMutable
1, // 4: panels.panel.v1.UpdatePanelByNameRequest.data:type_name -> panels.panel.v1.PanelMutable
0, // 5: panels.panel.v1.PanelEvent.data:type_name -> panels.panel.v1.Panel
2, // 6: panels.panel.v1.PanelService.CreatePanel:input_type -> panels.panel.v1.CreatePanelRequest
3, // 7: panels.panel.v1.PanelService.GetPanel:input_type -> panels.panel.v1.GetPanelByIdRequest
4, // 8: panels.panel.v1.PanelService.GetPanelByName:input_type -> panels.panel.v1.GetPanelByNameRequest
5, // 9: panels.panel.v1.PanelService.UpdatePanel:input_type -> panels.panel.v1.UpdatePanelByIdRequest
6, // 10: panels.panel.v1.PanelService.UpdatePanelByName:input_type -> panels.panel.v1.UpdatePanelByNameRequest
7, // 11: panels.panel.v1.PanelService.DeletePanel:input_type -> panels.panel.v1.DeletePanelByIdRequest
8, // 12: panels.panel.v1.PanelService.DeletePanelByName:input_type -> panels.panel.v1.DeletePanelByNameRequest
0, // 13: panels.panel.v1.PanelService.CreatePanel:output_type -> panels.panel.v1.Panel
0, // 14: panels.panel.v1.PanelService.GetPanel:output_type -> panels.panel.v1.Panel
0, // 15: panels.panel.v1.PanelService.GetPanelByName:output_type -> panels.panel.v1.Panel
0, // 16: panels.panel.v1.PanelService.UpdatePanel:output_type -> panels.panel.v1.Panel
0, // 17: panels.panel.v1.PanelService.UpdatePanelByName:output_type -> panels.panel.v1.Panel
11, // 18: panels.panel.v1.PanelService.DeletePanel:output_type -> google.protobuf.Empty
11, // 19: panels.panel.v1.PanelService.DeletePanelByName:output_type -> google.protobuf.Empty
13, // [13:20] is the sub-list for method output_type
6, // [6:13] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_panel_proto_init() }
func file_panel_proto_init() {
if File_panel_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_panel_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Panel); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_panel_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PanelMutable); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_panel_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreatePanelRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_panel_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetPanelByIdRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_panel_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetPanelByNameRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_panel_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdatePanelByIdRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_panel_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdatePanelByNameRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_panel_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeletePanelByIdRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_panel_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeletePanelByNameRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_panel_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PanelEvent); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_panel_proto_msgTypes[1].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_panel_proto_rawDesc,
NumEnums: 0,
NumMessages: 10,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_panel_proto_goTypes,
DependencyIndexes: file_panel_proto_depIdxs,
MessageInfos: file_panel_proto_msgTypes,
}.Build()
File_panel_proto = out.File
file_panel_proto_rawDesc = nil
file_panel_proto_goTypes = nil
file_panel_proto_depIdxs = nil
}

View File

@@ -0,0 +1,322 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v4.23.4
// source: panel.proto
package panelv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
emptypb "google.golang.org/protobuf/types/known/emptypb"
)
// 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
// PanelServiceClient is the client API for PanelService 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 PanelServiceClient interface {
CreatePanel(ctx context.Context, in *CreatePanelRequest, opts ...grpc.CallOption) (*Panel, error)
GetPanel(ctx context.Context, in *GetPanelByIdRequest, opts ...grpc.CallOption) (*Panel, error)
GetPanelByName(ctx context.Context, in *GetPanelByNameRequest, opts ...grpc.CallOption) (*Panel, error)
UpdatePanel(ctx context.Context, in *UpdatePanelByIdRequest, opts ...grpc.CallOption) (*Panel, error)
UpdatePanelByName(ctx context.Context, in *UpdatePanelByNameRequest, opts ...grpc.CallOption) (*Panel, error)
DeletePanel(ctx context.Context, in *DeletePanelByIdRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
DeletePanelByName(ctx context.Context, in *DeletePanelByNameRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}
type panelServiceClient struct {
cc grpc.ClientConnInterface
}
func NewPanelServiceClient(cc grpc.ClientConnInterface) PanelServiceClient {
return &panelServiceClient{cc}
}
func (c *panelServiceClient) CreatePanel(ctx context.Context, in *CreatePanelRequest, opts ...grpc.CallOption) (*Panel, error) {
out := new(Panel)
err := c.cc.Invoke(ctx, "/panels.panel.v1.PanelService/CreatePanel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *panelServiceClient) GetPanel(ctx context.Context, in *GetPanelByIdRequest, opts ...grpc.CallOption) (*Panel, error) {
out := new(Panel)
err := c.cc.Invoke(ctx, "/panels.panel.v1.PanelService/GetPanel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *panelServiceClient) GetPanelByName(ctx context.Context, in *GetPanelByNameRequest, opts ...grpc.CallOption) (*Panel, error) {
out := new(Panel)
err := c.cc.Invoke(ctx, "/panels.panel.v1.PanelService/GetPanelByName", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *panelServiceClient) UpdatePanel(ctx context.Context, in *UpdatePanelByIdRequest, opts ...grpc.CallOption) (*Panel, error) {
out := new(Panel)
err := c.cc.Invoke(ctx, "/panels.panel.v1.PanelService/UpdatePanel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *panelServiceClient) UpdatePanelByName(ctx context.Context, in *UpdatePanelByNameRequest, opts ...grpc.CallOption) (*Panel, error) {
out := new(Panel)
err := c.cc.Invoke(ctx, "/panels.panel.v1.PanelService/UpdatePanelByName", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *panelServiceClient) DeletePanel(ctx context.Context, in *DeletePanelByIdRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/panels.panel.v1.PanelService/DeletePanel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *panelServiceClient) DeletePanelByName(ctx context.Context, in *DeletePanelByNameRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/panels.panel.v1.PanelService/DeletePanelByName", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// PanelServiceServer is the server API for PanelService service.
// All implementations must embed UnimplementedPanelServiceServer
// for forward compatibility
type PanelServiceServer interface {
CreatePanel(context.Context, *CreatePanelRequest) (*Panel, error)
GetPanel(context.Context, *GetPanelByIdRequest) (*Panel, error)
GetPanelByName(context.Context, *GetPanelByNameRequest) (*Panel, error)
UpdatePanel(context.Context, *UpdatePanelByIdRequest) (*Panel, error)
UpdatePanelByName(context.Context, *UpdatePanelByNameRequest) (*Panel, error)
DeletePanel(context.Context, *DeletePanelByIdRequest) (*emptypb.Empty, error)
DeletePanelByName(context.Context, *DeletePanelByNameRequest) (*emptypb.Empty, error)
mustEmbedUnimplementedPanelServiceServer()
}
// UnimplementedPanelServiceServer must be embedded to have forward compatible implementations.
type UnimplementedPanelServiceServer struct {
}
func (UnimplementedPanelServiceServer) CreatePanel(context.Context, *CreatePanelRequest) (*Panel, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreatePanel not implemented")
}
func (UnimplementedPanelServiceServer) GetPanel(context.Context, *GetPanelByIdRequest) (*Panel, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetPanel not implemented")
}
func (UnimplementedPanelServiceServer) GetPanelByName(context.Context, *GetPanelByNameRequest) (*Panel, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetPanelByName not implemented")
}
func (UnimplementedPanelServiceServer) UpdatePanel(context.Context, *UpdatePanelByIdRequest) (*Panel, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdatePanel not implemented")
}
func (UnimplementedPanelServiceServer) UpdatePanelByName(context.Context, *UpdatePanelByNameRequest) (*Panel, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdatePanelByName not implemented")
}
func (UnimplementedPanelServiceServer) DeletePanel(context.Context, *DeletePanelByIdRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeletePanel not implemented")
}
func (UnimplementedPanelServiceServer) DeletePanelByName(context.Context, *DeletePanelByNameRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeletePanelByName not implemented")
}
func (UnimplementedPanelServiceServer) mustEmbedUnimplementedPanelServiceServer() {}
// UnsafePanelServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to PanelServiceServer will
// result in compilation errors.
type UnsafePanelServiceServer interface {
mustEmbedUnimplementedPanelServiceServer()
}
func RegisterPanelServiceServer(s grpc.ServiceRegistrar, srv PanelServiceServer) {
s.RegisterService(&PanelService_ServiceDesc, srv)
}
func _PanelService_CreatePanel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreatePanelRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PanelServiceServer).CreatePanel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/CreatePanel",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).CreatePanel(ctx, req.(*CreatePanelRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PanelService_GetPanel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetPanelByIdRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PanelServiceServer).GetPanel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/GetPanel",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).GetPanel(ctx, req.(*GetPanelByIdRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PanelService_GetPanelByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetPanelByNameRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PanelServiceServer).GetPanelByName(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/GetPanelByName",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).GetPanelByName(ctx, req.(*GetPanelByNameRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PanelService_UpdatePanel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdatePanelByIdRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PanelServiceServer).UpdatePanel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/UpdatePanel",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).UpdatePanel(ctx, req.(*UpdatePanelByIdRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PanelService_UpdatePanelByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdatePanelByNameRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PanelServiceServer).UpdatePanelByName(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/UpdatePanelByName",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).UpdatePanelByName(ctx, req.(*UpdatePanelByNameRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PanelService_DeletePanel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeletePanelByIdRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PanelServiceServer).DeletePanel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/DeletePanel",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).DeletePanel(ctx, req.(*DeletePanelByIdRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PanelService_DeletePanelByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeletePanelByNameRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PanelServiceServer).DeletePanelByName(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/DeletePanelByName",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).DeletePanelByName(ctx, req.(*DeletePanelByNameRequest))
}
return interceptor(ctx, in, info, handler)
}
// PanelService_ServiceDesc is the grpc.ServiceDesc for PanelService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var PanelService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "panels.panel.v1.PanelService",
HandlerType: (*PanelServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreatePanel",
Handler: _PanelService_CreatePanel_Handler,
},
{
MethodName: "GetPanel",
Handler: _PanelService_GetPanel_Handler,
},
{
MethodName: "GetPanelByName",
Handler: _PanelService_GetPanelByName_Handler,
},
{
MethodName: "UpdatePanel",
Handler: _PanelService_UpdatePanel_Handler,
},
{
MethodName: "UpdatePanelByName",
Handler: _PanelService_UpdatePanelByName_Handler,
},
{
MethodName: "DeletePanel",
Handler: _PanelService_DeletePanel_Handler,
},
{
MethodName: "DeletePanelByName",
Handler: _PanelService_DeletePanelByName_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "panel.proto",
}

View File

@@ -0,0 +1,75 @@
package consumers
import (
"context"
"github.com/rs/zerolog/log"
"github.com/segmentio/kafka-go"
"google.golang.org/protobuf/proto"
"github.com/hexolan/panels/post-service/internal"
"github.com/hexolan/panels/post-service/internal/kafka/producer"
"github.com/hexolan/panels/post-service/internal/kafka/consumers/userv1"
)
type UserEventConsumer struct {
reader *kafka.Reader
dbRepo internal.PostDBRepository
eventProd producer.PostEventProducer
}
func NewUserEventConsumer(cfg internal.Config, dbRepo internal.PostDBRepository, eventProd producer.PostEventProducer) UserEventConsumer {
return UserEventConsumer{
reader: kafka.NewReader(kafka.ReaderConfig{
Brokers: cfg.KafkaBrokers,
GroupID: "post-service",
Topic: "user",
}),
dbRepo: dbRepo,
}
}
func (ec UserEventConsumer) ProcessEvent(evt *userv1.UserEvent) {
if evt.GetData() == nil {
log.Error().Str("src", "user-event-consumer").Any("event", evt).Msg("no event data provided")
return
}
if evt.Type == "deleted" {
postIds, err := ec.dbRepo.DeletePostsByUser(context.Background(), evt.GetData().GetId())
if err == nil {
for _, postId := range postIds {
ec.eventProd.DispatchDeletedEvent(postId)
}
}
log.Debug().Str("src", "user-event-consumer").Any("event", evt).Msg("processed user deleted event")
}
}
func (ec UserEventConsumer) ProcessMessage(msg kafka.Message) {
var evt userv1.UserEvent
err := proto.Unmarshal(msg.Value, &evt)
if err != nil {
log.Error().Err(err).Str("src", "user-event-consumer").Msg("failed to unmarshal event")
return
}
ec.ProcessEvent(&evt)
}
func (ec UserEventConsumer) Start() {
for {
msg, err := ec.reader.FetchMessage(context.Background())
if err != nil {
log.Error().Err(err).Str("src", "user-event-consumer").Msg("failed to fetch msg from Kafka")
break
}
ec.ProcessMessage(msg)
}
// Attempt to close the reader connection (after experiencing a Kafka error)
if err := ec.reader.Close(); err != nil {
log.Panic().Err(err).Str("src", "user-event-consumer").Msg("failed to close Kafka reader")
}
}

View File

@@ -0,0 +1,849 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v4.23.4
// source: user.proto
package userv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
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 User struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
IsAdmin bool `protobuf:"varint,3,opt,name=is_admin,json=isAdmin,proto3" json:"is_admin,omitempty"`
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
}
func (x *User) Reset() {
*x = User{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *User) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*User) ProtoMessage() {}
func (x *User) ProtoReflect() protoreflect.Message {
mi := &file_user_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 User.ProtoReflect.Descriptor instead.
func (*User) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{0}
}
func (x *User) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *User) GetUsername() string {
if x != nil {
return x.Username
}
return ""
}
func (x *User) GetIsAdmin() bool {
if x != nil {
return x.IsAdmin
}
return false
}
func (x *User) GetCreatedAt() *timestamppb.Timestamp {
if x != nil {
return x.CreatedAt
}
return nil
}
func (x *User) GetUpdatedAt() *timestamppb.Timestamp {
if x != nil {
return x.UpdatedAt
}
return nil
}
type UserMutable struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Username *string `protobuf:"bytes,1,opt,name=username,proto3,oneof" json:"username,omitempty"`
}
func (x *UserMutable) Reset() {
*x = UserMutable{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserMutable) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserMutable) ProtoMessage() {}
func (x *UserMutable) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[1]
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 UserMutable.ProtoReflect.Descriptor instead.
func (*UserMutable) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{1}
}
func (x *UserMutable) GetUsername() string {
if x != nil && x.Username != nil {
return *x.Username
}
return ""
}
type CreateUserRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data *UserMutable `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *CreateUserRequest) Reset() {
*x = CreateUserRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateUserRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateUserRequest) ProtoMessage() {}
func (x *CreateUserRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[2]
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 CreateUserRequest.ProtoReflect.Descriptor instead.
func (*CreateUserRequest) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{2}
}
func (x *CreateUserRequest) GetData() *UserMutable {
if x != nil {
return x.Data
}
return nil
}
type GetUserByIdRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *GetUserByIdRequest) Reset() {
*x = GetUserByIdRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetUserByIdRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserByIdRequest) ProtoMessage() {}
func (x *GetUserByIdRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[3]
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 GetUserByIdRequest.ProtoReflect.Descriptor instead.
func (*GetUserByIdRequest) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{3}
}
func (x *GetUserByIdRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type GetUserByNameRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
}
func (x *GetUserByNameRequest) Reset() {
*x = GetUserByNameRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetUserByNameRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserByNameRequest) ProtoMessage() {}
func (x *GetUserByNameRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[4]
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 GetUserByNameRequest.ProtoReflect.Descriptor instead.
func (*GetUserByNameRequest) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{4}
}
func (x *GetUserByNameRequest) GetUsername() string {
if x != nil {
return x.Username
}
return ""
}
type UpdateUserByIdRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Data *UserMutable `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *UpdateUserByIdRequest) Reset() {
*x = UpdateUserByIdRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateUserByIdRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateUserByIdRequest) ProtoMessage() {}
func (x *UpdateUserByIdRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[5]
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 UpdateUserByIdRequest.ProtoReflect.Descriptor instead.
func (*UpdateUserByIdRequest) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{5}
}
func (x *UpdateUserByIdRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *UpdateUserByIdRequest) GetData() *UserMutable {
if x != nil {
return x.Data
}
return nil
}
type UpdateUserByNameRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
Data *UserMutable `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *UpdateUserByNameRequest) Reset() {
*x = UpdateUserByNameRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateUserByNameRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateUserByNameRequest) ProtoMessage() {}
func (x *UpdateUserByNameRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[6]
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 UpdateUserByNameRequest.ProtoReflect.Descriptor instead.
func (*UpdateUserByNameRequest) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{6}
}
func (x *UpdateUserByNameRequest) GetUsername() string {
if x != nil {
return x.Username
}
return ""
}
func (x *UpdateUserByNameRequest) GetData() *UserMutable {
if x != nil {
return x.Data
}
return nil
}
type DeleteUserByIdRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *DeleteUserByIdRequest) Reset() {
*x = DeleteUserByIdRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteUserByIdRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteUserByIdRequest) ProtoMessage() {}
func (x *DeleteUserByIdRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[7]
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 DeleteUserByIdRequest.ProtoReflect.Descriptor instead.
func (*DeleteUserByIdRequest) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{7}
}
func (x *DeleteUserByIdRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type DeleteUserByNameRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
}
func (x *DeleteUserByNameRequest) Reset() {
*x = DeleteUserByNameRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteUserByNameRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteUserByNameRequest) ProtoMessage() {}
func (x *DeleteUserByNameRequest) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[8]
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 DeleteUserByNameRequest.ProtoReflect.Descriptor instead.
func (*DeleteUserByNameRequest) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{8}
}
func (x *DeleteUserByNameRequest) GetUsername() string {
if x != nil {
return x.Username
}
return ""
}
// Kafka Event Schema
type UserEvent struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
Data *User `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *UserEvent) Reset() {
*x = UserEvent{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserEvent) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserEvent) ProtoMessage() {}
func (x *UserEvent) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[9]
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 UserEvent.ProtoReflect.Descriptor instead.
func (*UserEvent) Descriptor() ([]byte, []int) {
return file_user_proto_rawDescGZIP(), []int{9}
}
func (x *UserEvent) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *UserEvent) GetData() *User {
if x != nil {
return x.Data
}
return nil
}
var File_user_proto protoreflect.FileDescriptor
var file_user_proto_rawDesc = []byte{
0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x70, 0x61,
0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x1a, 0x1b, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d,
0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73,
0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc3, 0x01, 0x0a, 0x04, 0x55,
0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12,
0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28,
0x08, 0x52, 0x07, 0x69, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72,
0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61,
0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65,
0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74,
0x22, 0x3b, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12,
0x1f, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x48, 0x00, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01,
0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x44, 0x0a,
0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x2f, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x1b, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76,
0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x04, 0x64,
0x61, 0x74, 0x61, 0x22, 0x24, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79,
0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x32, 0x0a, 0x14, 0x47, 0x65, 0x74,
0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x58, 0x0a,
0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x49, 0x64, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2f, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73,
0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c,
0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x66, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2f,
0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70,
0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73,
0x65, 0x72, 0x4d, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22,
0x27, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x49,
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x35, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22,
0x49, 0x0a, 0x09, 0x55, 0x73, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14,
0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e,
0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0xb4, 0x04, 0x0a, 0x0b, 0x55,
0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x21, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c,
0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x61,
0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65,
0x72, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x22,
0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e,
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72,
0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0d, 0x47, 0x65,
0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x2e, 0x70, 0x61,
0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74,
0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x14, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e,
0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0a, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73,
0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55,
0x73, 0x65, 0x72, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14,
0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e,
0x55, 0x73, 0x65, 0x72, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x27, 0x2e, 0x70, 0x61, 0x6e,
0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65,
0x72, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0a, 0x44,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x70, 0x61, 0x6e, 0x65,
0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x10, 0x44, 0x65,
0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x27,
0x2e, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x73, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x4e, 0x61, 0x6d, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22,
0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_user_proto_rawDescOnce sync.Once
file_user_proto_rawDescData = file_user_proto_rawDesc
)
func file_user_proto_rawDescGZIP() []byte {
file_user_proto_rawDescOnce.Do(func() {
file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData)
})
return file_user_proto_rawDescData
}
var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_user_proto_goTypes = []interface{}{
(*User)(nil), // 0: panels.user.v1.User
(*UserMutable)(nil), // 1: panels.user.v1.UserMutable
(*CreateUserRequest)(nil), // 2: panels.user.v1.CreateUserRequest
(*GetUserByIdRequest)(nil), // 3: panels.user.v1.GetUserByIdRequest
(*GetUserByNameRequest)(nil), // 4: panels.user.v1.GetUserByNameRequest
(*UpdateUserByIdRequest)(nil), // 5: panels.user.v1.UpdateUserByIdRequest
(*UpdateUserByNameRequest)(nil), // 6: panels.user.v1.UpdateUserByNameRequest
(*DeleteUserByIdRequest)(nil), // 7: panels.user.v1.DeleteUserByIdRequest
(*DeleteUserByNameRequest)(nil), // 8: panels.user.v1.DeleteUserByNameRequest
(*UserEvent)(nil), // 9: panels.user.v1.UserEvent
(*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp
(*emptypb.Empty)(nil), // 11: google.protobuf.Empty
}
var file_user_proto_depIdxs = []int32{
10, // 0: panels.user.v1.User.created_at:type_name -> google.protobuf.Timestamp
10, // 1: panels.user.v1.User.updated_at:type_name -> google.protobuf.Timestamp
1, // 2: panels.user.v1.CreateUserRequest.data:type_name -> panels.user.v1.UserMutable
1, // 3: panels.user.v1.UpdateUserByIdRequest.data:type_name -> panels.user.v1.UserMutable
1, // 4: panels.user.v1.UpdateUserByNameRequest.data:type_name -> panels.user.v1.UserMutable
0, // 5: panels.user.v1.UserEvent.data:type_name -> panels.user.v1.User
2, // 6: panels.user.v1.UserService.CreateUser:input_type -> panels.user.v1.CreateUserRequest
3, // 7: panels.user.v1.UserService.GetUser:input_type -> panels.user.v1.GetUserByIdRequest
4, // 8: panels.user.v1.UserService.GetUserByName:input_type -> panels.user.v1.GetUserByNameRequest
5, // 9: panels.user.v1.UserService.UpdateUser:input_type -> panels.user.v1.UpdateUserByIdRequest
6, // 10: panels.user.v1.UserService.UpdateUserByName:input_type -> panels.user.v1.UpdateUserByNameRequest
7, // 11: panels.user.v1.UserService.DeleteUser:input_type -> panels.user.v1.DeleteUserByIdRequest
8, // 12: panels.user.v1.UserService.DeleteUserByName:input_type -> panels.user.v1.DeleteUserByNameRequest
0, // 13: panels.user.v1.UserService.CreateUser:output_type -> panels.user.v1.User
0, // 14: panels.user.v1.UserService.GetUser:output_type -> panels.user.v1.User
0, // 15: panels.user.v1.UserService.GetUserByName:output_type -> panels.user.v1.User
0, // 16: panels.user.v1.UserService.UpdateUser:output_type -> panels.user.v1.User
0, // 17: panels.user.v1.UserService.UpdateUserByName:output_type -> panels.user.v1.User
11, // 18: panels.user.v1.UserService.DeleteUser:output_type -> google.protobuf.Empty
11, // 19: panels.user.v1.UserService.DeleteUserByName:output_type -> google.protobuf.Empty
13, // [13:20] is the sub-list for method output_type
6, // [6:13] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_user_proto_init() }
func file_user_proto_init() {
if File_user_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*User); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserMutable); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateUserRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserByIdRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserByNameRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateUserByIdRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateUserByNameRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteUserByIdRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteUserByNameRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserEvent); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_user_proto_msgTypes[1].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_user_proto_rawDesc,
NumEnums: 0,
NumMessages: 10,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_user_proto_goTypes,
DependencyIndexes: file_user_proto_depIdxs,
MessageInfos: file_user_proto_msgTypes,
}.Build()
File_user_proto = out.File
file_user_proto_rawDesc = nil
file_user_proto_goTypes = nil
file_user_proto_depIdxs = nil
}

View File

@@ -0,0 +1,322 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v4.23.4
// source: user.proto
package userv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
emptypb "google.golang.org/protobuf/types/known/emptypb"
)
// 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
// UserServiceClient is the client API for UserService 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 UserServiceClient interface {
CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*User, error)
GetUser(ctx context.Context, in *GetUserByIdRequest, opts ...grpc.CallOption) (*User, error)
GetUserByName(ctx context.Context, in *GetUserByNameRequest, opts ...grpc.CallOption) (*User, error)
UpdateUser(ctx context.Context, in *UpdateUserByIdRequest, opts ...grpc.CallOption) (*User, error)
UpdateUserByName(ctx context.Context, in *UpdateUserByNameRequest, opts ...grpc.CallOption) (*User, error)
DeleteUser(ctx context.Context, in *DeleteUserByIdRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
DeleteUserByName(ctx context.Context, in *DeleteUserByNameRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}
type userServiceClient struct {
cc grpc.ClientConnInterface
}
func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient {
return &userServiceClient{cc}
}
func (c *userServiceClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*User, error) {
out := new(User)
err := c.cc.Invoke(ctx, "/panels.user.v1.UserService/CreateUser", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserByIdRequest, opts ...grpc.CallOption) (*User, error) {
out := new(User)
err := c.cc.Invoke(ctx, "/panels.user.v1.UserService/GetUser", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) GetUserByName(ctx context.Context, in *GetUserByNameRequest, opts ...grpc.CallOption) (*User, error) {
out := new(User)
err := c.cc.Invoke(ctx, "/panels.user.v1.UserService/GetUserByName", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) UpdateUser(ctx context.Context, in *UpdateUserByIdRequest, opts ...grpc.CallOption) (*User, error) {
out := new(User)
err := c.cc.Invoke(ctx, "/panels.user.v1.UserService/UpdateUser", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) UpdateUserByName(ctx context.Context, in *UpdateUserByNameRequest, opts ...grpc.CallOption) (*User, error) {
out := new(User)
err := c.cc.Invoke(ctx, "/panels.user.v1.UserService/UpdateUserByName", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) DeleteUser(ctx context.Context, in *DeleteUserByIdRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/panels.user.v1.UserService/DeleteUser", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) DeleteUserByName(ctx context.Context, in *DeleteUserByNameRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/panels.user.v1.UserService/DeleteUserByName", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// UserServiceServer is the server API for UserService service.
// All implementations must embed UnimplementedUserServiceServer
// for forward compatibility
type UserServiceServer interface {
CreateUser(context.Context, *CreateUserRequest) (*User, error)
GetUser(context.Context, *GetUserByIdRequest) (*User, error)
GetUserByName(context.Context, *GetUserByNameRequest) (*User, error)
UpdateUser(context.Context, *UpdateUserByIdRequest) (*User, error)
UpdateUserByName(context.Context, *UpdateUserByNameRequest) (*User, error)
DeleteUser(context.Context, *DeleteUserByIdRequest) (*emptypb.Empty, error)
DeleteUserByName(context.Context, *DeleteUserByNameRequest) (*emptypb.Empty, error)
mustEmbedUnimplementedUserServiceServer()
}
// UnimplementedUserServiceServer must be embedded to have forward compatible implementations.
type UnimplementedUserServiceServer struct {
}
func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserRequest) (*User, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented")
}
func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserByIdRequest) (*User, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
}
func (UnimplementedUserServiceServer) GetUserByName(context.Context, *GetUserByNameRequest) (*User, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserByName not implemented")
}
func (UnimplementedUserServiceServer) UpdateUser(context.Context, *UpdateUserByIdRequest) (*User, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateUser not implemented")
}
func (UnimplementedUserServiceServer) UpdateUserByName(context.Context, *UpdateUserByNameRequest) (*User, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateUserByName not implemented")
}
func (UnimplementedUserServiceServer) DeleteUser(context.Context, *DeleteUserByIdRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented")
}
func (UnimplementedUserServiceServer) DeleteUserByName(context.Context, *DeleteUserByNameRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteUserByName not implemented")
}
func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {}
// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to UserServiceServer will
// result in compilation errors.
type UnsafeUserServiceServer interface {
mustEmbedUnimplementedUserServiceServer()
}
func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) {
s.RegisterService(&UserService_ServiceDesc, srv)
}
func _UserService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).CreateUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/CreateUser",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).CreateUser(ctx, req.(*CreateUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserByIdRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).GetUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/GetUser",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserByIdRequest))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_GetUserByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserByNameRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).GetUserByName(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/GetUserByName",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).GetUserByName(ctx, req.(*GetUserByNameRequest))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateUserByIdRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).UpdateUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/UpdateUser",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).UpdateUser(ctx, req.(*UpdateUserByIdRequest))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_UpdateUserByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateUserByNameRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).UpdateUserByName(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/UpdateUserByName",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).UpdateUserByName(ctx, req.(*UpdateUserByNameRequest))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteUserByIdRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).DeleteUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/DeleteUser",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).DeleteUser(ctx, req.(*DeleteUserByIdRequest))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_DeleteUserByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteUserByNameRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).DeleteUserByName(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/DeleteUserByName",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).DeleteUserByName(ctx, req.(*DeleteUserByNameRequest))
}
return interceptor(ctx, in, info, handler)
}
// UserService_ServiceDesc is the grpc.ServiceDesc for UserService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var UserService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "panels.user.v1.UserService",
HandlerType: (*UserServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateUser",
Handler: _UserService_CreateUser_Handler,
},
{
MethodName: "GetUser",
Handler: _UserService_GetUser_Handler,
},
{
MethodName: "GetUserByName",
Handler: _UserService_GetUserByName_Handler,
},
{
MethodName: "UpdateUser",
Handler: _UserService_UpdateUser_Handler,
},
{
MethodName: "UpdateUserByName",
Handler: _UserService_UpdateUserByName_Handler,
},
{
MethodName: "DeleteUser",
Handler: _UserService_DeleteUser_Handler,
},
{
MethodName: "DeleteUserByName",
Handler: _UserService_DeleteUserByName_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "user.proto",
}

View File

@@ -0,0 +1,23 @@
package kafka
import (
"github.com/hexolan/panels/post-service/internal"
"github.com/hexolan/panels/post-service/internal/kafka/producer"
"github.com/hexolan/panels/post-service/internal/kafka/consumers"
)
type eventConsumers struct {
userEC consumers.UserEventConsumer
panelEC consumers.PanelEventConsumer
}
func NewEventConsumers(cfg internal.Config, dbRepo internal.PostDBRepository, eventProd producer.PostEventProducer) eventConsumers {
return eventConsumers{
userEC: consumers.NewUserEventConsumer(cfg, dbRepo, eventProd),
panelEC: consumers.NewPanelEventConsumer(cfg, dbRepo, eventProd),
}
}
func (ecs eventConsumers) Start() {
go ecs.panelEC.Start()
}

View File

@@ -0,0 +1,60 @@
package producer
import (
"context"
"github.com/rs/zerolog/log"
"github.com/segmentio/kafka-go"
"google.golang.org/protobuf/proto"
"github.com/hexolan/panels/post-service/internal"
"github.com/hexolan/panels/post-service/internal/rpc/postv1"
)
type PostEventProducer struct {
writer *kafka.Writer
}
func NewPostEventProducer(cfg internal.Config) PostEventProducer {
writer := &kafka.Writer{
Addr: kafka.TCP(cfg.KafkaBrokers...),
Topic: "post",
Balancer: &kafka.LeastBytes{},
}
return PostEventProducer{writer: writer}
}
func (ep PostEventProducer) SendEvent(event *postv1.PostEvent) {
evtBytes, err := proto.Marshal(event)
if err != nil {
log.Panic().Err(err).Msg("failed to marshal event")
}
// Write to kafka
err = ep.writer.WriteMessages(context.Background(), kafka.Message{Value: evtBytes})
if err != nil {
log.Panic().Err(err).Msg("failed to dispatch event")
}
}
func (ep PostEventProducer) DispatchCreatedEvent(post *internal.Post) {
go ep.SendEvent(&postv1.PostEvent{
Type: "created",
Data: postv1.PostToProto(post),
})
}
func (ep PostEventProducer) DispatchUpdatedEvent(post *internal.Post) {
go ep.SendEvent(&postv1.PostEvent{
Type: "updated",
Data: postv1.PostToProto(post),
})
}
func (ep PostEventProducer) DispatchDeletedEvent(id internal.PostId) {
go ep.SendEvent(&postv1.PostEvent{
Type: "deleted",
Data: &postv1.Post{Id: id.GetReprId()},
})
}