style: license headers + gofmt

This commit is contained in:
2024-03-27 11:12:43 +00:00
parent e9a1653c4e
commit 4d9a7a4856
109 changed files with 2059 additions and 530 deletions

View File

@@ -1,3 +1,17 @@
// Copyright 2023 Declan Teevan
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package consumers
import (
@@ -8,14 +22,14 @@ import (
"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"
"github.com/hexolan/panels/post-service/internal/kafka/producer"
)
type PanelEventConsumer struct {
reader *kafka.Reader
dbRepo internal.PostDBRepository
dbRepo internal.PostDBRepository
eventProd producer.PostEventProducer
}
@@ -24,9 +38,9 @@ func NewPanelEventConsumer(cfg internal.Config, dbRepo internal.PostDBRepository
reader: kafka.NewReader(kafka.ReaderConfig{
Brokers: cfg.KafkaBrokers,
GroupID: "post-service",
Topic: "panel",
Topic: "panel",
}),
dbRepo: dbRepo,
dbRepo: dbRepo,
eventProd: eventProd,
}
}
@@ -42,7 +56,7 @@ func (ec PanelEventConsumer) ProcessEvent(evt *panelv1.PanelEvent) {
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")
}
@@ -73,4 +87,4 @@ func (ec PanelEventConsumer) Start() {
if err := ec.reader.Close(); err != nil {
log.Panic().Err(err).Str("src", "panel-event-consumer").Msg("failed to close Kafka reader")
}
}
}

View File

@@ -1,6 +1,20 @@
// Copyright 2023 Declan Teevan
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc-gen-go v1.31.0
// protoc v4.23.4
// source: panel.proto

View File

