Skip to content

Commit ea7d84f

Browse files
committed
fix: golint and clippy
1 parent 24b16d1 commit ea7d84f

File tree

35 files changed

+1035
-215
lines changed

35 files changed

+1035
-215
lines changed

apps/control-plane/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,23 @@ import (
1818
"github.com/allsource/control-plane/internal"
1919
)
2020

21+
// Control plane configuration constants.
2122
const (
22-
DefaultPort = "3901"
23+
// DefaultPort is the default port the control plane listens on.
24+
DefaultPort = "3901"
25+
// CoreServiceURL is the URL of the core event store service.
2326
CoreServiceURL = "http://localhost:3900"
2427
)
2528

29+
// ControlPlane is the main control plane service that manages the event store cluster.
2630
type ControlPlane struct {
2731
client *resty.Client
2832
router *gin.Engine
2933
metrics *ControlPlaneMetrics
3034
container *internal.Container
3135
}
3236

37+
// NewControlPlane creates a new control plane instance with default configuration.
3338
func NewControlPlane() *ControlPlane {
3439
client := resty.New().
3540
SetTimeout(5 * time.Second).
@@ -220,6 +225,7 @@ func (cp *ControlPlane) replayHandler(c *gin.Context) {
220225
})
221226
}
222227

228+
// Start starts the control plane HTTP server on the specified port.
223229
func (cp *ControlPlane) Start(port string) error {
224230
return cp.router.Run(":" + port)
225231
}

apps/control-plane/main_v1.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ import (
1515
"github.com/allsource/control-plane/internal/domain/entities"
1616
)
1717

18+
// Version constants for the control plane.
1819
const (
20+
// Version is the current version of the control plane.
1921
Version = "1.0.0"
2022
)
2123

