- Home
- Skills
- Tencentblueking
- Bk Ci
- Common Technical Practices
common-technical-practices_skill
- Kotlin
2.5k
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill tencentblueking/bk-ci --skill common-technical-practices- SKILL.md14.4 KB
Overview
This skill documents seven common backend technical practices used across Spring Boot microservices: AOP aspects, distributed locks, retry strategies, parameter validation, performance monitoring, scheduled tasks, and audit logging. It is written for Kotlin/Java backend teams and focuses on practical guidance, typical pitfalls, and core helper classes. Use it to standardize cross-cutting concerns and reduce duplication across services.
How this skill works
The guide explains how to implement and integrate each practice as framework-level concerns, with code conventions, annotations, and utility classes (e.g., aspect base classes, Redis lock helpers, retry utilities, and monitoring annotations). It maps each concern to concrete files and packages, shows recommended configuration (timeouts, retry policies, cron), and lists runtime checks and operational tips. The material emphasizes safe defaults, idempotency, and observability to avoid common production issues.
When to use it
- When you need centralized logging, permission checks, or metrics via AOP aspects
- When concurrent access requires coordination across instances (use distributed locks)
- When transient failures need controlled retries with backoff
- When API inputs must be validated at the controller boundary
- When you must add Prometheus-compatible performance metrics and timers
- When tasks must run on schedules without duplicate execution in clustered deployments
Best practices
- Keep aspect pointcuts precise and place aspect classes in an .aop package
- Use fine-grained lock keys and set reasonable timeouts (10–30s); always release locks in finally blocks
- Apply retries only to transient errors, ensure idempotency, and use exponential backoff
- Validate inputs at the controller layer with JSR-303 annotations and custom validators for complex rules
- Instrument key flows with Micrometer/Prometheus, avoid high-cardinality labels (e.g., raw userId)
Example use cases
- Add a logging and timing aspect to record request duration and errors across services
- Protect a shared resource (cache eviction, report generation) with RedisLock to prevent race conditions
- Wrap unstable third-party calls with RetryUtils using exponential backoff and max attempts
- Add @Valid checks on incoming DTOs and return standardized 400 responses on validation failures
- Schedule nightly jobs with @Scheduled and use a distributed lock to ensure single-run in the cluster
FAQ
Ensure the aspect class is annotated with @Aspect and @Component, the target is a Spring-managed bean, and the pointcut expression matches public methods.
How do I avoid distributed lock deadlocks?
Set an expiration on locks, use try-finally to release, keep critical sections short, and choose appropriate lock granularity.
When should I not use retries?
Do not retry for business or client errors (invalid parameters, authorization); only retry transient infrastructure failures and ensure operations are idempotent.