storj/examples/grpc-debug/main.go
Alexander Leitner bfde515391
Clean up Storage node setup (#1013)
* Edit config on Setup

* Default to 1TiB storage space and 500GiB bandwidth

* Use human readable formats

* Use memory

* units of 1024 are measured with KiB/MiB etc

* pkg/cfgstruct: allow values to be configured with human readable sizes

Change-Id: Ic4e9ae461516d1d26fb81f6e44c5ac5cfccf777f

* Modify tests

* Removed comments

* More merge conflict stuff resolved

* Fix lint

* test fixin

Change-Id: I3a008206bf03a4446da19f642a2f9c1f9acaae36

* Remove commented code but secretly leave it in the histroy forever

* Move flag definition to struct
2019-01-14 16:19:15 -05:00

54 lines
1.1 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"context"
"fmt"
"github.com/spf13/pflag"
"google.golang.org/grpc"
"storj.io/storj/pkg/cfgstruct"
"storj.io/storj/pkg/provider"
"storj.io/storj/pkg/storj"
)
var (
targetAddr = pflag.String("target", "satellite.staging.storj.io:7777", "address of target")
identityConfig provider.IdentityConfig
)
func init() {
cfgstruct.Bind(pflag.CommandLine, &identityConfig, cfgstruct.ConfDir("$HOME/.storj/gw"))
}
func main() {
ctx := context.Background()
pflag.Parse()
identity, err := identityConfig.Load()
if err != nil {
panic(err)
}
dialOption, err := identity.DialOption(storj.NodeID{})
if err != nil {
panic(err)
}
conn, err := grpc.Dial(*targetAddr, dialOption)
if err != nil {
panic(err)
}
fmt.Println(conn.GetState())
err = conn.Invoke(ctx, "NonExistentMethod", nil, nil)
if err != nil && err.Error() != `rpc error: code = ResourceExhausted desc = malformed method name: "NonExistentMethod"` {
fmt.Println(err)
}
fmt.Println(conn.GetState())
err = conn.Close()
if err != nil {
fmt.Println(err)
}
}