24+
// ControlPlaneV1 is the v1.0 control plane with authentication and audit logging.
2225
type ControlPlaneV1 struct {
2326
client *resty.Client
2427
router *gin.Engine
@@ -27,6 +30,7 @@ type ControlPlaneV1 struct {
2730
auditLogger *AuditLogger
2831
}
2932

33+
// NewControlPlaneV1 creates a new v1.0 control plane instance with auth and audit logging.
3034
func NewControlPlaneV1() (*ControlPlaneV1, error) {
3135
// Initialize auth client
3236
jwtSecret := os.Getenv("JWT_SECRET")
@@ -463,10 +467,12 @@ func (cp *ControlPlaneV1) proxyToCoreAuthWithBody(c *gin.Context, method, path s
463467
return resp, nil
464468
}
465469

470+
// Start starts the control plane HTTP server on the specified port.
466471
func (cp *ControlPlaneV1) Start(port string) error {
467472
return cp.router.Run(":" + port)
468473
}
469474

475+
// Shutdown gracefully shuts down the control plane and closes resources.
470476
func (cp *ControlPlaneV1) Shutdown() error {
471477
if cp.auditLogger != nil {
472478
return cp.auditLogger.Close()

apps/control-plane/policy.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ import (
1313
// PolicyAction represents an action that can be taken
1414
type PolicyAction string
1515

16+
// Policy action constants.
1617
const (
18+
// ActionAllow permits the operation.
1719
ActionAllow PolicyAction = "allow"
18-
ActionDeny PolicyAction = "deny"
19-
ActionWarn PolicyAction = "warn"
20+
// ActionDeny blocks the operation.
21+
ActionDeny PolicyAction = "deny"
22+
// ActionWarn allows the operation but logs a warning.
23+
ActionWarn PolicyAction = "warn"
2024
)
2125

2226
// PolicyCondition represents a condition for a policy

apps/core/src/application/services/replay.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl ReplayManager {
162162
request
163163
.projection_name
164164
.as_ref()
165-
.map(|n| format!(" (projection: {})", n))
165+
.map(|n| format!(" (projection: {n})"))
166166
.unwrap_or_default()
167167
);
168168

@@ -319,7 +319,7 @@ impl ReplayManager {
319319
let replays = self.replays.read();
320320

321321
let state = replays.iter().find(|r| r.id == replay_id).ok_or_else(|| {
322-
AllSourceError::ValidationError(format!("Replay not found: {}", replay_id))
322+
AllSourceError::ValidationError(format!("Replay not found: {replay_id}"))
323323
})?;
324324

325325
let processed = state.processed_events.load(Ordering::Relaxed);
@@ -362,7 +362,7 @@ impl ReplayManager {
362362
let replays = self.replays.read();
363363

364364
let state = replays.iter().find(|r| r.id == replay_id).ok_or_else(|| {
365-
AllSourceError::ValidationError(format!("Replay not found: {}", replay_id))
365+
AllSourceError::ValidationError(format!("Replay not found: {replay_id}"))
366366
})?;
367367

368368
let status = *state.status.read();
@@ -423,7 +423,7 @@ impl ReplayManager {
423423
.iter()
424424
.position(|r| r.id == replay_id)
425425
.ok_or_else(|| {
426-
AllSourceError::ValidationError(format!("Replay not found: {}", replay_id))
426+
AllSourceError::ValidationError(format!("Replay not found: {replay_id}"))
427427
})?;
428428

429429
let status = *replays[idx].status.read();

apps/core/src/application/services/schema.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ impl SchemaRegistry {
247247
let schemas = self.schemas.read();
248248

249249
let subject_schemas = schemas.get(subject).ok_or_else(|| {
250-
AllSourceError::ValidationError(format!("Subject not found: {}", subject))
250+
AllSourceError::ValidationError(format!("Subject not found: {subject}"))
251251
})?;
252252

253253
let version = match version {
254254
Some(v) => v,
255255
None => {
256256
let latest_versions = self.latest_versions.read();
257257
*latest_versions.get(subject).ok_or_else(|| {
258-
AllSourceError::ValidationError(format!("No versions for subject: {}", subject))
258+
AllSourceError::ValidationError(format!("No versions for subject: {subject}"))
259259
})?
260260
}
261261
};
@@ -273,7 +273,7 @@ impl SchemaRegistry {
273273
let schemas = self.schemas.read();
274274

275275
let subject_schemas = schemas.get(subject).ok_or_else(|| {
276-
AllSourceError::ValidationError(format!("Subject not found: {}", subject))
276+
AllSourceError::ValidationError(format!("Subject not found: {subject}"))
277277
})?;
278278

279279
let mut versions: Vec<u32> = subject_schemas.keys().copied().collect();
@@ -326,7 +326,7 @@ impl SchemaRegistry {
326326
for req_field in required {
327327
if let Some(field_name) = req_field.as_str() {
328328
if !obj.contains_key(field_name) {
329-
errors.push(format!("Missing required field: {}", field_name));
329+
errors.push(format!("Missing required field: {field_name}"));
330330
}
331331
}
332332
}
@@ -361,7 +361,7 @@ impl SchemaRegistry {
361361
if let Some(prop_schema) = properties.get(key) {
362362
let nested_errors = self.validate_json(value, prop_schema);
363363
for err in nested_errors {
364-
errors.push(format!("{}.{}", key, err));
364+
errors.push(format!("{key}.{err}"));
365365
}
366366
}
367367
}

apps/core/src/domain/entities/audit_event.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ impl Actor {
210210
/// Get actor identifier for logging
211211
pub fn identifier(&self) -> String {
212212
match self {
213-
Self::User { user_id, .. } => format!("user:{}", user_id),
214-
Self::ApiKey { key_id, .. } => format!("api_key:{}", key_id),
215-
Self::System { component } => format!("system:{}", component),
213+
Self::User { user_id, .. } => format!("user:{user_id}"),
214+
Self::ApiKey { key_id, .. } => format!("api_key:{key_id}"),
215+
Self::System { component } => format!("system:{component}"),
216216
}
217217
}
218218
}
@@ -389,14 +389,14 @@ impl AuditEvent {
389389
/// Get a human-readable description
390390
pub fn description(&self) -> String {
391391
let actor_desc = match &self.actor {
392-
Actor::User { username, .. } => format!("User '{}'", username),
393-
Actor::ApiKey { key_name, .. } => format!("API Key '{}'", key_name),
394-
Actor::System { component } => format!("System component '{}'", component),
392+
Actor::User { username, .. } => format!("User '{username}'"),
393+
Actor::ApiKey { key_name, .. } => format!("API Key '{key_name}'"),
394+
Actor::System { component } => format!("System component '{component}'"),
395395
};
396396

397397
let resource_desc =
398398
if let (Some(r_type), Some(r_id)) = (&self.resource_type, &self.resource_id) {
399-
format!(" on {} '{}'", r_type, r_id)
399+
format!(" on {r_type} '{r_id}'")
400400
} else {
401401
String::new()
402402
};

apps/core/src/domain/value_objects/event_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl EventType {
141141
.all(|c| c.is_lowercase() || c.is_numeric() || c == '.' || c == '_')
142142
{
143143
return Err(crate::error::AllSourceError::InvalidInput(
144-
format!("Event type '{}' must be lowercase with dots/underscores. Convention: namespace.entity.action", value),
144+
format!("Event type '{value}' must be lowercase with dots/underscores. Convention: namespace.entity.action"),
145145
));
146146
}
147147

apps/core/src/domain/value_objects/tenant_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl TenantId {
8989
.all(|c| c.is_alphanumeric() || c == '-' || c == '_')
9090
{
9191
return Err(crate::error::AllSourceError::InvalidInput(
92-
format!("Tenant ID '{}' contains invalid characters. Only alphanumeric, hyphens, and underscores allowed", value),
92+
format!("Tenant ID '{value}' contains invalid characters. Only alphanumeric, hyphens, and underscores allowed"),
9393
));
9494
}
9595

apps/core/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl From<crate::infrastructure::persistence::SimdJsonError> for AllSourceError
7777
#[cfg(feature = "postgres")]
7878
impl From<sqlx::Error> for AllSourceError {
7979
fn from(err: sqlx::Error) -> Self {
80-
AllSourceError::StorageError(format!("Database error: {}", err))
80+
AllSourceError::StorageError(format!("Database error: {err}"))
8181
}
8282
}
8383

apps/core/src/infrastructure/cluster/request_router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl RequestRouter {
7373
})?;
7474

7575
self.registry.get_node(node_id).ok_or_else(|| {
76-
AllSourceError::InternalError(format!("Node {} not found in registry", node_id))
76+
AllSourceError::InternalError(format!("Node {node_id} not found in registry"))
7777
})
7878
}
7979

0 commit comments

Comments
 (0)