dixhttp

package
v2.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 16 Imported by: 1

README ยถ

Dix HTTP Visualization Module

This module provides an HTTP server to visualize dependency relationships in the Dix dependency injection container. Designed for large projects, with support for fuzzy search, package grouping, bidirectional dependency tracking, and depth control.

ไธญๆ–‡ๆ–‡ๆกฃ

UI ไฟกๆฏๆžถๆž„

ไธป็•Œ้ขไธบ legacy /๏ผˆAlpine + vis-network + ๆœฌๅœฐ้™ๆ€่ต„ๆบ๏ผ‰ใ€‚้ขๅ‘ DI ๆžถๆž„ๅฎกๆŸฅ๏ผšๅŒ…/ๆจกๅ—่พน็•Œใ€Providersใ€็ฑปๅž‹ไพ่ต–ใ€ไธšๅŠกๅˆ†็ป„่šๅˆใ€‚

่ƒฝๅŠ› ่ฏดๆ˜Ž
Providers / ็ฑปๅž‹ไพ่ต– ็Žฐๆœ‰ๅ…จๅฑ€ๆž„ๅ›พ๏ผ›้ป˜่ฎคไปๅฏ่ฟ› Providers
ๆจกๅ—ๅœฐๅ›พ /api/modules ่ทจๆจกๅ—่พน็•Œๆ€ป่งˆ๏ผ›ๅŒๅ‡ปไธ‹้’ปๅˆฐๅŒ…ๅ‰็ผ€่ฟ‡ๆปค็š„ Providers
ๅŒ…่Œƒๅ›ดไพงๆ  ้€‰ๆ‹ฉๅŒ…ไปฅ็ผฉๅฐๆžถๆž„ๅˆ‡็‰‡๏ผˆๅ‰็ผ€่ฟ‡ๆปค๏ผ‰
ๆŒ‰ๅˆ†็ป„่šๅˆ dix.groupRules.v1 / /api/group-rules
่ง„ๆจกๆ็คบ ่ถ…ๅฏ่ฏป้ข„็ฎ—ๆ—ถๆจชๅน…ๅปบ่ฎฎๆข็ฒ’ๅบฆ๏ผŒๅˆ—ๅ‡บ่€ฆๅˆๆžข็บฝ๏ผŒๆœ€ๅŽๆ‰ Top-K ่ฃ็‚น
Trace / ่ฏŠๆ–ญ ้กตๅ†…ๅผนๅฑ‚๏ผ›ๆŽ’้šœไธป่ทฏๅพ„ไปๆ˜ฏ่ฐƒ็”จ้“พ

Object๏ผˆๅทฒๅˆ›ๅปบๅฎžไพ‹๏ผ‰้ป˜่ฎคไธไฝœไธบๆžถๆž„็”ปๅธƒ่Š‚็‚น๏ผŒๅชๅœจ็ปŸ่ฎก/่ฏฆๆƒ…ไธญๅฑ•็คบใ€‚

Scale-first graph workflow

Module map / group aggregate  ->  scoped Providers or Types  ->  detail / Trace
  • The default graph mode remains Providers (legacy habit); crowding is handled by semantic prompts, hubs, short labels, readable layout, then truncation.
  • Module map is bounded by module count; Providers/Types use a soft on-canvas readability cap (~40 nodes) with hub listing.
  • Objects are shown as state in details and counts; they are not rendered as architecture nodes by default.
  • /api/dependencies remains the full-data endpoint for Providers/Types views.
  • Visualization UI entry is / only (/next removed).

