[#2] Rename internals
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
de309e3264
commit
67c5818fc1
14 changed files with 85 additions and 85 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -10,7 +10,7 @@ temp
|
||||||
test.sh
|
test.sh
|
||||||
testfile
|
testfile
|
||||||
.blast.yml
|
.blast.yml
|
||||||
.neofs-cli.yml
|
.frostfs-cli.yml
|
||||||
|
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
|
|
14
README.md
14
README.md
|
@ -52,7 +52,7 @@ FrostFS nodes with weighted load balancing).
|
||||||
|
|
||||||
If you launch HTTP gateway in bundle with [frostfs-dev-env](https://github.com/TrueCloudLab/frostfs-dev-env),
|
If you launch HTTP gateway in bundle with [frostfs-dev-env](https://github.com/TrueCloudLab/frostfs-dev-env),
|
||||||
you can get the IP address of the node in the output of `make hosts` command
|
you can get the IP address of the node in the output of `make hosts` command
|
||||||
(with s0*.neofs.devenv name).
|
(with s0*.frostfs.devenv name).
|
||||||
|
|
||||||
These two commands are functionally equivalent, they run the gate with one
|
These two commands are functionally equivalent, they run the gate with one
|
||||||
backend node (and otherwise default settings):
|
backend node (and otherwise default settings):
|
||||||
|
@ -96,7 +96,7 @@ You can provide a wallet via `--wallet` or `-w` flag. You can also specify the a
|
||||||
(if no address provided default one will be used). If wallet is used, you need to set `HTTP_GW_WALLET_PASSPHRASE` variable to decrypt the wallet.
|
(if no address provided default one will be used). If wallet is used, you need to set `HTTP_GW_WALLET_PASSPHRASE` variable to decrypt the wallet.
|
||||||
If no wallet provided, the gateway autogenerates a key pair it will use for FrostFS requests.
|
If no wallet provided, the gateway autogenerates a key pair it will use for FrostFS requests.
|
||||||
```
|
```
|
||||||
$ frostfs-http-gw -p $NEOFS_NODE -w $WALLET_PATH --address $ACCOUNT_ADDRESS
|
$ frostfs-http-gw -p $FROSTFS_NODE -w $WALLET_PATH --address $ACCOUNT_ADDRESS
|
||||||
```
|
```
|
||||||
Example:
|
Example:
|
||||||
```
|
```
|
||||||
|
@ -206,7 +206,7 @@ Steps to start using name resolving:
|
||||||
1. Enable NNS resolving in config (`rpc_endpoint` must be a valid neo rpc node, see [configs](./config) for other examples):
|
1. Enable NNS resolving in config (`rpc_endpoint` must be a valid neo rpc node, see [configs](./config) for other examples):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
rpc_endpoint: http://morph-chain.neofs.devenv:30333
|
rpc_endpoint: http://morph-chain.frostfs.devenv:30333
|
||||||
resolve_order:
|
resolve_order:
|
||||||
- nns
|
- nns
|
||||||
```
|
```
|
||||||
|
@ -216,13 +216,13 @@ you can check if your container (e.g. with `container-name` name) is registered
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ curl -s --data '{"id":1,"jsonrpc":"2.0","method":"getcontractstate","params":[1]}' \
|
$ curl -s --data '{"id":1,"jsonrpc":"2.0","method":"getcontractstate","params":[1]}' \
|
||||||
http://morph-chain.neofs.devenv:30333 | jq -r '.result.hash'
|
http://morph-chain.frostfs.devenv:30333 | jq -r '.result.hash'
|
||||||
|
|
||||||
0x8e6c3cd4b976b28e84a3788f6ea9e2676c15d667
|
0x8e6c3cd4b976b28e84a3788f6ea9e2676c15d667
|
||||||
|
|
||||||
$ docker exec -it morph_chain neo-go \
|
$ docker exec -it morph_chain neo-go \
|
||||||
contract testinvokefunction \
|
contract testinvokefunction \
|
||||||
-r http://morph-chain.neofs.devenv:30333 0x8e6c3cd4b976b28e84a3788f6ea9e2676c15d667 \
|
-r http://morph-chain.frostfs.devenv:30333 0x8e6c3cd4b976b28e84a3788f6ea9e2676c15d667 \
|
||||||
resolve string:container-name.container int:16 \
|
resolve string:container-name.container int:16 \
|
||||||
| jq -r '.stack[0].value | if type=="array" then .[0].value else . end' \
|
| jq -r '.stack[0].value | if type=="array" then .[0].value else . end' \
|
||||||
| base64 -d && echo
|
| base64 -d && echo
|
||||||
|
@ -240,7 +240,7 @@ $ curl http://localhost:8082/get_by_attribute/container-name/FileName/object-nam
|
||||||
|
|
||||||
You can create a container via [frostfs-cli](https://github.com/TrueCloudLab/frostfs-node/releases):
|
You can create a container via [frostfs-cli](https://github.com/TrueCloudLab/frostfs-node/releases):
|
||||||
```
|
```
|
||||||
$ frostfs-cli -r $NEOFS_NODE -w $WALLET container create --policy $POLICY --basic-acl $ACL
|
$ frostfs-cli -r $FROSTFS_NODE -w $WALLET container create --policy $POLICY --basic-acl $ACL
|
||||||
```
|
```
|
||||||
where `$WALLET` is a path to user wallet,
|
where `$WALLET` is a path to user wallet,
|
||||||
`$ACL` -- hex encoded basic ACL value or keywords 'private, 'public-read', 'public-read-write' and
|
`$ACL` -- hex encoded basic ACL value or keywords 'private, 'public-read', 'public-read-write' and
|
||||||
|
@ -259,7 +259,7 @@ the file `wallets/wallet.key`.
|
||||||
|
|
||||||
To create a file via [frostfs-cli](https://github.com/TrueCloudLab/frostfs-node/releases), run a command below:
|
To create a file via [frostfs-cli](https://github.com/TrueCloudLab/frostfs-node/releases), run a command below:
|
||||||
```
|
```
|
||||||
$ frostfs-cli -r $NEOFS_NODE -k $KEY object put --file $FILENAME --cid $CID
|
$ frostfs-cli -r $FROSTFS_NODE -k $KEY object put --file $FILENAME --cid $CID
|
||||||
```
|
```
|
||||||
where
|
where
|
||||||
`$KEY` -- the key, please read the information [above](#create-a-container),
|
`$KEY` -- the key, please read the information [above](#create-a-container),
|
||||||
|
|
8
app.go
8
app.go
|
@ -123,9 +123,9 @@ func newApp(ctx context.Context, opt ...Option) App {
|
||||||
a.webServer.DisablePreParseMultipartForm = true
|
a.webServer.DisablePreParseMultipartForm = true
|
||||||
a.webServer.StreamRequestBody = a.cfg.GetBool(cfgWebStreamRequestBody)
|
a.webServer.StreamRequestBody = a.cfg.GetBool(cfgWebStreamRequestBody)
|
||||||
// -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
// -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||||
key, err = getNeoFSKey(a)
|
key, err = getFrostFSKey(a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.log.Fatal("failed to get neofs credentials", zap.Error(err))
|
a.log.Fatal("failed to get frostfs credentials", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
var owner user.ID
|
var owner user.ID
|
||||||
|
@ -194,7 +194,7 @@ func (a *app) initResolver() {
|
||||||
|
|
||||||
func (a *app) getResolverConfig() ([]string, *resolver.Config) {
|
func (a *app) getResolverConfig() ([]string, *resolver.Config) {
|
||||||
resolveCfg := &resolver.Config{
|
resolveCfg := &resolver.Config{
|
||||||
NeoFS: resolver.NewNeoFSResolver(a.pool),
|
FrostFS: resolver.NewFrostFSResolver(a.pool),
|
||||||
RPCAddress: a.cfg.GetString(cfgRPCEndpoint),
|
RPCAddress: a.cfg.GetString(cfgRPCEndpoint),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ func remove(list []string, element string) []string {
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNeoFSKey(a *app) (*ecdsa.PrivateKey, error) {
|
func getFrostFSKey(a *app) (*ecdsa.PrivateKey, error) {
|
||||||
walletPath := a.cfg.GetString(cfgWalletPath)
|
walletPath := a.cfg.GetString(cfgWalletPath)
|
||||||
|
|
||||||
if len(walletPath) == 0 {
|
if len(walletPath) == 0 {
|
||||||
|
|
|
@ -27,13 +27,13 @@ HTTP_GW_SERVER_1_TLS_CERT_FILE=/path/to/tls/cert
|
||||||
HTTP_GW_SERVER_1_TLS_KEY_FILE=/path/to/tls/key
|
HTTP_GW_SERVER_1_TLS_KEY_FILE=/path/to/tls/key
|
||||||
|
|
||||||
# Nodes configuration.
|
# Nodes configuration.
|
||||||
# This configuration make the gateway use the first node (grpc://s01.neofs.devenv:8080)
|
# This configuration make the gateway use the first node (grpc://s01.frostfs.devenv:8080)
|
||||||
# while it's healthy. Otherwise, the gateway use the second node (grpc://s01.neofs.devenv:8080)
|
# while it's healthy. Otherwise, the gateway use the second node (grpc://s01.frostfs.devenv:8080)
|
||||||
# for 10% of requests and the third node for 90% of requests.
|
# for 10% of requests and the third node for 90% of requests.
|
||||||
|
|
||||||
# Peer 1.
|
# Peer 1.
|
||||||
# Endpoint.
|
# Endpoint.
|
||||||
HTTP_GW_PEERS_0_ADDRESS=grpc://s01.neofs.devenv:8080
|
HTTP_GW_PEERS_0_ADDRESS=grpc://s01.frostfs.devenv:8080
|
||||||
# Until nodes with the same priority level are healthy
|
# Until nodes with the same priority level are healthy
|
||||||
# nodes with other priority are not used.
|
# nodes with other priority are not used.
|
||||||
# The lower the value, the higher the priority.
|
# The lower the value, the higher the priority.
|
||||||
|
@ -41,11 +41,11 @@ HTTP_GW_PEERS_0_PRIORITY=1
|
||||||
# Load distribution proportion for nodes with the same priority.
|
# Load distribution proportion for nodes with the same priority.
|
||||||
HTTP_GW_PEERS_0_WEIGHT=1
|
HTTP_GW_PEERS_0_WEIGHT=1
|
||||||
# Peer 2.
|
# Peer 2.
|
||||||
HTTP_GW_PEERS_1_ADDRESS=grpc://s02.neofs.devenv:8080
|
HTTP_GW_PEERS_1_ADDRESS=grpc://s02.frostfs.devenv:8080
|
||||||
HTTP_GW_PEERS_1_PRIORITY=2
|
HTTP_GW_PEERS_1_PRIORITY=2
|
||||||
HTTP_GW_PEERS_1_WEIGHT=1
|
HTTP_GW_PEERS_1_WEIGHT=1
|
||||||
# Peer 3.
|
# Peer 3.
|
||||||
HTTP_GW_PEERS_2_ADDRESS=grpc://s03.neofs.devenv:8080
|
HTTP_GW_PEERS_2_ADDRESS=grpc://s03.frostfs.devenv:8080
|
||||||
HTTP_GW_PEERS_2_PRIORITY=2
|
HTTP_GW_PEERS_2_PRIORITY=2
|
||||||
HTTP_GW_PEERS_2_WEIGHT=9
|
HTTP_GW_PEERS_2_WEIGHT=9
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ HTTP_GW_STREAM_REQUEST_BODY=true
|
||||||
HTTP_GW_MAX_REQUEST_BODY_SIZE=4194304
|
HTTP_GW_MAX_REQUEST_BODY_SIZE=4194304
|
||||||
|
|
||||||
# RPC endpoint to be able to use nns container resolving.
|
# RPC endpoint to be able to use nns container resolving.
|
||||||
HTTP_GW_RPC_ENDPOINT=http://morph-chain.neofs.devenv:30333
|
HTTP_GW_RPC_ENDPOINT=http://morph-chain.frostfs.devenv:30333
|
||||||
# The order in which resolvers are used to find an container id by name.
|
# The order in which resolvers are used to find an container id by name.
|
||||||
HTTP_GW_RESOLVE_ORDER="nns dns"
|
HTTP_GW_RESOLVE_ORDER="nns dns"
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,13 @@ server:
|
||||||
key_file: /path/to/key
|
key_file: /path/to/key
|
||||||
|
|
||||||
# Nodes configuration.
|
# Nodes configuration.
|
||||||
# This configuration make the gateway use the first node (grpc://s01.neofs.devenv:8080)
|
# This configuration make the gateway use the first node (grpc://s01.frostfs.devenv:8080)
|
||||||
# while it's healthy. Otherwise, the gateway use the second node (grpc://s01.neofs.devenv:8080)
|
# while it's healthy. Otherwise, the gateway use the second node (grpc://s01.frostfs.devenv:8080)
|
||||||
# for 10% of requests and the third node for 90% of requests.
|
# for 10% of requests and the third node for 90% of requests.
|
||||||
peers:
|
peers:
|
||||||
0:
|
0:
|
||||||
# Endpoint.
|
# Endpoint.
|
||||||
address: grpc://s01.neofs.devenv:8080
|
address: grpc://s01.frostfs.devenv:8080
|
||||||
|
|
||||||
# Until nodes with the same priority level are healthy
|
# Until nodes with the same priority level are healthy
|
||||||
# nodes with other priority are not used.
|
# nodes with other priority are not used.
|
||||||
|
@ -42,11 +42,11 @@ peers:
|
||||||
# Load distribution proportion for nodes with the same priority.
|
# Load distribution proportion for nodes with the same priority.
|
||||||
weight: 1
|
weight: 1
|
||||||
1:
|
1:
|
||||||
address: grpc://s02.neofs.devenv:8080
|
address: grpc://s02.frostfs.devenv:8080
|
||||||
priority: 2
|
priority: 2
|
||||||
weight: 1
|
weight: 1
|
||||||
2:
|
2:
|
||||||
address: grpc://s03.neofs.devenv:8080
|
address: grpc://s03.frostfs.devenv:8080
|
||||||
priority: 2
|
priority: 2
|
||||||
weight: 9
|
weight: 9
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ web:
|
||||||
max_request_body_size: 4194304
|
max_request_body_size: 4194304
|
||||||
|
|
||||||
# RPC endpoint to be able to use nns container resolving.
|
# RPC endpoint to be able to use nns container resolving.
|
||||||
rpc_endpoint: http://morph-chain.neofs.devenv:30333
|
rpc_endpoint: http://morph-chain.frostfs.devenv:30333
|
||||||
# The order in which resolvers are used to find an container id by name.
|
# The order in which resolvers are used to find an container id by name.
|
||||||
resolve_order:
|
resolve_order:
|
||||||
- nns
|
- nns
|
||||||
|
|
|
@ -57,7 +57,7 @@ $ cat http.log
|
||||||
# General section
|
# General section
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
rpc_endpoint: http://morph-chain.neofs.devenv:30333
|
rpc_endpoint: http://morph-chain.frostfs.devenv:30333
|
||||||
resolve_order:
|
resolve_order:
|
||||||
- nns
|
- nns
|
||||||
- dns
|
- dns
|
||||||
|
@ -98,23 +98,23 @@ wallet:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Nodes configuration
|
# Nodes configuration
|
||||||
# This configuration makes the gateway use the first node (node1.neofs:8080)
|
# This configuration makes the gateway use the first node (node1.frostfs:8080)
|
||||||
# while it's healthy. Otherwise, gateway uses the second node (node2.neofs:8080)
|
# while it's healthy. Otherwise, gateway uses the second node (node2.frostfs:8080)
|
||||||
# for 10% of requests and the third node (node3.neofs:8080) for 90% of requests.
|
# for 10% of requests and the third node (node3.frostfs:8080) for 90% of requests.
|
||||||
# Until nodes with the same priority level are healthy
|
# Until nodes with the same priority level are healthy
|
||||||
# nodes with other priority are not used.
|
# nodes with other priority are not used.
|
||||||
# The lower the value, the higher the priority.
|
# The lower the value, the higher the priority.
|
||||||
peers:
|
peers:
|
||||||
0:
|
0:
|
||||||
address: node1.neofs:8080
|
address: node1.frostfs:8080
|
||||||
priority: 1
|
priority: 1
|
||||||
weight: 1
|
weight: 1
|
||||||
1:
|
1:
|
||||||
address: node2.neofs:8080
|
address: node2.frostfs:8080
|
||||||
priority: 2
|
priority: 2
|
||||||
weight: 0.1
|
weight: 0.1
|
||||||
2:
|
2:
|
||||||
address: node3.neofs:8080
|
address: node3.frostfs:8080
|
||||||
priority: 2
|
priority: 2
|
||||||
weight: 0.9
|
weight: 0.9
|
||||||
```
|
```
|
||||||
|
|
|
@ -111,7 +111,7 @@ func (r request) receiveFile(clnt *pool.Pool, objectAddress oid.Address) {
|
||||||
|
|
||||||
rObj, err := clnt.GetObject(r.appCtx, prm)
|
rObj, err := clnt.GetObject(r.appCtx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.handleNeoFSErr(err, start)
|
r.handleFrostFSErr(err, start)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ func bearerToken(ctx context.Context) *bearer.Token {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *request) handleNeoFSErr(err error, start time.Time) {
|
func (r *request) handleFrostFSErr(err error, start time.Time) {
|
||||||
r.log.Error(
|
r.log.Error(
|
||||||
"could not receive object",
|
"could not receive object",
|
||||||
zap.Stringer("elapsed", time.Since(start)),
|
zap.Stringer("elapsed", time.Since(start)),
|
||||||
|
@ -500,7 +500,7 @@ func (d *Downloader) zipObject(zipWriter *zip.Writer, addr oid.Address, btoken *
|
||||||
|
|
||||||
resGet, err := d.pool.GetObject(d.appCtx, prm)
|
resGet, err := d.pool.GetObject(d.appCtx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get NeoFS object: %v", err)
|
return fmt.Errorf("get FrostFS object: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
objWriter, err := d.addObjectToZip(zipWriter, &resGet.Header)
|
objWriter, err := d.addObjectToZip(zipWriter, &resGet.Header)
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (r request) headObject(clnt *pool.Pool, objectAddress oid.Address) {
|
||||||
|
|
||||||
obj, err := clnt.HeadObject(r.appCtx, prm)
|
obj, err := clnt.HeadObject(r.appCtx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.handleNeoFSErr(err, start)
|
r.handleFrostFSErr(err, start)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ func (r request) headObject(clnt *pool.Pool, objectAddress oid.Address) {
|
||||||
return &resObj, nil
|
return &resObj, nil
|
||||||
})
|
})
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
r.handleNeoFSErr(err, start)
|
r.handleFrostFSErr(err, start)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
namespace = "neofs_http_gw"
|
namespace = "frostfs_http_gw"
|
||||||
stateSubsystem = "state"
|
stateSubsystem = "state"
|
||||||
poolSubsystem = "pool"
|
poolSubsystem = "pool"
|
||||||
|
|
||||||
|
|
35
resolver/frostfs.go
Normal file
35
resolver/frostfs.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package resolver
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/TrueCloudLab/frostfs-sdk-go/pool"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FrostFSResolver represents virtual connection to the FrostFS network.
|
||||||
|
// It implements resolver.FrostFS.
|
||||||
|
type FrostFSResolver struct {
|
||||||
|
pool *pool.Pool
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewFrostFSResolver creates new FrostFSResolver using provided pool.Pool.
|
||||||
|
func NewFrostFSResolver(p *pool.Pool) *FrostFSResolver {
|
||||||
|
return &FrostFSResolver{pool: p}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SystemDNS implements resolver.FrostFS interface method.
|
||||||
|
func (x *FrostFSResolver) SystemDNS(ctx context.Context) (string, error) {
|
||||||
|
networkInfo, err := x.pool.NetworkInfo(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("read network info via client: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
domain := networkInfo.RawNetworkParameter("SystemDNS")
|
||||||
|
if domain == nil {
|
||||||
|
return "", errors.New("system DNS parameter not found or empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(domain), nil
|
||||||
|
}
|
|
@ -1,35 +0,0 @@
|
||||||
package resolver
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/pool"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NeoFSResolver represents virtual connection to the NeoFS network.
|
|
||||||
// It implements resolver.NeoFS.
|
|
||||||
type NeoFSResolver struct {
|
|
||||||
pool *pool.Pool
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewNeoFSResolver creates new NeoFSResolver using provided pool.Pool.
|
|
||||||
func NewNeoFSResolver(p *pool.Pool) *NeoFSResolver {
|
|
||||||
return &NeoFSResolver{pool: p}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SystemDNS implements resolver.NeoFS interface method.
|
|
||||||
func (x *NeoFSResolver) SystemDNS(ctx context.Context) (string, error) {
|
|
||||||
networkInfo, err := x.pool.NetworkInfo(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("read network info via client: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
domain := networkInfo.RawNetworkParameter("SystemDNS")
|
|
||||||
if domain == nil {
|
|
||||||
return "", errors.New("system DNS parameter not found or empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(domain), nil
|
|
||||||
}
|
|
|
@ -19,9 +19,9 @@ const (
|
||||||
// ErrNoResolvers returns when trying to resolve container without any resolver.
|
// ErrNoResolvers returns when trying to resolve container without any resolver.
|
||||||
var ErrNoResolvers = errors.New("no resolvers")
|
var ErrNoResolvers = errors.New("no resolvers")
|
||||||
|
|
||||||
// NeoFS represents virtual connection to the NeoFS network.
|
// FrostFS represents virtual connection to the FrostFS network.
|
||||||
type NeoFS interface {
|
type FrostFS interface {
|
||||||
// SystemDNS reads system DNS network parameters of the NeoFS.
|
// SystemDNS reads system DNS network parameters of the FrostFS.
|
||||||
//
|
//
|
||||||
// Returns exactly on non-zero value. Returns any error encountered
|
// Returns exactly on non-zero value. Returns any error encountered
|
||||||
// which prevented the parameter to be read.
|
// which prevented the parameter to be read.
|
||||||
|
@ -29,7 +29,7 @@ type NeoFS interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
NeoFS NeoFS
|
FrostFS FrostFS
|
||||||
RPCAddress string
|
RPCAddress string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ func (r *ContainerResolver) equals(resolverNames []string) bool {
|
||||||
func newResolver(name string, cfg *Config) (*Resolver, error) {
|
func newResolver(name string, cfg *Config) (*Resolver, error) {
|
||||||
switch name {
|
switch name {
|
||||||
case DNSResolver:
|
case DNSResolver:
|
||||||
return NewDNSResolver(cfg.NeoFS)
|
return NewDNSResolver(cfg.FrostFS)
|
||||||
case NNSResolver:
|
case NNSResolver:
|
||||||
return NewNNSResolver(cfg.RPCAddress)
|
return NewNNSResolver(cfg.RPCAddress)
|
||||||
default:
|
default:
|
||||||
|
@ -143,17 +143,17 @@ func newResolver(name string, cfg *Config) (*Resolver, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDNSResolver(neoFS NeoFS) (*Resolver, error) {
|
func NewDNSResolver(frostFS FrostFS) (*Resolver, error) {
|
||||||
if neoFS == nil {
|
if frostFS == nil {
|
||||||
return nil, fmt.Errorf("pool must not be nil for DNS resolver")
|
return nil, fmt.Errorf("pool must not be nil for DNS resolver")
|
||||||
}
|
}
|
||||||
|
|
||||||
var dns ns.DNS
|
var dns ns.DNS
|
||||||
|
|
||||||
resolveFunc := func(ctx context.Context, name string) (*cid.ID, error) {
|
resolveFunc := func(ctx context.Context, name string) (*cid.ID, error) {
|
||||||
domain, err := neoFS.SystemDNS(ctx)
|
domain, err := frostFS.SystemDNS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("read system DNS parameter of the NeoFS: %w", err)
|
return nil, fmt.Errorf("read system DNS parameter of the FrostFS: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
domain = name + "." + domain
|
domain = name + "." + domain
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
var neofsAttributeHeaderPrefixes = [...][]byte{[]byte("Neofs-"), []byte("NEOFS-"), []byte("neofs-")}
|
var frostfsAttributeHeaderPrefixes = [...][]byte{[]byte("Neofs-"), []byte("NEOFS-"), []byte("neofs-")}
|
||||||
|
|
||||||
func systemTranslator(key, prefix []byte) []byte {
|
func systemTranslator(key, prefix []byte) []byte {
|
||||||
// replace the specified prefix with `__NEOFS__`
|
// replace the specified prefix with `__NEOFS__`
|
||||||
|
@ -46,7 +46,7 @@ func filterHeaders(l *zap.Logger, header *fasthttp.RequestHeader) (map[string]st
|
||||||
clearKey := bytes.TrimPrefix(key, prefix)
|
clearKey := bytes.TrimPrefix(key, prefix)
|
||||||
|
|
||||||
// checks that it's a system NeoFS header
|
// checks that it's a system NeoFS header
|
||||||
for _, system := range neofsAttributeHeaderPrefixes {
|
for _, system := range frostfsAttributeHeaderPrefixes {
|
||||||
if bytes.HasPrefix(clearKey, system) {
|
if bytes.HasPrefix(clearKey, system) {
|
||||||
clearKey = systemTranslator(clearKey, system)
|
clearKey = systemTranslator(clearKey, system)
|
||||||
break
|
break
|
||||||
|
|
|
@ -182,8 +182,8 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if idObj, err = u.pool.PutObject(u.appCtx, prm); err != nil {
|
if idObj, err = u.pool.PutObject(u.appCtx, prm); err != nil {
|
||||||
log.Error("could not store file in neofs", zap.Error(err))
|
log.Error("could not store file in frostfs", zap.Error(err))
|
||||||
response.Error(c, "could not store file in neofs: "+err.Error(), fasthttp.StatusBadRequest)
|
response.Error(c, "could not store file in frostfs: "+err.Error(), fasthttp.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue