mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-06-23 04:10:25 +00:00
722b463b6a
* add handler Signed-off-by: SammyOina <sammyoina@gmail.com> * Refactor gRPC and Protobuf integration for manager service - Shifted Protobuf message definitions to a separate package `pkg/manager`. - Updated references throughout the codebase to import and use the new package for gRPC service definitions. - Enhanced AgentLog message with additional fields `level` and `timestamp`. - Removed direct dependencies on old Protobuf-generated types in favor of the new package. - Deleted obsolete Protobuf-generated files as they are now superseded by the new `pkg/manager`. - Streamlined event publishing and gRPC handling in the manager service to use the updated Protobuf messages. This refactoring improves modularity by centralizing Protobuf message definitions and decouples internal representation from the gRPC interface, aligning with best practices for microservice architecture. Additionally, the enriched logging structure paves the way for more detailed and fine-grained log analysis. Signed-off-by: SammyOina <sammyoina@gmail.com> * Refactor vsock event/log handling and config Streamlined event and log services in the manager by moving vsock listening functions out of `managerService` initialization and into dedicated `RetrieveAgentEventsLogs` methods. This change decouples the manager service creation from the actual start of log listening, adding clarity and flexibility in service management. Also moved logging middleware invocation outside of network handling loops to avoid unnecessary overhead. Additionally, the agent's vsock port configuration is now dynamically passed to the `New` function in the `events` package instead of relying on a hardcoded constant, allowing for greater configurability and testability. Finally, updated message structures for event and log sending to conform with the `ClientStreamMessage` definitions. These modifications should improve parsing and handling consistency and prepare our system for future enhancements related to inter-process communication. Signed-off-by: SammyOina <sammyoina@gmail.com> * fix linting errors Signed-off-by: SammyOina <sammyoina@gmail.com> * correct path to generated files Signed-off-by: SammyOina <sammyoina@gmail.com> * fix comments Signed-off-by: SammyOina <sammyoina@gmail.com> * remove uneccessary comments Signed-off-by: SammyOina <sammyoina@gmail.com> --------- Signed-off-by: SammyOina <sammyoina@gmail.com>
36 lines
1.0 KiB
Makefile
36 lines
1.0 KiB
Makefile
BUILD_DIR = build
|
|
SERVICES = manager agent cli
|
|
CGO_ENABLED ?= 0
|
|
GOARCH ?= amd64
|
|
VERSION ?= $(shell git describe --abbrev=0 --tags --always)
|
|
COMMIT ?= $(shell git rev-parse HEAD)
|
|
TIME ?= $(shell date +%F_%T)
|
|
CLI_SOURCE = ./cmd/cli/main.go
|
|
CLI_BIN = ${BUILD_DIR}/cocos-cli
|
|
empty:=
|
|
space:= $(empty) $(empty)
|
|
|
|
define compile_service
|
|
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
|
|
go build -ldflags "-s -w \
|
|
-X 'github.com/absmach/magistrala.BuildTime=$(TIME)' \
|
|
-X 'github.com/absmach/magistrala.Version=$(VERSION)' \
|
|
-X 'github.com/absmach/magistrala.Commit=$(COMMIT)'" \
|
|
-o ${BUILD_DIR}/cocos-$(1) cmd/$(1)/main.go
|
|
endef
|
|
|
|
.PHONY: all $(SERVICES)
|
|
|
|
all: $(SERVICES)
|
|
|
|
$(SERVICES):
|
|
$(call compile_service,$(@))
|
|
|
|
|
|
install-cli: cli
|
|
cp ${CLI_BIN} ~/.local/bin/cocos-cli
|
|
|
|
protoc:
|
|
protoc -I. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative agent/agent.proto
|
|
protoc -I. --go_out=./pkg --go_opt=paths=source_relative --go-grpc_out=./pkg --go-grpc_opt=paths=source_relative manager/manager.proto
|