mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge pull request #1462 from codysoyland/dead-code-removal
Remove some dead code
This commit is contained in:
commit
785bcde7d0
9 changed files with 18 additions and 96 deletions
|
|
@ -146,7 +146,7 @@ func WithLogger(logger *log.Logger) GossipMemberSetOption {
|
|||
|
||||
// NewGossipMemberSet returns a new instance of GossipMemberSet based on options.
|
||||
func NewGossipMemberSet(cfg Config, api *pilosa.API, options ...GossipMemberSetOption) (*GossipMemberSet, error) {
|
||||
host := api.Node().URI.GetHost()
|
||||
host := api.Node().URI.Host
|
||||
g := &GossipMemberSet{
|
||||
papi: api,
|
||||
Logger: pilosa.NopLogger,
|
||||
|
|
@ -191,10 +191,10 @@ func NewGossipMemberSet(cfg Config, api *pilosa.API, options ...GossipMemberSetO
|
|||
conf := memberlist.DefaultWANConfig()
|
||||
conf.Transport = g.transport.Net
|
||||
conf.Name = api.Node().ID
|
||||
conf.BindAddr = api.Node().URI.GetHost()
|
||||
conf.BindAddr = api.Node().URI.Host
|
||||
conf.BindPort = port
|
||||
conf.AdvertisePort = port
|
||||
conf.AdvertiseAddr = hostToIP(api.Node().URI.GetHost())
|
||||
conf.AdvertiseAddr = hostToIP(api.Node().URI.Host)
|
||||
//
|
||||
conf.TCPTimeout = time.Duration(cfg.StreamTimeout)
|
||||
conf.SuspicionMult = cfg.SuspicionMult
|
||||
|
|
|
|||
|
|
@ -27,18 +27,11 @@ import (
|
|||
"sort"
|
||||
"strconv"
|
||||
|
||||
"crypto/tls"
|
||||
|
||||
"github.com/pilosa/pilosa"
|
||||
"github.com/pilosa/pilosa/encoding/proto"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ClientOptions represents the configuration for a InternalHTTPClient
|
||||
type ClientOptions struct {
|
||||
TLS *tls.Config
|
||||
}
|
||||
|
||||
// InternalClient represents a client to the Pilosa cluster.
|
||||
type InternalClient struct {
|
||||
defaultURI *pilosa.URI
|
||||
|
|
@ -71,9 +64,6 @@ func NewInternalClientFromURI(defaultURI *pilosa.URI, remoteClient *http.Client)
|
|||
}
|
||||
}
|
||||
|
||||
// Host returns the host the client was initialized with.
|
||||
func (c *InternalClient) Host() *pilosa.URI { return c.defaultURI }
|
||||
|
||||
// MaxShardByIndex returns the number of shards on a server by index.
|
||||
func (c *InternalClient) MaxShardByIndex(ctx context.Context) (map[string]uint64, error) {
|
||||
return c.maxShardByIndex(ctx)
|
||||
|
|
@ -993,7 +983,7 @@ func pos(rowID, columnID uint64) uint64 {
|
|||
|
||||
func uriPathToURL(uri *pilosa.URI, path string) url.URL {
|
||||
return url.URL{
|
||||
Scheme: uri.GetScheme(),
|
||||
Scheme: uri.Scheme,
|
||||
Host: uri.HostPort(),
|
||||
Path: path,
|
||||
}
|
||||
|
|
@ -1001,7 +991,7 @@ func uriPathToURL(uri *pilosa.URI, path string) url.URL {
|
|||
|
||||
func nodePathToURL(node *pilosa.Node, path string) url.URL {
|
||||
return url.URL{
|
||||
Scheme: node.URI.GetScheme(),
|
||||
Scheme: node.URI.Scheme,
|
||||
Host: node.URI.HostPort(),
|
||||
Path: path,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1276,10 +1276,6 @@ func (h *Handler) handlePostClusterMessage(w http.ResponseWriter, r *http.Reques
|
|||
}
|
||||
}
|
||||
|
||||
func (h *Handler) GetAPI() *pilosa.API {
|
||||
return h.API
|
||||
}
|
||||
|
||||
type defaultClusterMessageResponse struct{}
|
||||
|
||||
func (h *Handler) handleGetTranslateData(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
33
pql/ast.go
33
pql/ast.go
|
|
@ -220,23 +220,6 @@ func (q *Query) WriteCallN() int {
|
|||
return n
|
||||
}
|
||||
|
||||
// HasKeys returns true if any call in the query uses keys and requires translation to ids.
|
||||
func (q *Query) HasKeys() bool {
|
||||
for _, call := range q.Calls {
|
||||
if call.Args["col"] != nil {
|
||||
if _, ok := call.Args["col"].(string); ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if call.Args["row"] != nil {
|
||||
if _, ok := call.Args["row"].(string); ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// String returns a string representation of the query.
|
||||
func (q *Query) String() string {
|
||||
a := make([]string, len(q.Calls))
|
||||
|
|
@ -329,22 +312,6 @@ func (c *Call) UintSliceArg(key string) ([]uint64, bool, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// StringArg is for reading the value at key from call.Args as a string. If the
|
||||
// key is not in Call.Args, the value of the returned bool will be false, and
|
||||
// the error will be nil. An error is returned if the value is not a string.
|
||||
func (c *Call) StringArg(key string) (string, bool, error) {
|
||||
val, ok := c.Args[key]
|
||||
if !ok {
|
||||
return "", false, nil
|
||||
}
|
||||
switch tval := val.(type) {
|
||||
case string:
|
||||
return tval, true, nil
|
||||
default:
|
||||
return "", true, fmt.Errorf("could not convert %v of type %T to string in Call.StringArg", tval, tval)
|
||||
}
|
||||
}
|
||||
|
||||
// Keys returns a list of argument keys in sorted order.
|
||||
func (c *Call) Keys() []string {
|
||||
a := make([]string, 0, len(c.Args))
|
||||
|
|
|
|||
|
|
@ -21,13 +21,6 @@ import (
|
|||
"github.com/pilosa/pilosa/toml"
|
||||
)
|
||||
|
||||
// Cluster types.
|
||||
const (
|
||||
ClusterNone = ""
|
||||
ClusterStatic = "static"
|
||||
ClusterGossip = "gossip"
|
||||
)
|
||||
|
||||
// TLSConfig contains TLS configuration
|
||||
type TLSConfig struct {
|
||||
// CertificatePath contains the path to the certificate (.crt or .pem file)
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ func (m *Command) SetupServer() error {
|
|||
|
||||
// Setup TLS
|
||||
var TLSConfig *tls.Config
|
||||
if uri.GetScheme() == "https" {
|
||||
if uri.Scheme == "https" {
|
||||
if m.Config.TLS.CertificatePath == "" {
|
||||
return errors.New("certificate path is required for TLS sockets")
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ func (m *Command) SetupServer() error {
|
|||
}
|
||||
|
||||
// If port is 0, get auto-allocated port from listener
|
||||
if uri.GetPort() == 0 {
|
||||
if uri.Port == 0 {
|
||||
uri.SetPort(uint16(m.ln.Addr().(*net.TCPAddr).Port))
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ func (m *Command) SetupNetworking() error {
|
|||
}
|
||||
|
||||
// get the host portion of addr to use for binding
|
||||
gossipHost := m.API.Node().URI.GetHost()
|
||||
gossipHost := m.API.Node().URI.Host
|
||||
m.gossipTransport, err = gossip.NewTransport(gossipHost, gossipPort, m.logger.Logger())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting transport")
|
||||
|
|
@ -368,19 +368,19 @@ func NewStatsClient(name string, host string) (pilosa.StatsClient, error) {
|
|||
// getListener gets a net.Listener based on the config.
|
||||
func getListener(uri pilosa.URI, tlsconf *tls.Config) (ln net.Listener, err error) {
|
||||
// If bind URI has the https scheme, enable TLS
|
||||
if uri.GetScheme() == "https" && tlsconf != nil {
|
||||
if uri.Scheme == "https" && tlsconf != nil {
|
||||
ln, err = tls.Listen("tcp", uri.HostPort(), tlsconf)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "tls.Listener")
|
||||
}
|
||||
} else if uri.GetScheme() == "http" {
|
||||
} else if uri.Scheme == "http" {
|
||||
// Open HTTP listener to determine port (if specified as :0).
|
||||
ln, err = net.Listen("tcp", uri.HostPort())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "net.Listen")
|
||||
}
|
||||
} else {
|
||||
return nil, errors.Errorf("unsupported scheme: %s", uri.GetScheme())
|
||||
return nil, errors.Errorf("unsupported scheme: %s", uri.Scheme)
|
||||
}
|
||||
|
||||
return ln, nil
|
||||
|
|
|
|||
|
|
@ -81,15 +81,6 @@ func (h *Holder) MustCreateIndexIfNotExists(index string, opt pilosa.IndexOption
|
|||
return &Index{Index: idx}
|
||||
}
|
||||
|
||||
// MustCreateFieldIfNotExists returns a given field. Panic on error.
|
||||
func (h *Holder) MustCreateFieldIfNotExists(index, field string) *Field {
|
||||
f, err := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{}).CreateFieldIfNotExists(field, pilosa.OptFieldTypeDefault())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
// Row returns a Row for a given field.
|
||||
func (h *Holder) Row(index, field string, rowID uint64) *pilosa.Row {
|
||||
idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{})
|
||||
|
|
|
|||
15
uri.go
15
uri.go
|
|
@ -82,11 +82,6 @@ func NewURIFromAddress(address string) (*URI, error) {
|
|||
return parseAddress(address)
|
||||
}
|
||||
|
||||
// GetScheme returns the scheme of this URI.
|
||||
func (u *URI) GetScheme() string {
|
||||
return u.Scheme
|
||||
}
|
||||
|
||||
// SetScheme sets the scheme of this URI.
|
||||
func (u *URI) SetScheme(scheme string) error {
|
||||
m := schemeRegexp.FindStringSubmatch(scheme)
|
||||
|
|
@ -97,11 +92,6 @@ func (u *URI) SetScheme(scheme string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetHost returns the host of this URI.
|
||||
func (u *URI) GetHost() string {
|
||||
return u.Host
|
||||
}
|
||||
|
||||
// SetHost sets the host of this URI.
|
||||
func (u *URI) SetHost(host string) error {
|
||||
m := hostRegexp.FindStringSubmatch(host)
|
||||
|
|
@ -112,11 +102,6 @@ func (u *URI) SetHost(host string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetPort returns the port of this URI.
|
||||
func (u *URI) GetPort() uint16 {
|
||||
return u.Port
|
||||
}
|
||||
|
||||
// SetPort sets the port of this URI.
|
||||
func (u *URI) SetPort(port uint16) {
|
||||
u.Port = port
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ func TestSetScheme(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if uri.GetScheme() != target {
|
||||
t.Fatalf("%s != %s", uri.GetScheme(), target)
|
||||
if uri.Scheme != target {
|
||||
t.Fatalf("%s != %s", uri.Scheme, target)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ func TestSetHost(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if uri.GetHost() != target {
|
||||
if uri.Host != target {
|
||||
t.Fatalf("%s != %s", uri.Host, target)
|
||||
}
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ func TestSetPort(t *testing.T) {
|
|||
uri := DefaultURI()
|
||||
target := uint16(9999)
|
||||
uri.SetPort(target)
|
||||
if uri.GetPort() != target {
|
||||
if uri.Port != target {
|
||||
t.Fatalf("%d != %d", uri.Port, target)
|
||||
}
|
||||
}
|
||||
|
|
@ -137,13 +137,13 @@ func TestHostPort(t *testing.T) {
|
|||
}
|
||||
|
||||
func compare(t *testing.T, uri *URI, scheme string, host string, port uint16) {
|
||||
if uri.GetScheme() != scheme {
|
||||
if uri.Scheme != scheme {
|
||||
t.Fatalf("Scheme does not match: %s != %s", uri.Scheme, scheme)
|
||||
}
|
||||
if uri.GetHost() != host {
|
||||
if uri.Host != host {
|
||||
t.Fatalf("Host does not match: %s != %s", uri.Host, host)
|
||||
}
|
||||
if uri.GetPort() != port {
|
||||
if uri.Port != port {
|
||||
t.Fatalf("Port does not match: %d != %d", uri.Port, port)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue