You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: align thread-safety docs and add CI test coverage (#37)
* fix: align thread-safety docs and add CI test coverage
Clarify non-thread-safe container behavior, expose top-level Try* APIs, and run full test suite in task/CI with added smoke tests for public wrappers.
Co-authored-by: Cursor <cursoragent@cursor.com>
* test: add coverage for context and global helpers
Add unit tests for dixcontext panic/nil handling and dixglobal provide/inject flows to improve wrapper-module coverage.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs: streamline README structure and diagnostics guide
Improve bilingual READMEs with clearer onboarding, API/option quick references, production-safe examples, and condensed diagnostics guidance linked to detailed dixhttp docs.
Co-authored-by: Cursor <cursoragent@cursor.com>
* test: expand wrapper coverage and add README link checks
Add dix wrapper edge-case tests and a README local-link checker wired into task and CI docs job.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs: add dixhttp auth guidance and PR template
Document reverse-proxy authentication practices for dixhttp and add a reusable PR description template for review-ready changes.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: remove README link checker tooling
Drop the optional readme-check script and its CI/task wiring since it is not needed for day-to-day development.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs(example): simplify samples for easier onboarding
Rewrite example programs with clearer scenarios, dix.New usage, run instructions, and Try* error-handling patterns aligned with the public API docs.
Co-authored-by: Cursor <cursoragent@cursor.com>
* test: isolate global InjectT test and align API docs
Make dixglobal InjectT test self-contained to avoid order-dependent state and document InjectTContext in both README API tables.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -9,6 +9,28 @@ Inspired by [uber-go/dig](https://github.com/uber-go/dig), with support for adva
9
9
10
10
[中文文档](./README_zh.md)
11
11
12
+
## Table of Contents
13
+
14
+
-[When to use dix](#when-to-use-dix)
15
+
-[Features](#-features)
16
+
-[Installation](#-installation)
17
+
-[Quick Start](#-quick-start)
18
+
-[Core API](#-core-api)
19
+
-[Injection Patterns](#-injection-patterns)
20
+
-[Modules](#-modules)
21
+
-[Diagnostics](#-diagnostics)
22
+
-[Development](#️-development)
23
+
-[Examples](#-examples)
24
+
-[Documentation](#-documentation)
25
+
26
+
## When to use dix
27
+
28
+
- You need **runtime** dependency registration (plugins, dynamic modules, conditional wiring).
29
+
- You want **built-in diagnostics**: structured trace logs, JSONL export, and an HTTP dependency graph.
30
+
- You prefer a **dig-like API** with safe `Try*` variants, map/list grouping, and method injection.
31
+
32
+
For compile-time wiring with minimal runtime overhead, see [google/wire](https://github.com/google/wire). For Uber's fx ecosystem, see [uber-go/dig](https://github.com/uber-go/dig).
33
+
12
34
## ✨ Features
13
35
14
36
| Feature | Description |
@@ -74,8 +96,39 @@ func main() {
74
96
}
75
97
```
76
98
99
+
For production startup, prefer `TryProvide` / `TryInject` to avoid panics and keep the process alive for diagnostics:
- Register all providers during application startup (single goroutine).
190
+
- After startup, only read resolved dependencies, or continue injection from a single goroutine.
191
+
- Use separate `Dix` instances per goroutine if you need isolated containers.
192
+
- For a process-wide singleton, prefer `dixglobal` only when startup is single-threaded.
160
193
161
-
Behavior rules:
194
+
### Startup Options
162
195
163
-
- If `DIX_DIAG_FILE` is **not configured**, dix keeps the original behavior (no diagnostic file output).
164
-
- If `DIX_DIAG_FILE` is configured, dix appends diagnostic records to file (`trace` / `error` / `llm`).
165
-
- Console verbosity still follows existing controls (`DIX_TRACE_DI`, `DIX_LLM_DIAG_MODE`).
166
-
167
-
Tip:
168
-
169
-
- Keep console output concise for users.
170
-
- Keep detailed records in file for search/LLM/offline troubleshooting.
171
-
172
-
### In-Memory Trace Query (`dixtrace`, Optional)
173
-
174
-
Starting from this version, dix also emits unified trace events into an in-memory trace store (`dixtrace`), which can be queried via HTTP API (`/api/trace`).
Web interface for visualizing dependency graph, **designed for large projects**:
295
+
Web interface for visualizing dependency graphs, **designed for large projects**:
301
296
302
297
```go
303
298
import (
@@ -309,7 +304,9 @@ server := dixhttp.NewServer((*dixinternal.Dix)(di))
309
304
server.ListenAndServe(":8080")
310
305
```
311
306
312
-
Visit `http://localhost:8080` to view dependency graph.
307
+
Visit `http://localhost:8080` to view the dependency graph.
308
+
309
+
> **Security**: exposes dependency graphs, provider source locations, runtime errors, and trace data. Use on **localhost or private networks** only. Do not expose publicly without authentication.
313
310
314
311
**Highlights**:
315
312
- 🔍 **Fuzzy Search** - Quickly locate types or functions
@@ -318,21 +315,46 @@ Visit `http://localhost:8080` to view dependency graph.
0 commit comments