Features

  • ๐Ÿ“Š Interactive Visualization - Modern no-build UI built with vanilla JS, local CSS, and vis-network
  • ๐Ÿ” Global Fuzzy Search - Quickly search for type names or function names to view dependencies
  • ๐Ÿ“ฆ Package Grouping - Collapsible left panel to browse by package
  • ๐Ÿ”„ Bidirectional Dependency Tracking - Show both upstream (dependencies) and downstream (dependents)
  • ๐Ÿ“ Depth Control - Limit dependency graph display levels (1-5 or all)
  • ๐ŸŽจ Multiple Layouts - Support hierarchical and force-directed layouts
  • ๐Ÿงฉ Group Rules (Prefix Aggregation) - Aggregate nodes by package/prefix rules
  • ๐Ÿ”Ž Prefix Filter - Show only nodes/providers matching a prefix
  • ๐Ÿงญ Group Subgraph - View a group's internal + upstream/downstream dependencies
  • โฑ๏ธ Startup Runtime Stats - Show all providers' startup durations (total/avg/last, call count), with executed-only filter (call_count > 0)
  • ๐Ÿ—‚ Diagnostic File Query - When DIX_DIAG_FILE is set, UI can query and display trace/error/llm JSONL records for troubleshooting
  • ๐Ÿงต Trace Timeline Query - Query unified in-memory trace events from dixtrace via /api/trace (with rich filters); /api/trace-tree assembles the nested call tree per trace id; for file persistence, DIX_TRACE_FILE is preferred, and falls back to DIX_DIAG_FILE when unset
  • ๐Ÿ“ก RESTful API - Provide JSON format dependency data
  • ๐Ÿงฉ Mermaid Export/Preview - Generate Mermaid flowcharts for current graph (respects grouping/filtering)

Quick Start

package main

import (
    "log"
    "github.com/pubgo/dix/v2"
    "github.com/pubgo/dix/v2/dixhttp"
)

func main() {
    // Create Dix container
    di := dix.New()
    
    // Register providers
    dix.Provide(di, func() *Config {
        return &Config{}
    })
    
    dix.Provide(di, func(c *Config) *Database {
        return &Database{Config: c}
    })
    
    dix.Provide(di, func(db *Database) *UserService {
        return &UserService{DB: db}
    })
    
    // Create and start HTTP server
    server := dixhttp.NewServer(di)
    log.Println("Server starting at http://localhost:8080")
    if err := server.ListenAndServe(":8080"); err != nil {
        log.Fatal(err)
    }
}

Open browser and visit http://localhost:8080 to view the dependency graph.

Base Path / Prefix

If you need to mount the UI and API under a path prefix (e.g. behind a gateway), use WithBasePath:

server := dixhttp.NewServerWithOptions(
  di,
  dixhttp.WithBasePath("/dix"),
)
// Visit http://localhost:8080/dix/

dixhttp itself does not include auth middleware. For production, place it behind a reverse proxy with authentication and network restrictions.

Example (Nginx + Basic Auth):

