Official External Packages
The Xu 0.16.0 SDK bundles the external drivers and their native source resources. The matrix below is scoped to that bundle; API pages display their own package source identity (currently 1.0.2), which differs from the SDK bundle’s 1.0.0 manifest. Do not infer bundled capabilities from a newer API declaration. Drivers cover databases, caches, messaging, object storage and service discovery; check each package for protocol and platform limits.
1. Select the SDK bundle or a fixed source commit
Place your project beside the extracted SDK and declare its bundled packages using a local source locator. Adjust the relative path if you installed the SDK elsewhere:
module: my_app
version: !ver 0.1.0
xu: !ver 0.16.0
require:
"github.com/xulang-org/packages": file:../xu-v0.16.0/packages
To fetch the source used by this SDK instead, select its full immutable commit:
require:
"github.com/xulang-org/packages": git:https://github.com/xulang-org/packages.git@96693e6cce8d51eba45e4f68dc12ce06f7a2336b
From your project directory, resolve and lock dependencies, then check and build:
xu install
xu check main.xu --offline
xu build main.xu -o my_app
Module versions and Git tags have separate roles: this bundle declares module version 1.0.0. The fixed source locator above selects the exact source independently of tag availability. Keep xu.lock with your application and consult modules and dependencies for frozen, vendor and proxy workflows.
2. Importing Packages in Source Code
Xu enforces an explicit namespace alias convention for all external packages: alias #full/module/path/pkg. This eliminates global namespace pollution and makes all external dependencies visible directly at the top of the file.
@main
// 1. Standard library modules have no alias; prefixed with #
#database/sql
// 2. External packages declare an alias and full repository path
mysql #github.com/xulang-org/packages/mysql
redis #github.com/xulang-org/packages/redis
postgres #github.com/xulang-org/packages/postgres
fn main() int {
// Access APIs directly through the declared alias
println("Drivers loaded successfully")
<< 0
}Important: Do not write #mysql or #redis. External module imports require an explicit alias and full module path. Standard library imports and local package imports (such as #util) follow their own resolution rules. The integrations listed here belong to github.com/xulang-org/packages; other external modules have their own identities.
3. Hands-on Quickstart Examples
Example 1: Using the MySQL Driver with database/sql
The standard library database/sql provides connection pooling, transactions, and result row abstractions; the concrete MySQL driver is implemented by packages/mysql:
@main
#database/sql
mysql #github.com/xulang-org/packages/mysql
fn main() int {
dsn := "root:123456@tcp(127.0.0.1:3306)/test_db?tls=false"
$db := sql.open(mysql.driver(), dsn)
db.ping() >>> (err) {
println("Database ping failed: " + err.msg())
<< 1
}
println("Connected to MySQL successfully!")
db.close() >>> (err) { << 1 }
<< 0
}Example 2: Redis Client Operations
@main
redis #github.com/xulang-org/packages/redis
fn main() int {
$client := redis.open("127.0.0.1:6379") >>> (err) {
println("Redis connect error: " + err.msg())
<< 1
}
client.set("app_version", "demo") >>> (err) { << 1 }
val := client.get("app_version") >>> (err) { << 1 }
println("Key 'app_version': " + val)
client.close()
<< 0
}Example 3: Object Storage with S3 / MinIO
@main
s3 #github.com/xulang-org/packages/s3
fn main() int {
$client := s3.open("http://127.0.0.1:9000", "access_key", "secret_key", "us-east-1")
client.put_object("my-bucket", "welcome.txt", "Hello from Xu!", "text/plain") >>> (err) {
println("S3 upload failed: " + err.msg())
<< 1
}
println("Object uploaded successfully")
<< 0
}4. Package Catalog & One-Line Import Snippets
The packages repository contains 29 service integrations and a shared transport package. You can copy-paste the exact import snippet into your code:
The status columns below describe code paths inspected in the selected SDK’s bundled packages/*.xu sources, including client.xu, authentication files, tls.xu helpers and transport/mod.xu. They are source evidence, not service interoperability or platform acceptance results. unknown means the capability has not been proven here.
TLS paths: HTTPS business requests use the shared TLS connection path; their legacy manual fd pools remain plaintext. A TLS byte-stream helper only provides tls_connect / tls_connect_config and raw reads / writes; it does not establish that the package’s ordinary authenticated client or pool runs over TLS. That integration is explicitly unknown. SMTP STARTTLS and DNS-over-TLS query integration are unknown. The default TLS configuration verifies certificates and hostnames; these source paths have not been exercised against every service here.
Platform: Network drivers use native sockets and are local SDK paths, outside the browser playground subset. Per-OS / architecture acceptance is unknown for every row. SQLite now uses pure Xu sqlite_native dynamic loading, without requiring static .xulib slices. See download boundaries and status.
| Category | Package | Service | One-Line Import Snippet | API Reference | Protocol scope | Authentication | TLS path | Platform / acceptance |
|---|---|---|---|---|---|---|---|---|
| Databases | mysql | MySQL / MariaDB | mysql #github.com/xulang-org/packages/mysql | API Reference | MySQL text protocol | mysql_native_password; caching_sha2_password rejected | DSN TLS upgrade with certificate / hostname checks | Native sockets; acceptance unknown |
| Databases | postgres | PostgreSQL | postgres #github.com/xulang-org/packages/postgres | API Reference | PostgreSQL wire 3.0 | Trust / cleartext / MD5 / SCRAM-SHA-256 | SSLRequest upgrade; require / verify-ca / verify-full | Native sockets; acceptance unknown |
| Databases | sqlite | SQLite Embedded | sqlite #github.com/xulang-org/packages/sqlite | API Reference | Embedded SQLite C API | Not applicable (embedded) | Not applicable (no network transport) | Pure Xu dynamic loading; no .xulib; target acceptance unknown |
| Databases | clickhouse | ClickHouse Columnar | clickhouse #github.com/xulang-org/packages/clickhouse | API Reference | HTTP SQL requests | X-ClickHouse-User / Key headers | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Databases | mongodb | MongoDB Document DB | mongodb #github.com/xulang-org/packages/mongodb | API Reference | OP_MSG subset; no compression / topology discovery | unknown | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Databases | cassandra | Apache Cassandra | cassandra #github.com/xulang-org/packages/cassandra | API Reference | CQL binary v4; startup / queries | unknown | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Databases | neo4j | Neo4j Graph Database | neo4j #github.com/xulang-org/packages/neo4j | API Reference | HTTP Cypher transactions; no Bolt claim | HTTP Basic | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Caches | redis | Redis High-Speed Cache | redis #github.com/xulang-org/packages/redis | API Reference | RESP2 and bounded RESP3 types | Password AUTH; ACL username support unknown | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Caches | memcached | Memcached | memcached #github.com/xulang-org/packages/memcached | API Reference | Text commands | unknown | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Messaging | kafka | Apache Kafka | kafka #github.com/xulang-org/packages/kafka | API Reference | Produce v3 / Fetch v4 subset; uncompressed records | unknown | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Messaging | rabbitmq | RabbitMQ / AMQP | rabbitmq #github.com/xulang-org/packages/rabbitmq | API Reference | AMQP 0-9-1 subset | SASL PLAIN | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Messaging | nats | NATS High Throughput | nats #github.com/xulang-org/packages/nats | API Reference | NATS text protocol | User / password CONNECT | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Messaging | mqtt | MQTT IoT Protocol | mqtt #github.com/xulang-org/packages/mqtt | API Reference | MQTT 3.1.1; QoS 0 / 1 | CONNECT username / password | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Coordination | etcd | etcd v3 Distributed KV | etcd #github.com/xulang-org/packages/etcd | API Reference | v3 HTTP/JSON gateway; not native gRPC | unknown | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Coordination | consul | HashiCorp Consul | consul #github.com/xulang-org/packages/consul | API Reference | HTTP API | X-Consul-Token header | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Coordination | zookeeper | Apache ZooKeeper | zookeeper #github.com/xulang-org/packages/zookeeper | API Reference | Four-letter admin commands; not a session client | unknown | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Coordination | nacos | Alibaba Nacos | nacos #github.com/xulang-org/packages/nacos | API Reference | HTTP OpenAPI subset | unknown | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Search | elasticsearch | Elasticsearch / OpenSearch | elasticsearch #github.com/xulang-org/packages/elasticsearch | API Reference | HTTP/JSON API subset | unknown | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Search | meilisearch | Meilisearch Engine | meilisearch #github.com/xulang-org/packages/meilisearch | API Reference | HTTP/JSON; integer document IDs | Bearer API key | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Observability | prometheus | Prometheus Metrics | prometheus #github.com/xulang-org/packages/prometheus | API Reference | Text metrics / HTTP Pushgateway | unknown | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Observability | influxdb | InfluxDB Time Series | influxdb #github.com/xulang-org/packages/influxdb | API Reference | HTTP API / line protocol | Authorization: Token | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Vectors & AI | milvus | Milvus Vector DB | milvus #github.com/xulang-org/packages/milvus | API Reference | REST v2 search; integer IDs | Bearer token field | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Vectors & AI | qdrant | Qdrant Vector Engine | qdrant #github.com/xulang-org/packages/qdrant | API Reference | HTTP/JSON API subset | api-key header | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Vectors & AI | chroma | Chroma Embeddings DB | chroma #github.com/xulang-org/packages/chroma | API Reference | HTTP/JSON API subset | unknown | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Storage | s3 | AWS S3 / MinIO Protocol | s3 #github.com/xulang-org/packages/s3 | API Reference | S3 HTTP object API subset | AWS SigV4 | HTTPS request path; fd pools remain plaintext | Native sockets; acceptance unknown |
| Protocols | grpc | gRPC / HTTP/2 Client | grpc #github.com/xulang-org/packages/grpc | API Reference | HTTP/2 unary; no streaming / compression | unknown | HTTPS unary with ALPN h2; fd pool is h2c | Native sockets; acceptance unknown |
| Protocols | websocket | WebSocket Full-Duplex | websocket #github.com/xulang-org/packages/websocket | API Reference | HTTP Upgrade / WebSocket frames | unknown | wss via connect_secure; retain transport.Conn | Native sockets; acceptance unknown |
| Protocols | dns | DNS Custom Resolver | dns #github.com/xulang-org/packages/dns | API Reference | TCP DNS A-record queries; not UDP | unknown | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Protocols | smtp | SMTP Mail Delivery | smtp #github.com/xulang-org/packages/smtp | API Reference | SMTP mail delivery | AUTH LOGIN | TLS byte-stream helper; client TLS unknown | Native sockets; acceptance unknown |
| Shared transport | transport | TCP / TLS / HTTP framing | transport #github.com/xulang-org/packages/transport | API Reference | TCP / TLS; HTTP/1.x response framing | Application-level authentication unknown | crypto/tls via dial; custom tls.Config | Native sockets; acceptance unknown |
5. Boundaries & Production Builds
- SQLite & Metal Pure-FFI Architecture: The SQLite driver now dynamically loads (
dlopen) systemlibsqlite3via pure-Xusqlite_native(Windows automatically uses built-inwinsqlite3.dll, overridable viaXU_SQLITE_LIBRARY), eliminating the legacy requirement to compile.xulibslices withmake native. The optional Metal GPU compute package dynamically loadslibxu_metal.dylibviametal_native(built viapython3 metal/native/build.py, overridable viaXU_METAL_LIBRARY). - Frozen Builds in Production: For immutable CI/CD deployment pipelines, commit the generated
vendor/directory andxu.lockto Git, then runxu build main.xu --frozen. This strictly forbids outbound network calls during build for 100% reproducible builds.
For more details on MVS resolution, checksum verification, and private proxies, see: Modules and Dependencies Specification and Native Modules Specification.
Build the Metal native library (optional macOS)
Applications that do not import metal do not need to build Metal native assets. Before using Metal GPU compute on Apple Silicon macOS, build its shared dynamic library:
cd packages
python3 metal/native/build.py