mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-13 00:58:50 +00:00
feat: enhance IPFS configuration and logging in CLI
- Added IPFS cluster API and HTTP API configuration options to node and bootstrap configurations. - Improved the generation of IPFS-related URLs and parameters for better integration. - Enhanced error logging in cache handlers to provide more context on failures during cache operations.
This commit is contained in:
parent
5b21774e04
commit
50f7abf376
15
CHANGELOG.md
15
CHANGELOG.md
@ -13,6 +13,21 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
|||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
## [0.58.0] - 2025-11-07
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Added default configuration for IPFS Cluster and IPFS API settings in node and gateway configurations.
|
||||||
|
- Added `ipfs` configuration section to node configuration, including settings for cluster API URL, replication factor, and encryption.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Improved error logging for cache operations in the Gateway.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
\n
|
||||||
## [0.57.0] - 2025-11-07
|
## [0.57.0] - 2025-11-07
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
2
Makefile
2
Makefile
@ -21,7 +21,7 @@ test-e2e:
|
|||||||
|
|
||||||
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill
|
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill
|
||||||
|
|
||||||
VERSION := 0.57.0
|
VERSION := 0.58.0
|
||||||
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||||
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||||
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
||||||
|
|||||||
@ -405,6 +405,10 @@ func GenerateNodeConfig(name, id string, listenPort, rqliteHTTPPort, rqliteRaftP
|
|||||||
joinAddr = "localhost:5001"
|
joinAddr = "localhost:5001"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate IPFS cluster API port (9094 for bootstrap, 9104+ for nodes)
|
||||||
|
// Pattern: Bootstrap (5001) -> 9094, Node2 (5002) -> 9104, Node3 (5003) -> 9114
|
||||||
|
clusterAPIPort := 9094 + (rqliteHTTPPort-5001)*10
|
||||||
|
|
||||||
return fmt.Sprintf(`node:
|
return fmt.Sprintf(`node:
|
||||||
id: "%s"
|
id: "%s"
|
||||||
type: "node"
|
type: "node"
|
||||||
@ -425,6 +429,17 @@ database:
|
|||||||
cluster_sync_interval: "30s"
|
cluster_sync_interval: "30s"
|
||||||
peer_inactivity_limit: "24h"
|
peer_inactivity_limit: "24h"
|
||||||
min_cluster_size: 1
|
min_cluster_size: 1
|
||||||
|
ipfs:
|
||||||
|
# IPFS Cluster API endpoint for pin management (leave empty to disable)
|
||||||
|
cluster_api_url: "http://localhost:%d"
|
||||||
|
# IPFS HTTP API endpoint for content retrieval
|
||||||
|
api_url: "http://localhost:%d"
|
||||||
|
# Timeout for IPFS operations
|
||||||
|
timeout: "60s"
|
||||||
|
# Replication factor for pinned content
|
||||||
|
replication_factor: 3
|
||||||
|
# Enable client-side encryption before upload
|
||||||
|
enable_encryption: true
|
||||||
|
|
||||||
discovery:
|
discovery:
|
||||||
%s
|
%s
|
||||||
@ -440,7 +455,7 @@ security:
|
|||||||
logging:
|
logging:
|
||||||
level: "info"
|
level: "info"
|
||||||
format: "console"
|
format: "console"
|
||||||
`, nodeID, listenPort, dataDir, dataDir, rqliteHTTPPort, rqliteRaftPort, joinAddr, peersYAML.String(), 4001, rqliteHTTPPort, rqliteRaftPort)
|
`, nodeID, listenPort, dataDir, dataDir, rqliteHTTPPort, rqliteRaftPort, joinAddr, clusterAPIPort, rqliteHTTPPort, peersYAML.String(), 4001, rqliteHTTPPort, rqliteRaftPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateBootstrapConfig generates a bootstrap configuration
|
// GenerateBootstrapConfig generates a bootstrap configuration
|
||||||
@ -472,6 +487,17 @@ database:
|
|||||||
cluster_sync_interval: "30s"
|
cluster_sync_interval: "30s"
|
||||||
peer_inactivity_limit: "24h"
|
peer_inactivity_limit: "24h"
|
||||||
min_cluster_size: 1
|
min_cluster_size: 1
|
||||||
|
ipfs:
|
||||||
|
# IPFS Cluster API endpoint for pin management (leave empty to disable)
|
||||||
|
cluster_api_url: "http://localhost:9094"
|
||||||
|
# IPFS HTTP API endpoint for content retrieval
|
||||||
|
api_url: "http://localhost:%d"
|
||||||
|
# Timeout for IPFS operations
|
||||||
|
timeout: "60s"
|
||||||
|
# Replication factor for pinned content
|
||||||
|
replication_factor: 3
|
||||||
|
# Enable client-side encryption before upload
|
||||||
|
enable_encryption: true
|
||||||
|
|
||||||
discovery:
|
discovery:
|
||||||
bootstrap_peers: []
|
bootstrap_peers: []
|
||||||
@ -487,7 +513,7 @@ security:
|
|||||||
logging:
|
logging:
|
||||||
level: "info"
|
level: "info"
|
||||||
format: "console"
|
format: "console"
|
||||||
`, nodeID, listenPort, dataDir, dataDir, rqliteHTTPPort, rqliteRaftPort, 4001, rqliteHTTPPort, rqliteRaftPort)
|
`, nodeID, listenPort, dataDir, dataDir, rqliteHTTPPort, rqliteRaftPort, rqliteHTTPPort, 4001, rqliteHTTPPort, rqliteRaftPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateGatewayConfig generates a gateway configuration
|
// GenerateGatewayConfig generates a gateway configuration
|
||||||
@ -515,5 +541,12 @@ func GenerateGatewayConfig(bootstrapPeers string) string {
|
|||||||
client_namespace: "default"
|
client_namespace: "default"
|
||||||
rqlite_dsn: ""
|
rqlite_dsn: ""
|
||||||
%s
|
%s
|
||||||
|
olric_servers:
|
||||||
|
- "127.0.0.1:3320"
|
||||||
|
olric_timeout: "10s"
|
||||||
|
ipfs_cluster_api_url: "http://localhost:9094"
|
||||||
|
ipfs_api_url: "http://localhost:9105"
|
||||||
|
ipfs_timeout: "60s"
|
||||||
|
ipfs_replication_factor: 3
|
||||||
`, peersYAML.String())
|
`, peersYAML.String())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1794,13 +1794,11 @@ func generateGatewayConfigDirect(bootstrapPeers string, enableHTTPS bool, domain
|
|||||||
olricYAML.WriteString(" - \"localhost:3320\"\n")
|
olricYAML.WriteString(" - \"localhost:3320\"\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPFS Cluster configuration (defaults - can be customized later)
|
// IPFS Cluster configuration
|
||||||
ipfsYAML := `# IPFS Cluster configuration (optional)
|
ipfsYAML := `ipfs_cluster_api_url: "http://localhost:9094"
|
||||||
# Uncomment and configure if you have IPFS Cluster running:
|
ipfs_api_url: "http://localhost:9105"
|
||||||
# ipfs_cluster_api_url: "http://localhost:9094"
|
ipfs_timeout: "60s"
|
||||||
# ipfs_api_url: "http://localhost:5001"
|
ipfs_replication_factor: 3
|
||||||
# ipfs_timeout: "60s"
|
|
||||||
# ipfs_replication_factor: 3
|
|
||||||
`
|
`
|
||||||
|
|
||||||
return fmt.Sprintf(`listen_addr: ":6001"
|
return fmt.Sprintf(`listen_addr: ":6001"
|
||||||
|
|||||||
@ -8,7 +8,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/DeBrosOfficial/network/pkg/logging"
|
||||||
olriclib "github.com/olric-data/olric"
|
olriclib "github.com/olric-data/olric"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Cache HTTP handlers for Olric distributed cache
|
// Cache HTTP handlers for Olric distributed cache
|
||||||
@ -76,12 +78,20 @@ func (g *Gateway) cacheGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeError(w, http.StatusNotFound, "key not found")
|
writeError(w, http.StatusNotFound, "key not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
g.logger.ComponentError(logging.ComponentGeneral, "failed to get key from cache",
|
||||||
|
zap.String("dmap", req.DMap),
|
||||||
|
zap.String("key", req.Key),
|
||||||
|
zap.Error(err))
|
||||||
writeError(w, http.StatusInternalServerError, fmt.Sprintf("failed to get key: %v", err))
|
writeError(w, http.StatusInternalServerError, fmt.Sprintf("failed to get key: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
value, err := decodeValueFromOlric(gr)
|
value, err := decodeValueFromOlric(gr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
g.logger.ComponentError(logging.ComponentGeneral, "failed to decode value from cache",
|
||||||
|
zap.String("dmap", req.DMap),
|
||||||
|
zap.String("key", req.Key),
|
||||||
|
zap.Error(err))
|
||||||
writeError(w, http.StatusInternalServerError, fmt.Sprintf("failed to decode value: %v", err))
|
writeError(w, http.StatusInternalServerError, fmt.Sprintf("failed to decode value: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user