@@ -1,6 +1,20 @@
// Copyright 2023 Declan Teevan
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc-gen-go-grpc v1.3.0
// - protoc v4.23.4
// source: panel.proto
@@ -19,6 +33,16 @@ import (
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
PanelService_CreatePanel_FullMethodName = "/panels.panel.v1.PanelService/CreatePanel"
PanelService_GetPanel_FullMethodName = "/panels.panel.v1.PanelService/GetPanel"
PanelService_GetPanelByName_FullMethodName = "/panels.panel.v1.PanelService/GetPanelByName"
PanelService_UpdatePanel_FullMethodName = "/panels.panel.v1.PanelService/UpdatePanel"
PanelService_UpdatePanelByName_FullMethodName = "/panels.panel.v1.PanelService/UpdatePanelByName"
PanelService_DeletePanel_FullMethodName = "/panels.panel.v1.PanelService/DeletePanel"
PanelService_DeletePanelByName_FullMethodName = "/panels.panel.v1.PanelService/DeletePanelByName"
)
// 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.
@@ -42,7 +66,7 @@ func NewPanelServiceClient(cc grpc.ClientConnInterface) PanelServiceClient {
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...)
err := c.cc.Invoke(ctx, PanelService_CreatePanel_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -51,7 +75,7 @@ func (c *panelServiceClient) CreatePanel(ctx context.Context, in *CreatePanelReq
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...)
err := c.cc.Invoke(ctx, PanelService_GetPanel_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -60,7 +84,7 @@ func (c *panelServiceClient) GetPanel(ctx context.Context, in *GetPanelByIdReque
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...)
err := c.cc.Invoke(ctx, PanelService_GetPanelByName_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -69,7 +93,7 @@ func (c *panelServiceClient) GetPanelByName(ctx context.Context, in *GetPanelByN
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...)
err := c.cc.Invoke(ctx, PanelService_UpdatePanel_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -78,7 +102,7 @@ func (c *panelServiceClient) UpdatePanel(ctx context.Context, in *UpdatePanelByI
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...)
err := c.cc.Invoke(ctx, PanelService_UpdatePanelByName_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -87,7 +111,7 @@ func (c *panelServiceClient) UpdatePanelByName(ctx context.Context, in *UpdatePa
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...)
err := c.cc.Invoke(ctx, PanelService_DeletePanel_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -96,7 +120,7 @@ func (c *panelServiceClient) DeletePanel(ctx context.Context, in *DeletePanelByI
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...)
err := c.cc.Invoke(ctx, PanelService_DeletePanelByName_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -165,7 +189,7 @@ func _PanelService_CreatePanel_Handler(srv interface{}, ctx context.Context, dec
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/CreatePanel",
FullMethod: PanelService_CreatePanel_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).CreatePanel(ctx, req.(*CreatePanelRequest))
@@ -183,7 +207,7 @@ func _PanelService_GetPanel_Handler(srv interface{}, ctx context.Context, dec fu
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/GetPanel",
FullMethod: PanelService_GetPanel_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).GetPanel(ctx, req.(*GetPanelByIdRequest))
@@ -201,7 +225,7 @@ func _PanelService_GetPanelByName_Handler(srv interface{}, ctx context.Context,
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/GetPanelByName",
FullMethod: PanelService_GetPanelByName_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).GetPanelByName(ctx, req.(*GetPanelByNameRequest))
@@ -219,7 +243,7 @@ func _PanelService_UpdatePanel_Handler(srv interface{}, ctx context.Context, dec
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/UpdatePanel",
FullMethod: PanelService_UpdatePanel_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).UpdatePanel(ctx, req.(*UpdatePanelByIdRequest))
@@ -237,7 +261,7 @@ func _PanelService_UpdatePanelByName_Handler(srv interface{}, ctx context.Contex
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/UpdatePanelByName",
FullMethod: PanelService_UpdatePanelByName_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).UpdatePanelByName(ctx, req.(*UpdatePanelByNameRequest))
@@ -255,7 +279,7 @@ func _PanelService_DeletePanel_Handler(srv interface{}, ctx context.Context, dec
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/DeletePanel",
FullMethod: PanelService_DeletePanel_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).DeletePanel(ctx, req.(*DeletePanelByIdRequest))
@@ -273,7 +297,7 @@ func _PanelService_DeletePanelByName_Handler(srv interface{}, ctx context.Contex
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.panel.v1.PanelService/DeletePanelByName",
FullMethod: PanelService_DeletePanelByName_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PanelServiceServer).DeletePanelByName(ctx, req.(*DeletePanelByNameRequest))

View File

@@ -1,3 +1,17 @@
// Copyright 2023 Declan Teevan
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package consumers
import (
@@ -8,14 +22,14 @@ import (
"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"
"github.com/hexolan/panels/post-service/internal/kafka/producer"
)
type UserEventConsumer struct {
reader *kafka.Reader
dbRepo internal.PostDBRepository
dbRepo internal.PostDBRepository
eventProd producer.PostEventProducer
}
@@ -24,7 +38,7 @@ func NewUserEventConsumer(cfg internal.Config, dbRepo internal.PostDBRepository,
reader: kafka.NewReader(kafka.ReaderConfig{
Brokers: cfg.KafkaBrokers,
GroupID: "post-service",
Topic: "user",
Topic: "user",
}),
dbRepo: dbRepo,
}
@@ -72,4 +86,4 @@ func (ec UserEventConsumer) Start() {
if err := ec.reader.Close(); err != nil {
log.Panic().Err(err).Str("src", "user-event-consumer").Msg("failed to close Kafka reader")
}
}
}

View File

@@ -1,6 +1,20 @@
// Copyright 2023 Declan Teevan
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc-gen-go v1.31.0
// protoc v4.23.4
// source: user.proto

View File

@@ -1,6 +1,20 @@
// Copyright 2023 Declan Teevan
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc-gen-go-grpc v1.3.0
// - protoc v4.23.4
// source: user.proto
@@ -19,6 +33,16 @@ import (
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
UserService_CreateUser_FullMethodName = "/panels.user.v1.UserService/CreateUser"
UserService_GetUser_FullMethodName = "/panels.user.v1.UserService/GetUser"
UserService_GetUserByName_FullMethodName = "/panels.user.v1.UserService/GetUserByName"
UserService_UpdateUser_FullMethodName = "/panels.user.v1.UserService/UpdateUser"
UserService_UpdateUserByName_FullMethodName = "/panels.user.v1.UserService/UpdateUserByName"
UserService_DeleteUser_FullMethodName = "/panels.user.v1.UserService/DeleteUser"
UserService_DeleteUserByName_FullMethodName = "/panels.user.v1.UserService/DeleteUserByName"
)
// 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.
@@ -42,7 +66,7 @@ func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient {
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...)
err := c.cc.Invoke(ctx, UserService_CreateUser_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -51,7 +75,7 @@ func (c *userServiceClient) CreateUser(ctx context.Context, in *CreateUserReques
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...)
err := c.cc.Invoke(ctx, UserService_GetUser_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -60,7 +84,7 @@ func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserByIdRequest,
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...)
err := c.cc.Invoke(ctx, UserService_GetUserByName_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -69,7 +93,7 @@ func (c *userServiceClient) GetUserByName(ctx context.Context, in *GetUserByName
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...)
err := c.cc.Invoke(ctx, UserService_UpdateUser_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -78,7 +102,7 @@ func (c *userServiceClient) UpdateUser(ctx context.Context, in *UpdateUserByIdRe
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...)
err := c.cc.Invoke(ctx, UserService_UpdateUserByName_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -87,7 +111,7 @@ func (c *userServiceClient) UpdateUserByName(ctx context.Context, in *UpdateUser
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...)
err := c.cc.Invoke(ctx, UserService_DeleteUser_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -96,7 +120,7 @@ func (c *userServiceClient) DeleteUser(ctx context.Context, in *DeleteUserByIdRe
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...)
err := c.cc.Invoke(ctx, UserService_DeleteUserByName_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -165,7 +189,7 @@ func _UserService_CreateUser_Handler(srv interface{}, ctx context.Context, dec f
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/CreateUser",
FullMethod: UserService_CreateUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).CreateUser(ctx, req.(*CreateUserRequest))
@@ -183,7 +207,7 @@ func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/GetUser",
FullMethod: UserService_GetUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserByIdRequest))
@@ -201,7 +225,7 @@ func _UserService_GetUserByName_Handler(srv interface{}, ctx context.Context, de
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/GetUserByName",
FullMethod: UserService_GetUserByName_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).GetUserByName(ctx, req.(*GetUserByNameRequest))
@@ -219,7 +243,7 @@ func _UserService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec f
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/UpdateUser",
FullMethod: UserService_UpdateUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).UpdateUser(ctx, req.(*UpdateUserByIdRequest))
@@ -237,7 +261,7 @@ func _UserService_UpdateUserByName_Handler(srv interface{}, ctx context.Context,
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/UpdateUserByName",
FullMethod: UserService_UpdateUserByName_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).UpdateUserByName(ctx, req.(*UpdateUserByNameRequest))
@@ -255,7 +279,7 @@ func _UserService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec f
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/DeleteUser",
FullMethod: UserService_DeleteUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).DeleteUser(ctx, req.(*DeleteUserByIdRequest))
@@ -273,7 +297,7 @@ func _UserService_DeleteUserByName_Handler(srv interface{}, ctx context.Context,
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/panels.user.v1.UserService/DeleteUserByName",
FullMethod: UserService_DeleteUserByName_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).DeleteUserByName(ctx, req.(*DeleteUserByNameRequest))

View File

@@ -1,23 +1,37 @@
// Copyright 2023 Declan Teevan
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
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"
"github.com/hexolan/panels/post-service/internal/kafka/producer"
)
type eventConsumers struct {
userEC consumers.UserEventConsumer
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),
userEC: consumers.NewUserEventConsumer(cfg, dbRepo, eventProd),
panelEC: consumers.NewPanelEventConsumer(cfg, dbRepo, eventProd),
}
}
func (ecs eventConsumers) Start() {
go ecs.panelEC.Start()
}
}

View File

@@ -1,3 +1,17 @@
// Copyright 2023 Declan Teevan
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package producer
import (
@@ -17,8 +31,8 @@ type PostEventProducer struct {
func NewPostEventProducer(cfg internal.Config) PostEventProducer {
writer := &kafka.Writer{
Addr: kafka.TCP(cfg.KafkaBrokers...),
Topic: "post",
Addr: kafka.TCP(cfg.KafkaBrokers...),
Topic: "post",
Balancer: &kafka.LeastBytes{},
}
@@ -57,4 +71,4 @@ func (ep PostEventProducer) DispatchDeletedEvent(id internal.PostId) {
Type: "deleted",
Data: &postv1.Post{Id: id.GetReprId()},
})
}
}