-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsochdb.go
More file actions
109 lines (108 loc) · 2.68 KB
/
Copy pathsochdb.go
File metadata and controls
109 lines (108 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Package sochdb provides Go SDK for SochDB v0.4.3
//
// Dual-mode architecture: Embedded (FFI) + Server (gRPC/IPC)
//
// Architecture: Flexible Deployment
// ==================================
// This SDK supports BOTH modes:
//
// 1. Embedded Mode (FFI) - For single-process apps:
// - Direct FFI bindings to Rust libraries (via CGO)
// - No server required - just import and run
// - Best for: Local development, simple apps, edge deployments
//
// 2. Server Mode (gRPC) - For distributed systems:
// - Thin client connecting to sochdb-grpc server
// - Best for: Production, multi-language, scalability
//
// Example (Server Mode - gRPC):
//
// import "github.com/sochdb/sochdb-go"
//
// // Connect to server
// client, err := sochdb.GrpcConnect("localhost:50051")
// if err != nil {
// log.Fatal(err)
// }
// defer client.Close()
//
// // Use the client
// err = client.PutKv(context.Background(), "namespace", "key", []byte("value"))
//
// Example (Embedded Mode - IPC):
//
// import "github.com/sochdb/sochdb-go"
//
// // Connect via Unix socket
// client, err := sochdb.Connect("/path/to/db/sochdb.sock")
// if err != nil {
// log.Fatal(err)
// }
// defer client.Close()
//
// // Use the client
// value, err := client.Get([]byte("key"))
//
// Example (Namespace & Collections - v0.4.1):
//
// import "github.com/sochdb/sochdb-go"
// import "github.com/sochdb/sochdb-go/embedded"
//
// // Open embedded database
// db, err := embedded.Open("./mydb")
// if err != nil {
// log.Fatal(err)
// }
// defer db.Close()
//
// // Create namespace
// ns, err := db.CreateNamespace("tenant_123")
// if err != nil {
// log.Fatal(err)
// }
//
// // Create collection
// collection, err := ns.CreateCollection(sochdb.CollectionConfig{
// Name: "documents",
// Dimension: 384,
// })
// if err != nil {
// log.Fatal(err)
// }
//
// // Insert vectors
// err = collection.Insert([]float32{1.0, 2.0, 3.0}, map[string]interface{}{"source": "web"}, "")
//
// Example (Priority Queue - v0.4.1):
//
// import "github.com/sochdb/sochdb-go"
// import "github.com/sochdb/sochdb-go/embedded"
//
// // Open database
// db, err := embedded.Open("./queue_db")
// if err != nil {
// log.Fatal(err)
// }
// defer db.Close()
//
// // Create queue
// queue := sochdb.NewPriorityQueue(db, "tasks", nil)
//
// // Enqueue task
// taskID, err := queue.Enqueue(1, []byte("high priority task"), nil)
// if err != nil {
// log.Fatal(err)
// }
//
// // Dequeue and process
// task, err := queue.Dequeue("worker-1")
// if err != nil {
// log.Fatal(err)
// }
// if task != nil {
// // Process task...
// err = queue.Ack(task.TaskID)
// }
package sochdb
// Version is the current SDK version.
const Version = "0.4.5"