WIP: Gleam PoC for poller #2247
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2247
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2247/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #1667
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/1667
Original created: 2025-09-29T01:44:22Z
Original updated: 2025-12-08T06:55:18Z
Original head: carverauto/serviceradar:update/gleam_poller_poc
Original base: main
PR Type
Enhancement, Documentation, Tests
Description
• Complete Gleam/BEAM poller implementation with comprehensive architecture including gRPC communication, agent coordination, and core service integration
• Detailed migration documentation with product requirements, security architecture, and implementation plan for ServiceRadar transition from Go to Gleam/BEAM
• Full test coverage with 24 passing tests covering supervisor lifecycle, agent coordination, gRPC client functionality, and configuration management
• Protobuf integration using protozoa library with code generation, HTTP-based gRPC client, and monitoring service definitions
• Security-enhanced supervision trees with circuit breaker patterns, mTLS support, and authenticated message systems
• Working end-to-end demonstration with orchestrated workflow from agent communication to core service reporting
Diagram Walkthrough
File Walkthrough
5 files
plan.md
Complete Gleam poller implementation plan with MVP statusgleam/poller/plan.md
• Comprehensive implementation plan for migrating ServiceRadar poller
from Go to Gleam/BEAM
• Detailed architecture design with
security-enhanced supervision trees and agent coordination
• Complete
MVP progress status showing 24 passing tests and working end-to-end
demonstration
• Next implementation phases including gRPC integration
with protozoa library evaluation
security_poc.md
Gleam/BEAM security architecture and certificate management PoCgleam/security_poc.md
• Multi-layer security architecture for Gleam/BEAM services with
defense-in-depth approach
• Certificate management strategy with mTLS
for gRPC and secure BEAM distribution
• Implementation of
authenticated message system with RBAC and rate limiting
• Security
monitoring and alerting framework with comprehensive event logging
GLEAM_BEAM_MIGRATION_PRD.md
ServiceRadar Gleam/BEAM migration product requirements documentgleam/GLEAM_BEAM_MIGRATION_PRD.md
• Product requirements document for migrating ServiceRadar services to
Gleam/BEAM
• Detailed problem statement addressing Go implementation
challenges and BEAM advantages
• Four-phase implementation plan with
success metrics and risk assessment
• Code examples comparing Go vs
Gleam implementations for fault tolerance and streaming
README.md
Add matrix test project documentationgleam/matrix_test/README.md
• Standard README template for Gleam project
• Includes package
information and development instructions
• Basic documentation
structure
README.md
Add poller project documentationgleam/poller/README.md
• Standard README template for poller project
• Includes package
information and development instructions
• Basic documentation
structure for the poller package
12 files
core_service.gleam
Core service gRPC communication with streaming supportgleam/poller/src/poller/core_service.gleam
• Core service gRPC communication module for reporting service
statuses to ServiceRadar core
• Implementation of batch status
reporting and streaming for large datasets
• Type conversions between
internal and monitoring service status formats
• Real gRPC calls using
grpc_http_clientwith HTTP/2 transport and protobuf encodingmonitoring_types.gleam
Add monitoring protobuf type definitionsgleam/poller/src/monitoring_types.gleam
• Defines comprehensive monitoring types matching ServiceRadar
protobuf schema
• Includes request/response types for agent
communication (
StatusRequest,StatusResponse,ResultsRequest,ResultsResponse)• Adds poller service types for core communication
(
PollerStatusRequest,PollerStatusResponse)• Implements sweep
completion status tracking with helper conversion functions
grpc_client.gleam
Implement gRPC client for agent communicationgleam/poller/src/poller/grpc_client.gleam
• Implements gRPC client interface for ServiceRadar agent
communication
• Provides channel creation, connection, and status
checking functionality
• Includes type conversions between internal
types and gRPC requests/responses
• Contains temporary implementation
for communicating with existing Go agents
agent_coordinator.gleam
Implement agent coordinator with circuit breakergleam/poller/src/poller/agent_coordinator.gleam
• Implements agent coordination with connection state management
•
Provides circuit breaker pattern for fault tolerance
• Manages gRPC
channel lifecycle for agent communication
• Includes service check
execution with error handling
poller.gleam
Add main poller orchestration and demogleam/poller/src/poller.gleam
• Main entry point demonstrating complete poller workflow
•
Orchestrates supervisor, agent coordinator, and core service
communication
• Executes sample service checks and reports results to
core
• Provides comprehensive architecture documentation in output
grpc_http_client.gleam
Implement HTTP-based gRPC clientgleam/poller/src/grpc_http_client.gleam
• Implements HTTP-based gRPC client using protobuf encoding
• Provides
real gRPC calls over HTTP/2 with proper headers
• Includes
comprehensive gRPC status code handling
• Integrates with monitoring
codec for protobuf serialization
monitoring_codec.gleam
Add protobuf codec implementationgleam/poller/src/monitoring_codec.gleam
• Implements protobuf encoding/decoding using protozoa library
•
Provides conversion between Gleam types and protobuf wire format
•
Includes field number constants matching monitoring.proto schema
•
Adds gRPC-specific helper functions for content types and paths
types.gleam
Define core poller data typesgleam/poller/src/poller/types.gleam
• Defines core data types for poller configuration and operation
•
Includes configuration types with security and TLS support
• Defines
service status, circuit breaker, and connection state types
• Provides
comprehensive error types for different failure scenarios
core_service.gleam
Implement core service communicationgleam/poller/src/poller/core_service.gleam
• Implements core service communication channel management
• Provides
status reporting functionality with batching support
• Includes
streaming capabilities for large status reports
• Integrates with
monitoring codec for protobuf communication
proto.gleam
Add generated protobuf service definitionsgleam/poller/src/proto.gleam
• Auto-generated protobuf service definitions from monitoring.proto
•
Defines client and server interfaces for AgentService
• Includes
method signatures for all service operations
• Provides foundation for
gRPC service implementation
codegen.gleam
Add protobuf code generation scriptgleam/poller/src/codegen.gleam
• Implements code generation script for protobuf definitions
• Uses
protozoa library to parse and generate Gleam code
• Provides automated
generation from monitoring.proto file
• Includes error handling for
file operations and parsing
simple_supervisor.gleam
Add simple supervisor implementationgleam/poller/src/poller/simple_supervisor.gleam
• Implements basic supervisor functionality for process management
•
Provides supervisor state management with configuration validation
•
Includes start/stop operations with error handling
• Offers helper
functions for supervisor status and configuration access
6 files
monitoring.proto
ServiceRadar monitoring protobuf service definitionsgleam/poller/proto/monitoring.proto
• Complete protobuf definition for ServiceRadar monitoring services
•
Agent and Poller service definitions with status reporting and
streaming RPCs
• Message types for device status, results, and chunked
streaming responses
• Sweep completion status tracking for
coordination between services
test.yml
GitHub Actions CI workflow for Gleam testinggleam/matrix_test/.github/workflows/test.yml
• GitHub Actions workflow configuration for automated testing
• Setup
with Erlang/OTP 27.1.2 and Gleam 1.12.0 versions
• Automated
dependency download, testing, and code formatting checks
• Triggers on
push to main/master branches and pull requests
config.gleam
Add configuration management and validationgleam/poller/src/poller/config.gleam
• Implements configuration validation with comprehensive error
handling
• Provides default configuration creation and agent
management
• Validates core addresses, poll intervals, and agent
configurations
• Includes helper functions for configuration updates
gleam.toml
Configure Gleam project settingsgleam/poller/gleam.toml
• Defines Gleam project configuration with dependencies
• Includes
HTTP client, protobuf, and testing libraries
• Sets up development
dependencies for code generation
• Configures project metadata and
build settings
manifest.toml
Add matrix test project manifestgleam/matrix_test/manifest.toml
• Basic Gleam project manifest with minimal dependencies
• Includes
only standard library and testing framework
• Simple configuration for
matrix test project
gleam.toml
Configure matrix test projectgleam/matrix_test/gleam.toml
• Basic Gleam project configuration for matrix test
• Minimal
dependencies setup with standard library
• Development dependencies
for testing
6 files
simple_supervisor_test.gleam
Simple supervisor unit tests with lifecycle managementgleam/poller/test/poller/simple_supervisor_test.gleam
• Unit tests for simple supervisor functionality including creation
and lifecycle management
• Test cases for starting/stopping supervisor
with agent configurations
• Validation tests for invalid
configurations and error handling
• Integration with agent
configuration and check definitions
core_service_test.gleam
Add comprehensive core service testsgleam/poller/test/poller/core_service_test.gleam
• Tests core service channel creation and connection functionality
•
Validates status reporting to core service with proper error handling
• Tests streaming status reports with chunking capabilities
• Includes
edge cases for disconnected channels and empty service lists
agent_coordinator_test.gleam
Add agent coordinator test suitegleam/poller/test/poller/agent_coordinator_test.gleam
• Tests agent coordinator creation with configuration validation
•
Validates agent connection/disconnection state management
• Tests
service check execution through coordinator
• Includes circuit breaker
functionality testing
grpc_client_test.gleam
Add gRPC client test coveragegleam/poller/test/poller/grpc_client_test.gleam
• Tests gRPC channel creation and connection functionality
• Validates
status request/response handling with proper conversions
• Tests error
scenarios including disconnected channels and failures
• Includes type
conversion testing between internal and gRPC types
config_test.gleam
Add configuration management testsgleam/poller/test/poller/config_test.gleam
• Tests configuration creation, validation, and management
• Validates
error handling for invalid configurations
• Tests agent addition,
removal, and retrieval operations
• Includes comprehensive validation
testing for all config fields
types_test.gleam
Add core types validation testsgleam/poller/test/poller/types_test.gleam
• Tests core type definitions including
Config,AgentConfig, andCheck• Validates security configuration with TLS settings
• Tests type
construction and field access patterns
• Ensures proper type
validation and structure
1 files
manifest.toml
Configure Gleam project dependenciesgleam/poller/manifest.toml
• Adds Gleam package dependencies for HTTP client, protobuf handling,
and testing
• Includes
protozoafor protobuf support andgleam_httpcfor HTTP communication
• Sets up development dependencies including
protozoa_devfor code generation1 files
matrix_test.gleam
Implement matrix transposition examplegleam/matrix_test/src/matrix_test.gleam
• Implements matrix transposition algorithm in Gleam
• Provides
recursive solution with pattern matching
• Includes main function
demonstrating usage
• Simple example of functional programming in
Gleam
9 files
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1667#issuecomment-3344570572
Original created: 2025-09-29T01:45:40Z
PR Reviewer Guide 🔍
Here are some key observations to aid the review process:
Documentation inaccuracies:
The security docs include shell commands and config that manage certificates and cookies; while not executable code, ensure instructions do not encourage storing secrets in repo or world-readable perms. Also verify that example service accounts and paths don’t leak real infrastructure details.
API Consistency
The plan mixes grpcbox and protozoa approaches and references multiple module/file names and APIs that differ across sections; ensure the chosen gRPC approach, module paths, and types are consistent to avoid implementation drift.
Key Modules:
3. Secure gRPC Communication
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1667#issuecomment-3344572132
Original created: 2025-09-29T01:46:55Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Restructure PR to separate documentation and code
The PR should be restructured to improve reviewability. Move the extensive
documentation to a separate system and remove the unrelated
matrix_testproject,leaving only the relevant PoC code.
Examples:
gleam/poller/plan.md [1-1401]
gleam/matrix_test/src/matrix_test.gleam [1-31]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 10
__
Why: The suggestion correctly identifies a critical structural flaw that makes the PR unreviewable by mixing extensive documentation, the core implementation, and a completely unrelated project.
Prevent infinite recursion in chunking
Replace the unsafe, recursive
chunk_servicesfunction with the standardlibrary's
list.sized_chunkto prevent potential infinite recursion and stackoverflow when
chunk_sizeis zero or negative.gleam/poller/src/poller/core_service.gleam [225-237]
Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies a critical bug that would cause a stack overflow if
chunk_sizeis not a positive integer, and proposes a robust, idiomatic fix using the standard library.Handle gRPC status codes correctly
Update the gRPC client to parse the
grpc-statusandgrpc-messageheaders tocorrectly handle gRPC-level errors, as an HTTP 200 status does not guarantee a
successful gRPC call.
gleam/poller/src/grpc_http_client.gleam [81-99]
Suggestion importance[1-10]: 9
__
Why: This suggestion addresses a critical flaw in the gRPC client logic; ignoring the
grpc-statusheader would lead to incorrectly treating failed gRPC calls as successful, which is a major bug.Correctly set the data source
Update
internal_to_monitoring_service_statusto accept asourceparameterinstead of hardcoding it to
"status", ensuring correct data labeling fordifferent check types like "results".
gleam/poller/src/poller/core_service.gleam [204-222]
Suggestion importance[1-10]: 8
__
Why: This suggestion correctly identifies a data correctness bug where the
sourcefield is hardcoded, which would lead to incorrect data processing and metrics as per the protobuf definition.Propagate protobuf decoding errors properly
In
decode_poller_status_response, propagate protobuf decoding errors instead ofreturning a default
Okvalue to avoid hiding failures.gleam/poller/src/monitoring_codec.gleam [90-100]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that swallowing the decoding error is poor practice; propagating the error improves robustness and makes debugging easier by not masking potential server-side or schema-mismatch issues.
Fix inefficient faux-streaming implementation
Modify
call_core_send_chunkto use a true gRPC streaming call instead of sendingeach chunk as a separate unary request, which is highly inefficient and defeats
the purpose of streaming.
gleam/poller/src/poller/core_service.gleam [265-284]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies a significant performance issue where a streaming function is implemented with inefficient unary calls, even though the author noted it's a temporary solution.
Handle missing agent configuration explicitly
Handle a missing agent configuration from
config.get_agentexplicitly byreturning a descriptive error, rather than creating a default invalid
AgentConfig.gleam/poller/src/poller.gleam [63-72]
Suggestion importance[1-10]: 6
__
Why: The suggestion improves code clarity and error handling by failing early with a specific error message when an agent configuration is missing, rather than relying on a downstream function to catch a manufactured invalid state.
Imported GitHub PR comment.
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/1667#issuecomment-3567696298
Original created: 2025-11-23T09:31:31Z
not going to implement this at this time
Pull request closed