docs: fix S3 examples and improve storage path visibility

- Fix 4 S3 storage configuration examples in README
- Change from 'options: {bucket}' to 's3Storage: {bucketName}'
- Enhance FileSystemStorage logs to show resolved path
- Helps users verify their configuration is working correctly
- Prevents silent failures like v3.43.2 persistence regression
This commit is contained in:
David Snelling 2025-10-14 14:59:38 -07:00
parent 09c71c398f
commit e507fcfe06
2 changed files with 45 additions and 10 deletions

View file

@ -543,12 +543,28 @@ await brain.import('research.pdf') // PDF with table extraction
```javascript ```javascript
// Single node (default) // Single node (default)
const brain = new Brainy({ const brain = new Brainy({
storage: {type: 's3', options: {bucket: 'my-data'}} storage: {
type: 's3',
s3Storage: {
bucketName: 'my-data',
region: 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
}
}
}) })
// Distributed cluster - just add one flag! // Distributed cluster - just add one flag!
const brain = new Brainy({ const brain = new Brainy({
storage: {type: 's3', options: {bucket: 'my-data'}}, storage: {
type: 's3',
s3Storage: {
bucketName: 'my-data',
region: 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
}
},
distributed: true // That's it! Everything else is automatic distributed: true // That's it! Everything else is automatic
}) })
``` ```
@ -568,7 +584,15 @@ import { Brainy, NounType } from '@soulcraft/brainy'
// Ingestion nodes (optimized for writes) // Ingestion nodes (optimized for writes)
const ingestionNode = new Brainy({ const ingestionNode = new Brainy({
storage: {type: 's3', options: {bucket: 'social-data'}}, storage: {
type: 's3',
s3Storage: {
bucketName: 'social-data',
region: 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
}
},
distributed: true, distributed: true,
writeOnly: true // Optimized for high-throughput writes writeOnly: true // Optimized for high-throughput writes
}) })
@ -585,7 +609,15 @@ blueskyStream.on('post', async (post) => {
// Search nodes (optimized for queries) // Search nodes (optimized for queries)
const searchNode = new Brainy({ const searchNode = new Brainy({
storage: {type: 's3', options: {bucket: 'social-data'}}, storage: {
type: 's3',
s3Storage: {
bucketName: 'social-data',
region: 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
}
},
distributed: true, distributed: true,
readOnly: true // Optimized for fast queries readOnly: true // Optimized for fast queries
}) })

View file

@ -306,12 +306,13 @@ export async function createStorage(
) )
return new MemoryStorage() return new MemoryStorage()
} }
console.log('Using file system storage (forced)') const fsPath = getFileSystemPath(options)
console.log(`Using file system storage (forced): ${fsPath}`)
try { try {
const { FileSystemStorage } = await import( const { FileSystemStorage } = await import(
'./adapters/fileSystemStorage.js' './adapters/fileSystemStorage.js'
) )
return new FileSystemStorage(getFileSystemPath(options)) return new FileSystemStorage(fsPath)
} catch (error) { } catch (error) {
console.warn( console.warn(
'Failed to load FileSystemStorage, falling back to memory storage:', 'Failed to load FileSystemStorage, falling back to memory storage:',
@ -359,12 +360,13 @@ export async function createStorage(
) )
return new MemoryStorage() return new MemoryStorage()
} }
console.log('Using file system storage') const fsPath = getFileSystemPath(options)
console.log(`Using file system storage: ${fsPath}`)
try { try {
const { FileSystemStorage } = await import( const { FileSystemStorage } = await import(
'./adapters/fileSystemStorage.js' './adapters/fileSystemStorage.js'
) )
return new FileSystemStorage(getFileSystemPath(options)) return new FileSystemStorage(fsPath)
} catch (error) { } catch (error) {
console.warn( console.warn(
'Failed to load FileSystemStorage, falling back to memory storage:', 'Failed to load FileSystemStorage, falling back to memory storage:',
@ -538,12 +540,13 @@ export async function createStorage(
process.versions && process.versions &&
process.versions.node process.versions.node
) { ) {
console.log('Using file system storage (auto-detected)') const fsPath = getFileSystemPath(options)
console.log(`Using file system storage (auto-detected): ${fsPath}`)
try { try {
const { FileSystemStorage } = await import( const { FileSystemStorage } = await import(
'./adapters/fileSystemStorage.js' './adapters/fileSystemStorage.js'
) )
return new FileSystemStorage(getFileSystemPath(options)) return new FileSystemStorage(fsPath)
} catch (fsError) { } catch (fsError) {
console.warn( console.warn(
'Failed to load FileSystemStorage, falling back to memory storage:', 'Failed to load FileSystemStorage, falling back to memory storage:',