Skip to content

Commit 5a82968

Browse files
committed
rag/treesitter: add nocgo build support
Allow building without CGO for applications that do not use RAG. DocumentProcessor returns an error when built without CGO and RAG is used.
1 parent dc8062b commit 5a82968

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

pkg/rag/treesitter/treesitter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build cgo
2+
13
package treesitter
24

35
import (
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//go:build !cgo
2+
3+
package treesitter
4+
5+
import (
6+
"errors"
7+
8+
"github.com/docker/docker-agent/pkg/rag/chunk"
9+
)
10+
11+
// DocumentProcessor implements chunk.DocumentProcessor and always returns an
12+
// error when the application is built without CGO and uses RAG. For applications
13+
// that do not use RAG, this allows building without any CGO requirement.
14+
type DocumentProcessor struct{}
15+
16+
// NewDocumentProcessor creates a new DocumentProcessor.
17+
func NewDocumentProcessor(_, _ int, _ bool) *DocumentProcessor {
18+
return &DocumentProcessor{}
19+
}
20+
21+
// Process implements chunk.DocumentProcessor.
22+
func (p *DocumentProcessor) Process(_ string, _ []byte) ([]chunk.Chunk, error) {
23+
return nil, errors.New("rag/treesitter: document processor must be built with CGO_ENABLED=1")
24+
}

0 commit comments

Comments
 (0)