location /dix/ {
    auth_basic "Restricted Dix";
    auth_basic_user_file /etc/nginx/.htpasswd;

    proxy_pass http://127.0.0.1:8080/dix/;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

Practical security checklist:

  • Bind the dixhttp server to loopback/internal interface only.
  • Keep access behind auth (Basic Auth / SSO / gateway token).
  • Restrict by source IP/CIDR where possible.
  • Avoid exposing diagnosis endpoints (/api/errors, /api/diagnostics, /api/trace) to public internet.

UI Layout

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ๐Ÿ”— Dix Dependency Visualization            ๐Ÿ“ฆ 8 Pkgs  โšก 42 Provs  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ ๐Ÿ“ฆ Pkgs  โ”‚  [Providers] [Types]  Layout: Hier  Depth: 2  ๐Ÿ” Search  โ”‚ ๐Ÿ“‹ Details  โ”‚
โ”‚          โ”‚                                            โ”‚             โ”‚
โ”‚ ๐Ÿ“ All   โ”‚                                            โ”‚  Function   โ”‚
โ”‚  42      โ”‚           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                      โ”‚  xxx.func   โ”‚
โ”‚          โ”‚           โ”‚ Config  โ”‚                      โ”‚             โ”‚
โ”‚ .../app  โ”‚           โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜                      โ”‚  Output     โ”‚
โ”‚  12      โ”‚                โ”‚                           โ”‚  *Config    โ”‚
โ”‚          โ”‚           โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”                      โ”‚             โ”‚
โ”‚ .../db   โ”‚           โ”‚Database โ”‚                      โ”‚  Inputs     โ”‚
โ”‚  8       โ”‚           โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜                      โ”‚  (clickable)โ”‚
โ”‚          โ”‚                โ”‚                           โ”‚             โ”‚
โ”‚          โ”‚        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                   โ”‚ [View Deps] โ”‚
โ”‚          โ”‚        โ”‚  UserService  โ”‚                   โ”‚             โ”‚
โ”‚          โ”‚        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                   โ”‚             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  ยซ Collapse                                           โ”‚   Legend    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Three-Panel Layout
Area Description
Left - Package List Provider list grouped by package, searchable, collapsible
Center - Dependency Graph Interactive graph with drag, zoom, click support
Right - Details Panel Show selected node details with clickable navigation

Core Features

The search box on the right side of the toolbar supports:

  • Fuzzy Matching - Enter keywords to match type names or function names
  • Real-time Suggestions - Show matching results dropdown (max 20)
  • Quick Jump - Click result or press Enter to view dependency graph
  • Category Labels - Results marked as Provider or Type
๐Ÿ”„ Bidirectional Dependency Tracking

After searching or clicking a type, the system shows that type as center:

     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚ Upstream โ”‚  โ† Green nodes
     โ”‚ (Config) โ”‚
     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
          โ”‚
          โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚  Target  โ”‚  โ† Yellow highlight
     โ”‚(Database)โ”‚
     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
          โ”‚
          โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚Downstreamโ”‚  โ† Red nodes
     โ”‚(Service) โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Color Legend:

  • ๐ŸŸก Yellow - Target node (searched object)
  • ๐ŸŸข Green - Dependencies (upstream, what target depends on)
  • ๐Ÿ”ด Red - Dependents (downstream, what depends on target)
๐Ÿ“ Depth Control

Depth determines how many levels to expand up/down:

Depth Description Use Case
1 Only direct dependencies/dependents Quick view of direct relationships
2 Two levels (default) Recommended for daily use
3-5 More levels Track complex dependency chains
All Show complete dependency tree Small projects or specific analysis

Example: Assume dependency chain is Config โ†’ Database โ†’ UserService โ†’ Handler

Search UserService with different depths:

  • Depth 1: Database โ† UserService โ†’ Handler
  • Depth 2: Config โ† Database โ† UserService โ†’ Handler
๐Ÿงฉ Group Rules (Prefix Aggregation)

You can aggregate nodes by package or prefix using group rules. Rules can be configured:

  • In UI (group list)
  • From backend via RegisterGroupRules (recommended for production)

Backend registration:

import "github.com/pubgo/dix/v2/dixhttp"

dixhttp.RegisterGroupRules(
  dixhttp.GroupRule{
    Name: "service",
    Prefixes: []string{
      "github.com/acme/app/service",
      "github.com/acme/app/internal/service",
    },
  },
  dixhttp.GroupRule{
    Name: "router",
    Prefixes: []string{"github.com/acme/app/router"},
  },
)

The UI will auto-load /api/group-rules if local rules are empty.

๐Ÿ”Ž Prefix Filter

The toolbar provides a Prefix Filter field. It filters the current graph to show only nodes/providers whose package/type/function name contains the given prefix. This works in:

  • Providers/Types view
  • Type-focused dependency view
  • Group subgraph view
๐Ÿงญ Group Subgraph

Click a virtual group node to open the group detail panel, then click View group graph to see:

  • Internal nodes
  • Upstream & downstream dependencies
  • Depth control applied from the toolbar
๐Ÿ“ฆ Package Grouping

Left panel features:

  • Package List - Show all packages with Provider counts
  • Search Filter - Quickly locate specific packages
  • Click Filter - Show only that package's dependencies
  • Collapse - Click ยซ button to collapse sidebar, expand graph area

Interactions

Operation Effect
Single Click Show details in right panel
Double Click Show dependency graph centered on that node
Drag Node Move node position
Scroll Zoom Zoom in/out graph
Click Type in Details Jump to view that type's dependencies

Mermaid Support

The toolbar includes a Mermaid button. It generates a Mermaid flowchart from the current graph view (including grouping, depth, and prefix filters), opens a preview modal, and lets you copy the Mermaid source.

Typical usage:

  1. Adjust view / grouping / filters.
  2. Click Mermaid.
  3. Copy the generated Mermaid text or use the preview.

API Endpoints

GET /

Returns HTML visualization page

GET /api/stats

Returns summary statistics

{
  "provider_count": 42,
  "object_count": 15,
  "package_count": 8,
  "edge_count": 67
}
GET /api/runtime-stats?limit=20

Returns provider runtime metrics sorted by total duration (desc), useful for finding slow startup components.

[
  {
    "function_name": "main.NewUserService",
    "output_type": "*service.UserService",
    "call_count": 1,
    "total_duration": 3456789,
    "average_duration": 3456789,
    "last_duration": 3456789,
    "last_run_at_unix_nano": 1700000000000000000
  }
]
GET /api/errors?limit=50

Returns recent Inject / TryInject errors (latest first), useful when startup injection fails before full initialization.

[
  {
    "operation": "provider_execute",
    "component": "main.main.func12",
    "stage": "resolve_input",
    "provider_function": "main.main.func12",
    "output_type": "*main.UserService",
    "input_type": "*main.Database",
    "root_cause": "value not found: type=*main.Database ...",
    "message": "failed to get input value for provider: value not found: type=*main.Database ...",
    "occurred_at_unix_nano": 1700000000000000000
  }
]
GET /api/diagnostics?kind=trace&q=provider&event=provider.call.start&limit=200

Reads and filters JSONL records from DIX_DIAG_FILE.

If DIX_DIAG_FILE is not set, response returns enabled=false and empty records.

{
  "enabled": true,
  "path": "/tmp/dix-diag.jsonl",
  "exists": true,
  "total": 42,
  "returned": 42,
  "next_before_id": 0,
  "records": [
    {
      "record_id": 128,
      "source": "dix",
      "pid": 12345,
      "process": "my-app",
      "hostname": "dev-mac",
      "trace_di": true,
      "kind": "trace",
      "event": "provider.call.start",
      "occurred_at_unix_nano": 1700000000000000000,
      "fields": {
        "provider": "github.com/acme/app.main.NewDB"
      }
    }
  ]
}
GET /api/search?q=xxx&kind=type|provider|object&module=pkg-prefix&state=instantiated|error|slow&limit=50

Server-side search over the dependency graph (case-insensitive contains on type/function name). state=instantiated filters types that already have objects; error/slow filter providers whose last execution failed or exceeded the slow threshold.

GET /api/modules

Module-level aggregation: per-package node counts plus cross-package dependency lists (depends_on). The default building block for the drill-down module view.

GET /api/ego?center=<type-label>&depth=2&direction=both

Neighborhood subgraph centered on one type: depth-hop BFS (max 10) over declared dependencies; direction = deps / dependents / both. Returns {nodes, edges}.

GET /api/trace-tree?trace_id=xxx

Returns the nested call tree for one trace (inject โ†’ inject.param โ†’ resolve.* โ†’ provider.*), assembled server-side from the in-memory sink. 404-style empty result (total: 0) when the trace id is unknown (evicted or never existed).

GET /api/trace?operation=provider&status=error&limit=200&container_id=xxx

container_id narrows events to a single container (each container stamps its events with a random id). Returns in-memory unified trace events from dixtrace.

File sink behavior:

  • Prefer DIX_TRACE_FILE when configured.
  • If DIX_TRACE_FILE is unset and DIX_DIAG_FILE is set, trace file sink reuses DIX_DIAG_FILE in append mode (single-file troubleshooting setup).

Supported filters:

  • trace_id, operation, status, event, component, provider, output_type, q
  • limit, before_id, since_unix_nano, until_unix_nano
{
  "enabled": true,
  "total": 2,
  "returned": 2,
  "records": [
    {
      "id": 102,
      "operation": "provider",
      "phase": "call.failed",
      "event": "provider.call.failed",
      "status": "error",
      "provider_function": "github.com/acme/app.main.NewDB",
      "output_type": "*db.Client",
      "error": "dial tcp timeout",
      "timed_out": true,
      "occurred_at_unix_nano": 1700000000000000000
    }
  ]
}
GET /api/packages

Returns package list

[
  {
    "name": "github.com/example/app/service",
    "provider_count": 12,
    "types": ["*service.UserService", "*service.OrderService"]
  }
]
GET /api/dependencies?package=xxx&limit=100

Returns full dependency data for global/legacy views and package filtering. New scale-first module and ego views use their own bounded endpoints first.

{
  "providers": [
    {
      "id": "provider_*main.ServiceA_0",
      "output_type": "*main.ServiceA",
      "output_pkg": "github.com/example/app/service",
      "function_name": "main.NewServiceA",
      "function_pkg": "github.com/example/app",
      "input_types": ["*main.Config"],
      "input_pkgs": ["github.com/example/app/config"]
    }
  ],
  "objects": [...],
  "edges": [...]
}
GET /api/package/{packageName}

Returns Provider details for specified package

GET /api/type/{typeName}?depth=2

Returns dependency chain for specified type

{
  "root_type": "*service.UserService",
  "depth": 2,
  "nodes": [
    {"id": "*service.UserService", "type": "*service.UserService", "package": "...", "level": 0}
  ],
  "edges": [
    {"from": "*db.Database", "to": "*service.UserService", "type": "dependency"}
  ]
}

### GET `/api/group-rules`
Returns backend-registered group rules (used as UI defaults)

```json
[
  {"name": "service", "prefixes": ["github.com/acme/app/service"]}
]

## Tech Stack

- **Backend**: Go standard library `net/http`
- **Frontend**: vanilla JS, local CSS, and [vis-network](https://visjs.github.io/vis-network/) for graph rendering
- **Assets**: Go-embedded local files; no build step and no CDN dependency

## Use Cases

โœ… **Recommended**:
- Large projects (100+ providers)
- Modular architecture needing package-based viewing
- Tracking specific type dependency chains
- Debugging circular dependency issues
- Onboarding new team members

โš ๏ธ **Notes**:
- Production environment should restrict access (internal network or dev only)
- Very large projects (1000+ providers) should use depth limits

## Example

See `example/http/main.go` for complete example.

Documentation ยถ

Index ยถ

Constants ยถ

This section is empty.

Variables ยถ

This section is empty.

Functions ยถ

func Example ยถ

func Example(di *dix.Dix)

Example demonstrates how to use the HTTP server for dependency visualization

func RegisterGroupRules ยถ

func RegisterGroupRules(rules ...GroupRule)

RegisterGroupRules registers global group rules for visualization. This can be called by business code to predefine group rules.

Types ยถ

type DependencyData ยถ

type DependencyData struct {
	Providers []ProviderInfo `json:"providers"`
	Objects   []ObjectInfo   `json:"objects"`
	Edges     []EdgeInfo     `json:"edges"`
}

DependencyData represents the structure of dependency information

type EdgeInfo ยถ

type EdgeInfo struct {
	From string `json:"from"`
	To   string `json:"to"`
	Type string `json:"type"` // "provider", "object", "dependency"
}

EdgeInfo represents a dependency relationship

type GroupRule ยถ

type GroupRule struct {
	Name     string   `json:"name"`
	Prefixes []string `json:"prefixes"`
}

GroupRule defines a group name with prefix list for aggregation.

type IssueInfo ยถ added in v2.2.0

type IssueInfo struct {
	Severity           string `json:"severity"`
	Kind               string `json:"kind"`
	ProviderID         string `json:"provider_id,omitempty"`
	Provider           string `json:"provider,omitempty"`
	OutputType         string `json:"output_type,omitempty"`
	Module             string `json:"module,omitempty"`
	Title              string `json:"title"`
	RootCause          string `json:"root_cause,omitempty"`
	Hint               string `json:"hint,omitempty"`
	TraceID            string `json:"trace_id,omitempty"`
	OccurredAtUnixNano int64  `json:"occurred_at_unix_nano,omitempty"`
}

IssueInfo is one actionable diagnostic item with a stable link back to the graph/trace.

type ObjectInfo ยถ

type ObjectInfo struct {
	ID            string `json:"id"`
	Type          string `json:"type"`
	Group         string `json:"group"`
	IsInitialized bool   `json:"is_initialized"`
}

ObjectInfo contains information about an object instance

type PackageDetailsData ยถ

type PackageDetailsData struct {
	Package   string         `json:"package"`
	Providers []ProviderInfo `json:"providers"`
	Edges     []EdgeInfo     `json:"edges"`
}

PackageDetailsData contains detailed information for a package

type PackageInfo ยถ

type PackageInfo struct {
	Name          string   `json:"name"`
	ProviderCount int      `json:"provider_count"`
	Types         []string `json:"types"`
}

PackageInfo contains information about a package

type ProviderInfo ยถ

type ProviderInfo struct {
	ID             string   `json:"id"`
	RegistrationID uint64   `json:"registration_id"`
	ProviderIDs    []string `json:"provider_ids"`
	OutputType     string   `json:"output_type"`
	OutputTypes    []string `json:"output_types,omitempty"`
	OutputPkg      string   `json:"output_pkg"`
	FunctionName   string   `json:"function_name"`
	FunctionPkg    string   `json:"function_pkg"`
	FunctionFile   string   `json:"function_file"`
	FunctionLine   int      `json:"function_line"`
	InputTypes     []string `json:"input_types"`
	InputPkgs      []string `json:"input_pkgs"`
}

ProviderInfo contains information about a provider

type ResolvedCount2 ยถ added in v2.2.0

type ResolvedCount2 struct {
	Type  string `json:"type"`
	Count int64  `json:"count"`
}

ResolvedCount2 ๆ˜ฏ dixhttp ๅฏนๅ†…้ƒจๅˆ†ๆž่ฎกๆ•ฐ็ฑปๅž‹็š„ๆŠ•ๅฝฑใ€‚

type Server ยถ

type Server struct {
	// contains filtered or unexported fields
}

Server provides HTTP endpoints to visualize dependency relationships

func NewServer ยถ

func NewServer(di *dix.Dix) *Server

NewServer creates a new HTTP server for dependency visualization

func NewServerWithOptions ยถ

func NewServerWithOptions(di *dix.Dix, opts ...ServerOption) *Server

NewServerWithOptions creates a new HTTP server with options.

func (*Server) HandleDependencies ยถ

func (s *Server) HandleDependencies(w http.ResponseWriter, r *http.Request)

func (*Server) HandleDiagnostics ยถ

func (s *Server) HandleDiagnostics(w http.ResponseWriter, r *http.Request)

HandleDiagnostics returns records from DIX_DIAG_FILE (JSONL). Query params: - kind: trace|error (optional) - event: trace event fuzzy match (optional) - q: full-text search over record JSON (optional) - limit: optional positive integer, default 200, max 2000 - before_id: optional record id cursor for older-page query - since_unix_nano: optional lower time bound - until_unix_nano: optional upper time bound

func (*Server) HandleEgo ยถ added in v2.2.0

func (s *Server) HandleEgo(w http.ResponseWriter, r *http.Request)

HandleEgo ่ฟ”ๅ›žไปฅ center ไธบไธญๅฟƒ็š„ N ่ทณ้‚ปๅŸŸๅญๅ›พใ€‚ Query params: - center: ็ฑปๅž‹ label(ๅฟ…ๅกซ) - depth: ็ผบ็œ 2,ไธŠ้™ 10 - direction: both|deps|dependents,็ผบ็œ both

func (*Server) HandleErrors ยถ

func (s *Server) HandleErrors(w http.ResponseWriter, r *http.Request)

HandleErrors returns recent Inject/TryInject error events. Query params: - limit: optional positive integer to limit returned rows.

func (*Server) HandleGroupRules ยถ

func (s *Server) HandleGroupRules(w http.ResponseWriter, r *http.Request)

HandleGroupRules returns global group rules for visualization.

func (*Server) HandleIndex ยถ

func (s *Server) HandleIndex(w http.ResponseWriter, r *http.Request)

HandleIndex serves the HTML visualization page

func (*Server) HandleIssues ยถ added in v2.2.0

func (s *Server) HandleIssues(w http.ResponseWriter, r *http.Request)

HandleIssues merges injection failures, provider failures, and slow providers into one issue-first diagnostic feed.

func (*Server) HandleModule ยถ added in v2.2.0

func (s *Server) HandleModule(w http.ResponseWriter, r *http.Request)

HandleModule returns a bounded provider/type topology for one module. Query params: - name: exact module/package path (required) - limit: max nodes, default 100, max 500 - edge_limit: max edges, default 300, max 1000

func (*Server) HandleModules ยถ added in v2.2.0

func (s *Server) HandleModules(w http.ResponseWriter, r *http.Request)

HandleModules ่ฟ”ๅ›žๆจกๅ—็บง่šๅˆ่ง†ๅ›พ(ๅซ่ทจๆจกๅ—ไพ่ต–)ใ€‚

func (*Server) HandlePackageDetails ยถ

func (s *Server) HandlePackageDetails(w http.ResponseWriter, r *http.Request)

HandlePackageDetails returns details for a specific package

func (*Server) HandlePackages ยถ

func (s *Server) HandlePackages(w http.ResponseWriter, r *http.Request)

HandlePackages returns list of packages for navigation

func (*Server) HandleRuntimeStats ยถ

func (s *Server) HandleRuntimeStats(w http.ResponseWriter, r *http.Request)

HandleRuntimeStats returns provider runtime stats for startup/perf diagnosis. Query params: - limit: optional positive integer to limit returned rows.

func (*Server) HandleSearch ยถ added in v2.2.0

func (s *Server) HandleSearch(w http.ResponseWriter, r *http.Request)

HandleSearch ๆฃ€็ดขๅ›พ่Š‚็‚นใ€‚ Query params: - q: ๅ…ณ้”ฎๅญ—(็ฑปๅž‹ๅ/ๅ‡ฝๆ•ฐๅๅŒ…ๅซๅŒน้…) - kind: type|provider|object - module: pkg ๅ‰็ผ€ - state: instantiated|error|slow - limit: ็ผบ็œ 50,ไธŠ้™ 500

func (*Server) HandleStats ยถ

func (s *Server) HandleStats(w http.ResponseWriter, r *http.Request)

HandleStats returns summary statistics

func (*Server) HandleTrace ยถ

func (s *Server) HandleTrace(w http.ResponseWriter, r *http.Request)

HandleTrace returns in-memory dixtrace events. Query params: - trace_id, operation, status, event, component, provider, output_type, q - limit, before_id, since_unix_nano, until_unix_nano

func (*Server) HandleTraceTree ยถ added in v2.2.0

func (s *Server) HandleTraceTree(w http.ResponseWriter, r *http.Request)

HandleTraceTree returns the nested call tree of one trace. Query params: - trace_id: required trace id.

func (*Server) HandleTypeDetails ยถ

func (s *Server) HandleTypeDetails(w http.ResponseWriter, r *http.Request)

HandleTypeDetails returns dependency details for a specific type

func (*Server) ListenAndServe ยถ

func (s *Server) ListenAndServe(addr string) error

ListenAndServe starts the HTTP server on the specified address

func (*Server) ServeHTTP ยถ

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler interface

type ServerOption ยถ

type ServerOption func(*Server)

ServerOption customizes the HTTP server behavior.

func WithBasePath ยถ

func WithBasePath(basePath string) ServerOption

WithBasePath sets an optional URL prefix for all routes. Example: "/dix".

type StatsData ยถ

type StatsData struct {
	ProviderCount int `json:"provider_count"`
	ObjectCount   int `json:"object_count"`
	PackageCount  int `json:"package_count"`
	EdgeCount     int `json:"edge_count"`

	// ๆฆ‚่งˆๅขžๅผบ(P4a):ๆจกๅ—ๆ•ฐใ€่งฃๆž็ƒญๅบฆ TopNใ€ๆ…ข/้”™่ฏฏ provider
	Modules        int              `json:"modules"`
	TopResolved    []ResolvedCount2 `json:"top_resolved,omitempty"`
	SlowProviders  []string         `json:"slow_providers,omitempty"`
	ErrorProviders []string         `json:"error_providers,omitempty"`
}

StatsData contains summary statistics

type TypeDetailsData ยถ

type TypeDetailsData struct {
	RootType string     `json:"root_type"`
	Depth    int        `json:"depth"`
	Nodes    []TypeNode `json:"nodes"`
	Edges    []EdgeInfo `json:"edges"`
}

TypeDetailsData contains dependency details for a type

type TypeNode ยถ

type TypeNode struct {
	ID      string `json:"id"`
	Type    string `json:"type"`
	Package string `json:"package"`
	Level   int    `json:"level"`
}

TypeNode represents a type in the dependency graph

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL