repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
libp2p/go-libp2p-kad-dht
providers/providers.go
GetProviders
func (pm *ProviderManager) GetProviders(ctx context.Context, k cid.Cid) []peer.ID { gp := &getProv{ k: k, resp: make(chan []peer.ID, 1), // buffered to prevent sender from blocking } select { case <-ctx.Done(): return nil case pm.getprovs <- gp: } select { case <-ctx.Done(): return nil case peers := <-gp.resp: return peers } }
go
func (pm *ProviderManager) GetProviders(ctx context.Context, k cid.Cid) []peer.ID { gp := &getProv{ k: k, resp: make(chan []peer.ID, 1), // buffered to prevent sender from blocking } select { case <-ctx.Done(): return nil case pm.getprovs <- gp: } select { case <-ctx.Done(): return nil case peers := <-gp.resp: return peers } }
[ "func", "(", "pm", "*", "ProviderManager", ")", "GetProviders", "(", "ctx", "context", ".", "Context", ",", "k", "cid", ".", "Cid", ")", "[", "]", "peer", ".", "ID", "{", "gp", ":=", "&", "getProv", "{", "k", ":", "k", ",", "resp", ":", "make", ...
// GetProviders returns the set of providers for the given key. // This method _does not_ copy the set. Do not modify it.
[ "GetProviders", "returns", "the", "set", "of", "providers", "for", "the", "given", "key", ".", "This", "method", "_does", "not_", "copy", "the", "set", ".", "Do", "not", "modify", "it", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/providers/providers.go#L315-L331
train
libp2p/go-libp2p-kad-dht
dht.go
New
func New(ctx context.Context, h host.Host, options ...opts.Option) (*IpfsDHT, error) { var cfg opts.Options if err := cfg.Apply(append([]opts.Option{opts.Defaults}, options...)...); err != nil { return nil, err } dht := makeDHT(ctx, h, cfg.Datastore, cfg.Protocols) // register for network notifs. dht.host.Network().Notify((*netNotifiee)(dht)) dht.proc = goprocessctx.WithContextAndTeardown(ctx, func() error { // remove ourselves from network notifs. dht.host.Network().StopNotify((*netNotifiee)(dht)) return nil }) dht.proc.AddChild(dht.providers.Process()) dht.Validator = cfg.Validator if !cfg.Client { for _, p := range cfg.Protocols { h.SetStreamHandler(p, dht.handleNewStream) } } return dht, nil }
go
func New(ctx context.Context, h host.Host, options ...opts.Option) (*IpfsDHT, error) { var cfg opts.Options if err := cfg.Apply(append([]opts.Option{opts.Defaults}, options...)...); err != nil { return nil, err } dht := makeDHT(ctx, h, cfg.Datastore, cfg.Protocols) // register for network notifs. dht.host.Network().Notify((*netNotifiee)(dht)) dht.proc = goprocessctx.WithContextAndTeardown(ctx, func() error { // remove ourselves from network notifs. dht.host.Network().StopNotify((*netNotifiee)(dht)) return nil }) dht.proc.AddChild(dht.providers.Process()) dht.Validator = cfg.Validator if !cfg.Client { for _, p := range cfg.Protocols { h.SetStreamHandler(p, dht.handleNewStream) } } return dht, nil }
[ "func", "New", "(", "ctx", "context", ".", "Context", ",", "h", "host", ".", "Host", ",", "options", "...", "opts", ".", "Option", ")", "(", "*", "IpfsDHT", ",", "error", ")", "{", "var", "cfg", "opts", ".", "Options", "\n", "if", "err", ":=", "c...
// New creates a new DHT with the specified host and options.
[ "New", "creates", "a", "new", "DHT", "with", "the", "specified", "host", "and", "options", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L81-L106
train
libp2p/go-libp2p-kad-dht
dht.go
NewDHT
func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT { dht, err := New(ctx, h, opts.Datastore(dstore)) if err != nil { panic(err) } return dht }
go
func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT { dht, err := New(ctx, h, opts.Datastore(dstore)) if err != nil { panic(err) } return dht }
[ "func", "NewDHT", "(", "ctx", "context", ".", "Context", ",", "h", "host", ".", "Host", ",", "dstore", "ds", ".", "Batching", ")", "*", "IpfsDHT", "{", "dht", ",", "err", ":=", "New", "(", "ctx", ",", "h", ",", "opts", ".", "Datastore", "(", "dst...
// NewDHT creates a new DHT object with the given peer as the 'local' host. // IpfsDHT's initialized with this function will respond to DHT requests, // whereas IpfsDHT's initialized with NewDHTClient will not.
[ "NewDHT", "creates", "a", "new", "DHT", "object", "with", "the", "given", "peer", "as", "the", "local", "host", ".", "IpfsDHT", "s", "initialized", "with", "this", "function", "will", "respond", "to", "DHT", "requests", "whereas", "IpfsDHT", "s", "initialize...
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L111-L117
train
libp2p/go-libp2p-kad-dht
dht.go
getValueSingle
func (dht *IpfsDHT) getValueSingle(ctx context.Context, p peer.ID, key string) (*pb.Message, error) { meta := logging.LoggableMap{ "key": key, "peer": p, } eip := logger.EventBegin(ctx, "getValueSingle", meta) defer eip.Done() pmes := pb.NewMessage(pb.Message_GET_VALUE, []byte(key), 0) resp, err := dht.sendRequest(ctx, p, pmes) switch err { case nil: return resp, nil case ErrReadTimeout: logger.Warningf("getValueSingle: read timeout %s %s", p.Pretty(), key) fallthrough default: eip.SetError(err) return nil, err } }
go
func (dht *IpfsDHT) getValueSingle(ctx context.Context, p peer.ID, key string) (*pb.Message, error) { meta := logging.LoggableMap{ "key": key, "peer": p, } eip := logger.EventBegin(ctx, "getValueSingle", meta) defer eip.Done() pmes := pb.NewMessage(pb.Message_GET_VALUE, []byte(key), 0) resp, err := dht.sendRequest(ctx, p, pmes) switch err { case nil: return resp, nil case ErrReadTimeout: logger.Warningf("getValueSingle: read timeout %s %s", p.Pretty(), key) fallthrough default: eip.SetError(err) return nil, err } }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "getValueSingle", "(", "ctx", "context", ".", "Context", ",", "p", "peer", ".", "ID", ",", "key", "string", ")", "(", "*", "pb", ".", "Message", ",", "error", ")", "{", "meta", ":=", "logging", ".", "Loggabl...
// getValueSingle simply performs the get value RPC with the given parameters
[ "getValueSingle", "simply", "performs", "the", "get", "value", "RPC", "with", "the", "given", "parameters" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L220-L241
train
libp2p/go-libp2p-kad-dht
dht.go
getLocal
func (dht *IpfsDHT) getLocal(key string) (*recpb.Record, error) { logger.Debugf("getLocal %s", key) rec, err := dht.getRecordFromDatastore(mkDsKey(key)) if err != nil { logger.Warningf("getLocal: %s", err) return nil, err } // Double check the key. Can't hurt. if rec != nil && string(rec.GetKey()) != key { logger.Errorf("BUG getLocal: found a DHT record that didn't match it's key: %s != %s", rec.GetKey(), key) return nil, nil } return rec, nil }
go
func (dht *IpfsDHT) getLocal(key string) (*recpb.Record, error) { logger.Debugf("getLocal %s", key) rec, err := dht.getRecordFromDatastore(mkDsKey(key)) if err != nil { logger.Warningf("getLocal: %s", err) return nil, err } // Double check the key. Can't hurt. if rec != nil && string(rec.GetKey()) != key { logger.Errorf("BUG getLocal: found a DHT record that didn't match it's key: %s != %s", rec.GetKey(), key) return nil, nil } return rec, nil }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "getLocal", "(", "key", "string", ")", "(", "*", "recpb", ".", "Record", ",", "error", ")", "{", "logger", ".", "Debugf", "(", "\"getLocal %s\"", ",", "key", ")", "\n", "rec", ",", "err", ":=", "dht", ".", ...
// getLocal attempts to retrieve the value from the datastore
[ "getLocal", "attempts", "to", "retrieve", "the", "value", "from", "the", "datastore" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L244-L259
train
libp2p/go-libp2p-kad-dht
dht.go
putLocal
func (dht *IpfsDHT) putLocal(key string, rec *recpb.Record) error { logger.Debugf("putLocal: %v %v", key, rec) data, err := proto.Marshal(rec) if err != nil { logger.Warningf("putLocal: %s", err) return err } return dht.datastore.Put(mkDsKey(key), data) }
go
func (dht *IpfsDHT) putLocal(key string, rec *recpb.Record) error { logger.Debugf("putLocal: %v %v", key, rec) data, err := proto.Marshal(rec) if err != nil { logger.Warningf("putLocal: %s", err) return err } return dht.datastore.Put(mkDsKey(key), data) }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "putLocal", "(", "key", "string", ",", "rec", "*", "recpb", ".", "Record", ")", "error", "{", "logger", ".", "Debugf", "(", "\"putLocal: %v %v\"", ",", "key", ",", "rec", ")", "\n", "data", ",", "err", ":=", ...
// putLocal stores the key value pair in the datastore
[ "putLocal", "stores", "the", "key", "value", "pair", "in", "the", "datastore" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L262-L271
train
libp2p/go-libp2p-kad-dht
dht.go
Update
func (dht *IpfsDHT) Update(ctx context.Context, p peer.ID) { logger.Event(ctx, "updatePeer", p) dht.routingTable.Update(p) }
go
func (dht *IpfsDHT) Update(ctx context.Context, p peer.ID) { logger.Event(ctx, "updatePeer", p) dht.routingTable.Update(p) }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "Update", "(", "ctx", "context", ".", "Context", ",", "p", "peer", ".", "ID", ")", "{", "logger", ".", "Event", "(", "ctx", ",", "\"updatePeer\"", ",", "p", ")", "\n", "dht", ".", "routingTable", ".", "Updat...
// Update signals the routingTable to Update its last-seen status // on the given peer.
[ "Update", "signals", "the", "routingTable", "to", "Update", "its", "last", "-", "seen", "status", "on", "the", "given", "peer", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L275-L278
train
libp2p/go-libp2p-kad-dht
dht.go
FindLocal
func (dht *IpfsDHT) FindLocal(id peer.ID) pstore.PeerInfo { switch dht.host.Network().Connectedness(id) { case inet.Connected, inet.CanConnect: return dht.peerstore.PeerInfo(id) default: return pstore.PeerInfo{} } }
go
func (dht *IpfsDHT) FindLocal(id peer.ID) pstore.PeerInfo { switch dht.host.Network().Connectedness(id) { case inet.Connected, inet.CanConnect: return dht.peerstore.PeerInfo(id) default: return pstore.PeerInfo{} } }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "FindLocal", "(", "id", "peer", ".", "ID", ")", "pstore", ".", "PeerInfo", "{", "switch", "dht", ".", "host", ".", "Network", "(", ")", ".", "Connectedness", "(", "id", ")", "{", "case", "inet", ".", "Connec...
// FindLocal looks for a peer with a given ID connected to this dht and returns the peer and the table it was found in.
[ "FindLocal", "looks", "for", "a", "peer", "with", "a", "given", "ID", "connected", "to", "this", "dht", "and", "returns", "the", "peer", "and", "the", "table", "it", "was", "found", "in", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L281-L288
train
libp2p/go-libp2p-kad-dht
dht.go
findPeerSingle
func (dht *IpfsDHT) findPeerSingle(ctx context.Context, p peer.ID, id peer.ID) (*pb.Message, error) { eip := logger.EventBegin(ctx, "findPeerSingle", logging.LoggableMap{ "peer": p, "target": id, }) defer eip.Done() pmes := pb.NewMessage(pb.Message_FIND_NODE, []byte(id), 0) resp, err := dht.sendRequest(ctx, p, pmes) switch err { case nil: return resp, nil case ErrReadTimeout: logger.Warningf("read timeout: %s %s", p.Pretty(), id) fallthrough default: eip.SetError(err) return nil, err } }
go
func (dht *IpfsDHT) findPeerSingle(ctx context.Context, p peer.ID, id peer.ID) (*pb.Message, error) { eip := logger.EventBegin(ctx, "findPeerSingle", logging.LoggableMap{ "peer": p, "target": id, }) defer eip.Done() pmes := pb.NewMessage(pb.Message_FIND_NODE, []byte(id), 0) resp, err := dht.sendRequest(ctx, p, pmes) switch err { case nil: return resp, nil case ErrReadTimeout: logger.Warningf("read timeout: %s %s", p.Pretty(), id) fallthrough default: eip.SetError(err) return nil, err } }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "findPeerSingle", "(", "ctx", "context", ".", "Context", ",", "p", "peer", ".", "ID", ",", "id", "peer", ".", "ID", ")", "(", "*", "pb", ".", "Message", ",", "error", ")", "{", "eip", ":=", "logger", ".", ...
// findPeerSingle asks peer 'p' if they know where the peer with id 'id' is
[ "findPeerSingle", "asks", "peer", "p", "if", "they", "know", "where", "the", "peer", "with", "id", "id", "is" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L291-L311
train
libp2p/go-libp2p-kad-dht
dht.go
nearestPeersToQuery
func (dht *IpfsDHT) nearestPeersToQuery(pmes *pb.Message, count int) []peer.ID { closer := dht.routingTable.NearestPeers(kb.ConvertKey(string(pmes.GetKey())), count) return closer }
go
func (dht *IpfsDHT) nearestPeersToQuery(pmes *pb.Message, count int) []peer.ID { closer := dht.routingTable.NearestPeers(kb.ConvertKey(string(pmes.GetKey())), count) return closer }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "nearestPeersToQuery", "(", "pmes", "*", "pb", ".", "Message", ",", "count", "int", ")", "[", "]", "peer", ".", "ID", "{", "closer", ":=", "dht", ".", "routingTable", ".", "NearestPeers", "(", "kb", ".", "Conv...
// nearestPeersToQuery returns the routing tables closest peers.
[ "nearestPeersToQuery", "returns", "the", "routing", "tables", "closest", "peers", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L332-L335
train
libp2p/go-libp2p-kad-dht
dht.go
betterPeersToQuery
func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, p peer.ID, count int) []peer.ID { closer := dht.nearestPeersToQuery(pmes, count) // no node? nil if closer == nil { logger.Warning("betterPeersToQuery: no closer peers to send:", p) return nil } filtered := make([]peer.ID, 0, len(closer)) for _, clp := range closer { // == to self? thats bad if clp == dht.self { logger.Error("BUG betterPeersToQuery: attempted to return self! this shouldn't happen...") return nil } // Dont send a peer back themselves if clp == p { continue } filtered = append(filtered, clp) } // ok seems like closer nodes return filtered }
go
func (dht *IpfsDHT) betterPeersToQuery(pmes *pb.Message, p peer.ID, count int) []peer.ID { closer := dht.nearestPeersToQuery(pmes, count) // no node? nil if closer == nil { logger.Warning("betterPeersToQuery: no closer peers to send:", p) return nil } filtered := make([]peer.ID, 0, len(closer)) for _, clp := range closer { // == to self? thats bad if clp == dht.self { logger.Error("BUG betterPeersToQuery: attempted to return self! this shouldn't happen...") return nil } // Dont send a peer back themselves if clp == p { continue } filtered = append(filtered, clp) } // ok seems like closer nodes return filtered }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "betterPeersToQuery", "(", "pmes", "*", "pb", ".", "Message", ",", "p", "peer", ".", "ID", ",", "count", "int", ")", "[", "]", "peer", ".", "ID", "{", "closer", ":=", "dht", ".", "nearestPeersToQuery", "(", ...
// betterPeersToQuery returns nearestPeersToQuery, but if and only if closer than self.
[ "betterPeersToQuery", "returns", "nearestPeersToQuery", "but", "if", "and", "only", "if", "closer", "than", "self", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L338-L365
train
libp2p/go-libp2p-kad-dht
dht.go
newContextWithLocalTags
func (dht *IpfsDHT) newContextWithLocalTags(ctx context.Context, extraTags ...tag.Mutator) context.Context { extraTags = append( extraTags, tag.Upsert(metrics.KeyPeerID, dht.self.Pretty()), tag.Upsert(metrics.KeyInstanceID, fmt.Sprintf("%p", dht)), ) ctx, _ = tag.New( ctx, extraTags..., ) // ignoring error as it is unrelated to the actual function of this code. return ctx }
go
func (dht *IpfsDHT) newContextWithLocalTags(ctx context.Context, extraTags ...tag.Mutator) context.Context { extraTags = append( extraTags, tag.Upsert(metrics.KeyPeerID, dht.self.Pretty()), tag.Upsert(metrics.KeyInstanceID, fmt.Sprintf("%p", dht)), ) ctx, _ = tag.New( ctx, extraTags..., ) // ignoring error as it is unrelated to the actual function of this code. return ctx }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "newContextWithLocalTags", "(", "ctx", "context", ".", "Context", ",", "extraTags", "...", "tag", ".", "Mutator", ")", "context", ".", "Context", "{", "extraTags", "=", "append", "(", "extraTags", ",", "tag", ".", ...
// newContextWithLocalTags returns a new context.Context with the InstanceID and // PeerID keys populated. It will also take any extra tags that need adding to // the context as tag.Mutators.
[ "newContextWithLocalTags", "returns", "a", "new", "context", ".", "Context", "with", "the", "InstanceID", "and", "PeerID", "keys", "populated", ".", "It", "will", "also", "take", "any", "extra", "tags", "that", "need", "adding", "to", "the", "context", "as", ...
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dht.go#L427-L438
train
libp2p/go-libp2p-kad-dht
dial_queue.go
dqDefaultConfig
func dqDefaultConfig() dqConfig { return dqConfig{ minParallelism: DefaultDialQueueMinParallelism, maxParallelism: DefaultDialQueueMaxParallelism, scalingFactor: DefaultDialQueueScalingFactor, maxIdle: DefaultDialQueueMaxIdle, mutePeriod: DefaultDialQueueScalingMutePeriod, } }
go
func dqDefaultConfig() dqConfig { return dqConfig{ minParallelism: DefaultDialQueueMinParallelism, maxParallelism: DefaultDialQueueMaxParallelism, scalingFactor: DefaultDialQueueScalingFactor, maxIdle: DefaultDialQueueMaxIdle, mutePeriod: DefaultDialQueueScalingMutePeriod, } }
[ "func", "dqDefaultConfig", "(", ")", "dqConfig", "{", "return", "dqConfig", "{", "minParallelism", ":", "DefaultDialQueueMinParallelism", ",", "maxParallelism", ":", "DefaultDialQueueMaxParallelism", ",", "scalingFactor", ":", "DefaultDialQueueScalingFactor", ",", "maxIdle"...
// dqDefaultConfig returns the default configuration for dial queues. See const documentation to learn the default values.
[ "dqDefaultConfig", "returns", "the", "default", "configuration", "for", "dial", "queues", ".", "See", "const", "documentation", "to", "learn", "the", "default", "values", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/dial_queue.go#L68-L76
train
libp2p/go-libp2p-kad-dht
routing.go
GetValue
func (dht *IpfsDHT) GetValue(ctx context.Context, key string, opts ...ropts.Option) (_ []byte, err error) { eip := logger.EventBegin(ctx, "GetValue") defer func() { eip.Append(loggableKey(key)) if err != nil { eip.SetError(err) } eip.Done() }() // apply defaultQuorum if relevant var cfg ropts.Options if err := cfg.Apply(opts...); err != nil { return nil, err } opts = append(opts, Quorum(getQuorum(&cfg, defaultQuorum))) responses, err := dht.SearchValue(ctx, key, opts...) if err != nil { return nil, err } var best []byte for r := range responses { best = r } if ctx.Err() != nil { return best, ctx.Err() } if best == nil { return nil, routing.ErrNotFound } logger.Debugf("GetValue %v %v", key, best) return best, nil }
go
func (dht *IpfsDHT) GetValue(ctx context.Context, key string, opts ...ropts.Option) (_ []byte, err error) { eip := logger.EventBegin(ctx, "GetValue") defer func() { eip.Append(loggableKey(key)) if err != nil { eip.SetError(err) } eip.Done() }() // apply defaultQuorum if relevant var cfg ropts.Options if err := cfg.Apply(opts...); err != nil { return nil, err } opts = append(opts, Quorum(getQuorum(&cfg, defaultQuorum))) responses, err := dht.SearchValue(ctx, key, opts...) if err != nil { return nil, err } var best []byte for r := range responses { best = r } if ctx.Err() != nil { return best, ctx.Err() } if best == nil { return nil, routing.ErrNotFound } logger.Debugf("GetValue %v %v", key, best) return best, nil }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "GetValue", "(", "ctx", "context", ".", "Context", ",", "key", "string", ",", "opts", "...", "ropts", ".", "Option", ")", "(", "_", "[", "]", "byte", ",", "err", "error", ")", "{", "eip", ":=", "logger", "...
// GetValue searches for the value corresponding to given Key.
[ "GetValue", "searches", "for", "the", "value", "corresponding", "to", "given", "Key", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/routing.go#L113-L149
train
libp2p/go-libp2p-kad-dht
routing.go
GetValues
func (dht *IpfsDHT) GetValues(ctx context.Context, key string, nvals int) (_ []RecvdVal, err error) { eip := logger.EventBegin(ctx, "GetValues") eip.Append(loggableKey(key)) defer eip.Done() valCh, err := dht.getValues(ctx, key, nvals) if err != nil { eip.SetError(err) return nil, err } out := make([]RecvdVal, 0, nvals) for val := range valCh { out = append(out, val) } return out, ctx.Err() }
go
func (dht *IpfsDHT) GetValues(ctx context.Context, key string, nvals int) (_ []RecvdVal, err error) { eip := logger.EventBegin(ctx, "GetValues") eip.Append(loggableKey(key)) defer eip.Done() valCh, err := dht.getValues(ctx, key, nvals) if err != nil { eip.SetError(err) return nil, err } out := make([]RecvdVal, 0, nvals) for val := range valCh { out = append(out, val) } return out, ctx.Err() }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "GetValues", "(", "ctx", "context", ".", "Context", ",", "key", "string", ",", "nvals", "int", ")", "(", "_", "[", "]", "RecvdVal", ",", "err", "error", ")", "{", "eip", ":=", "logger", ".", "EventBegin", "(...
// GetValues gets nvals values corresponding to the given key.
[ "GetValues", "gets", "nvals", "values", "corresponding", "to", "the", "given", "key", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/routing.go#L253-L271
train
libp2p/go-libp2p-kad-dht
routing.go
Provide
func (dht *IpfsDHT) Provide(ctx context.Context, key cid.Cid, brdcst bool) (err error) { eip := logger.EventBegin(ctx, "Provide", key, logging.LoggableMap{"broadcast": brdcst}) defer func() { if err != nil { eip.SetError(err) } eip.Done() }() // add self locally dht.providers.AddProvider(ctx, key, dht.self) if !brdcst { return nil } peers, err := dht.GetClosestPeers(ctx, key.KeyString()) if err != nil { return err } mes, err := dht.makeProvRecord(key) if err != nil { return err } wg := sync.WaitGroup{} for p := range peers { wg.Add(1) go func(p peer.ID) { defer wg.Done() logger.Debugf("putProvider(%s, %s)", key, p) err := dht.sendMessage(ctx, p, mes) if err != nil { logger.Debug(err) } }(p) } wg.Wait() return nil }
go
func (dht *IpfsDHT) Provide(ctx context.Context, key cid.Cid, brdcst bool) (err error) { eip := logger.EventBegin(ctx, "Provide", key, logging.LoggableMap{"broadcast": brdcst}) defer func() { if err != nil { eip.SetError(err) } eip.Done() }() // add self locally dht.providers.AddProvider(ctx, key, dht.self) if !brdcst { return nil } peers, err := dht.GetClosestPeers(ctx, key.KeyString()) if err != nil { return err } mes, err := dht.makeProvRecord(key) if err != nil { return err } wg := sync.WaitGroup{} for p := range peers { wg.Add(1) go func(p peer.ID) { defer wg.Done() logger.Debugf("putProvider(%s, %s)", key, p) err := dht.sendMessage(ctx, p, mes) if err != nil { logger.Debug(err) } }(p) } wg.Wait() return nil }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "Provide", "(", "ctx", "context", ".", "Context", ",", "key", "cid", ".", "Cid", ",", "brdcst", "bool", ")", "(", "err", "error", ")", "{", "eip", ":=", "logger", ".", "EventBegin", "(", "ctx", ",", "\"Provi...
// Provider abstraction for indirect stores. // Some DHTs store values directly, while an indirect store stores pointers to // locations of the value, similarly to Coral and Mainline DHT. // Provide makes this node announce that it can provide a value for the given key
[ "Provider", "abstraction", "for", "indirect", "stores", ".", "Some", "DHTs", "store", "values", "directly", "while", "an", "indirect", "store", "stores", "pointers", "to", "locations", "of", "the", "value", "similarly", "to", "Coral", "and", "Mainline", "DHT", ...
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/routing.go#L398-L437
train
libp2p/go-libp2p-kad-dht
routing.go
FindProviders
func (dht *IpfsDHT) FindProviders(ctx context.Context, c cid.Cid) ([]pstore.PeerInfo, error) { var providers []pstore.PeerInfo for p := range dht.FindProvidersAsync(ctx, c, KValue) { providers = append(providers, p) } return providers, nil }
go
func (dht *IpfsDHT) FindProviders(ctx context.Context, c cid.Cid) ([]pstore.PeerInfo, error) { var providers []pstore.PeerInfo for p := range dht.FindProvidersAsync(ctx, c, KValue) { providers = append(providers, p) } return providers, nil }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "FindProviders", "(", "ctx", "context", ".", "Context", ",", "c", "cid", ".", "Cid", ")", "(", "[", "]", "pstore", ".", "PeerInfo", ",", "error", ")", "{", "var", "providers", "[", "]", "pstore", ".", "PeerI...
// FindProviders searches until the context expires.
[ "FindProviders", "searches", "until", "the", "context", "expires", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/routing.go#L456-L462
train
libp2p/go-libp2p-kad-dht
routing.go
FindProvidersAsync
func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan pstore.PeerInfo { logger.Event(ctx, "findProviders", key) peerOut := make(chan pstore.PeerInfo, count) go dht.findProvidersAsyncRoutine(ctx, key, count, peerOut) return peerOut }
go
func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan pstore.PeerInfo { logger.Event(ctx, "findProviders", key) peerOut := make(chan pstore.PeerInfo, count) go dht.findProvidersAsyncRoutine(ctx, key, count, peerOut) return peerOut }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "FindProvidersAsync", "(", "ctx", "context", ".", "Context", ",", "key", "cid", ".", "Cid", ",", "count", "int", ")", "<-", "chan", "pstore", ".", "PeerInfo", "{", "logger", ".", "Event", "(", "ctx", ",", "\"f...
// FindProvidersAsync is the same thing as FindProviders, but returns a channel. // Peers will be returned on the channel as soon as they are found, even before // the search query completes.
[ "FindProvidersAsync", "is", "the", "same", "thing", "as", "FindProviders", "but", "returns", "a", "channel", ".", "Peers", "will", "be", "returned", "on", "the", "channel", "as", "soon", "as", "they", "are", "found", "even", "before", "the", "search", "query...
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/routing.go#L467-L472
train
libp2p/go-libp2p-kad-dht
routing.go
FindPeer
func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ pstore.PeerInfo, err error) { eip := logger.EventBegin(ctx, "FindPeer", id) defer func() { if err != nil { eip.SetError(err) } eip.Done() }() // Check if were already connected to them if pi := dht.FindLocal(id); pi.ID != "" { return pi, nil } peers := dht.routingTable.NearestPeers(kb.ConvertPeerID(id), AlphaValue) if len(peers) == 0 { return pstore.PeerInfo{}, kb.ErrLookupFailure } // Sanity... for _, p := range peers { if p == id { logger.Debug("found target peer in list of closest peers...") return dht.peerstore.PeerInfo(p), nil } } // setup the Query parent := ctx query := dht.newQuery(string(id), func(ctx context.Context, p peer.ID) (*dhtQueryResult, error) { notif.PublishQueryEvent(parent, &notif.QueryEvent{ Type: notif.SendingQuery, ID: p, }) pmes, err := dht.findPeerSingle(ctx, p, id) if err != nil { return nil, err } closer := pmes.GetCloserPeers() clpeerInfos := pb.PBPeersToPeerInfos(closer) // see if we got the peer here for _, npi := range clpeerInfos { if npi.ID == id { return &dhtQueryResult{ peer: npi, success: true, }, nil } } notif.PublishQueryEvent(parent, &notif.QueryEvent{ Type: notif.PeerResponse, ID: p, Responses: clpeerInfos, }) return &dhtQueryResult{closerPeers: clpeerInfos}, nil }) // run it! result, err := query.Run(ctx, peers) if err != nil { return pstore.PeerInfo{}, err } logger.Debugf("FindPeer %v %v", id, result.success) if result.peer.ID == "" { return pstore.PeerInfo{}, routing.ErrNotFound } return *result.peer, nil }
go
func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ pstore.PeerInfo, err error) { eip := logger.EventBegin(ctx, "FindPeer", id) defer func() { if err != nil { eip.SetError(err) } eip.Done() }() // Check if were already connected to them if pi := dht.FindLocal(id); pi.ID != "" { return pi, nil } peers := dht.routingTable.NearestPeers(kb.ConvertPeerID(id), AlphaValue) if len(peers) == 0 { return pstore.PeerInfo{}, kb.ErrLookupFailure } // Sanity... for _, p := range peers { if p == id { logger.Debug("found target peer in list of closest peers...") return dht.peerstore.PeerInfo(p), nil } } // setup the Query parent := ctx query := dht.newQuery(string(id), func(ctx context.Context, p peer.ID) (*dhtQueryResult, error) { notif.PublishQueryEvent(parent, &notif.QueryEvent{ Type: notif.SendingQuery, ID: p, }) pmes, err := dht.findPeerSingle(ctx, p, id) if err != nil { return nil, err } closer := pmes.GetCloserPeers() clpeerInfos := pb.PBPeersToPeerInfos(closer) // see if we got the peer here for _, npi := range clpeerInfos { if npi.ID == id { return &dhtQueryResult{ peer: npi, success: true, }, nil } } notif.PublishQueryEvent(parent, &notif.QueryEvent{ Type: notif.PeerResponse, ID: p, Responses: clpeerInfos, }) return &dhtQueryResult{closerPeers: clpeerInfos}, nil }) // run it! result, err := query.Run(ctx, peers) if err != nil { return pstore.PeerInfo{}, err } logger.Debugf("FindPeer %v %v", id, result.success) if result.peer.ID == "" { return pstore.PeerInfo{}, routing.ErrNotFound } return *result.peer, nil }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "FindPeer", "(", "ctx", "context", ".", "Context", ",", "id", "peer", ".", "ID", ")", "(", "_", "pstore", ".", "PeerInfo", ",", "err", "error", ")", "{", "eip", ":=", "logger", ".", "EventBegin", "(", "ctx",...
// FindPeer searches for a peer with given ID.
[ "FindPeer", "searches", "for", "a", "peer", "with", "given", "ID", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/routing.go#L578-L652
train
libp2p/go-libp2p-kad-dht
routing.go
FindPeersConnectedToPeer
func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (<-chan *pstore.PeerInfo, error) { peerchan := make(chan *pstore.PeerInfo, asyncQueryBuffer) peersSeen := make(map[peer.ID]struct{}) var peersSeenMx sync.Mutex peers := dht.routingTable.NearestPeers(kb.ConvertPeerID(id), AlphaValue) if len(peers) == 0 { return nil, kb.ErrLookupFailure } // setup the Query query := dht.newQuery(string(id), func(ctx context.Context, p peer.ID) (*dhtQueryResult, error) { pmes, err := dht.findPeerSingle(ctx, p, id) if err != nil { return nil, err } var clpeers []*pstore.PeerInfo closer := pmes.GetCloserPeers() for _, pbp := range closer { pi := pb.PBPeerToPeerInfo(pbp) // skip peers already seen peersSeenMx.Lock() if _, found := peersSeen[pi.ID]; found { peersSeenMx.Unlock() continue } peersSeen[pi.ID] = struct{}{} peersSeenMx.Unlock() // if peer is connected, send it to our client. if pb.Connectedness(pbp.Connection) == inet.Connected { select { case <-ctx.Done(): return nil, ctx.Err() case peerchan <- pi: } } // if peer is the peer we're looking for, don't bother querying it. // TODO maybe query it? if pb.Connectedness(pbp.Connection) != inet.Connected { clpeers = append(clpeers, pi) } } return &dhtQueryResult{closerPeers: clpeers}, nil }) // run it! run it asynchronously to gen peers as results are found. // this does no error checking go func() { if _, err := query.Run(ctx, peers); err != nil { logger.Debug(err) } // close the peerchan channel when done. close(peerchan) }() return peerchan, nil }
go
func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (<-chan *pstore.PeerInfo, error) { peerchan := make(chan *pstore.PeerInfo, asyncQueryBuffer) peersSeen := make(map[peer.ID]struct{}) var peersSeenMx sync.Mutex peers := dht.routingTable.NearestPeers(kb.ConvertPeerID(id), AlphaValue) if len(peers) == 0 { return nil, kb.ErrLookupFailure } // setup the Query query := dht.newQuery(string(id), func(ctx context.Context, p peer.ID) (*dhtQueryResult, error) { pmes, err := dht.findPeerSingle(ctx, p, id) if err != nil { return nil, err } var clpeers []*pstore.PeerInfo closer := pmes.GetCloserPeers() for _, pbp := range closer { pi := pb.PBPeerToPeerInfo(pbp) // skip peers already seen peersSeenMx.Lock() if _, found := peersSeen[pi.ID]; found { peersSeenMx.Unlock() continue } peersSeen[pi.ID] = struct{}{} peersSeenMx.Unlock() // if peer is connected, send it to our client. if pb.Connectedness(pbp.Connection) == inet.Connected { select { case <-ctx.Done(): return nil, ctx.Err() case peerchan <- pi: } } // if peer is the peer we're looking for, don't bother querying it. // TODO maybe query it? if pb.Connectedness(pbp.Connection) != inet.Connected { clpeers = append(clpeers, pi) } } return &dhtQueryResult{closerPeers: clpeers}, nil }) // run it! run it asynchronously to gen peers as results are found. // this does no error checking go func() { if _, err := query.Run(ctx, peers); err != nil { logger.Debug(err) } // close the peerchan channel when done. close(peerchan) }() return peerchan, nil }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "FindPeersConnectedToPeer", "(", "ctx", "context", ".", "Context", ",", "id", "peer", ".", "ID", ")", "(", "<-", "chan", "*", "pstore", ".", "PeerInfo", ",", "error", ")", "{", "peerchan", ":=", "make", "(", "...
// FindPeersConnectedToPeer searches for peers directly connected to a given peer.
[ "FindPeersConnectedToPeer", "searches", "for", "peers", "directly", "connected", "to", "a", "given", "peer", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/routing.go#L655-L719
train
libp2p/go-libp2p-kad-dht
handlers.go
handlePutValue
func (dht *IpfsDHT) handlePutValue(ctx context.Context, p peer.ID, pmes *pb.Message) (_ *pb.Message, err error) { ctx = logger.Start(ctx, "handlePutValue") logger.SetTag(ctx, "peer", p) defer func() { logger.FinishWithErr(ctx, err) }() rec := pmes.GetRecord() if rec == nil { logger.Infof("Got nil record from: %s", p.Pretty()) return nil, errors.New("nil record") } if !bytes.Equal(pmes.GetKey(), rec.GetKey()) { return nil, errors.New("put key doesn't match record key") } cleanRecord(rec) // Make sure the record is valid (not expired, valid signature etc) if err = dht.Validator.Validate(string(rec.GetKey()), rec.GetValue()); err != nil { logger.Warningf("Bad dht record in PUT from: %s. %s", p.Pretty(), err) return nil, err } dskey := convertToDsKey(rec.GetKey()) // Make sure the new record is "better" than the record we have locally. // This prevents a record with for example a lower sequence number from // overwriting a record with a higher sequence number. existing, err := dht.getRecordFromDatastore(dskey) if err != nil { return nil, err } if existing != nil { recs := [][]byte{rec.GetValue(), existing.GetValue()} i, err := dht.Validator.Select(string(rec.GetKey()), recs) if err != nil { logger.Warningf("Bad dht record in PUT from %s: %s", p.Pretty(), err) return nil, err } if i != 0 { logger.Infof("DHT record in PUT from %s is older than existing record. Ignoring", p.Pretty()) return nil, errors.New("old record") } } // record the time we receive every record rec.TimeReceived = u.FormatRFC3339(time.Now()) data, err := proto.Marshal(rec) if err != nil { return nil, err } err = dht.datastore.Put(dskey, data) logger.Debugf("%s handlePutValue %v", dht.self, dskey) return pmes, err }
go
func (dht *IpfsDHT) handlePutValue(ctx context.Context, p peer.ID, pmes *pb.Message) (_ *pb.Message, err error) { ctx = logger.Start(ctx, "handlePutValue") logger.SetTag(ctx, "peer", p) defer func() { logger.FinishWithErr(ctx, err) }() rec := pmes.GetRecord() if rec == nil { logger.Infof("Got nil record from: %s", p.Pretty()) return nil, errors.New("nil record") } if !bytes.Equal(pmes.GetKey(), rec.GetKey()) { return nil, errors.New("put key doesn't match record key") } cleanRecord(rec) // Make sure the record is valid (not expired, valid signature etc) if err = dht.Validator.Validate(string(rec.GetKey()), rec.GetValue()); err != nil { logger.Warningf("Bad dht record in PUT from: %s. %s", p.Pretty(), err) return nil, err } dskey := convertToDsKey(rec.GetKey()) // Make sure the new record is "better" than the record we have locally. // This prevents a record with for example a lower sequence number from // overwriting a record with a higher sequence number. existing, err := dht.getRecordFromDatastore(dskey) if err != nil { return nil, err } if existing != nil { recs := [][]byte{rec.GetValue(), existing.GetValue()} i, err := dht.Validator.Select(string(rec.GetKey()), recs) if err != nil { logger.Warningf("Bad dht record in PUT from %s: %s", p.Pretty(), err) return nil, err } if i != 0 { logger.Infof("DHT record in PUT from %s is older than existing record. Ignoring", p.Pretty()) return nil, errors.New("old record") } } // record the time we receive every record rec.TimeReceived = u.FormatRFC3339(time.Now()) data, err := proto.Marshal(rec) if err != nil { return nil, err } err = dht.datastore.Put(dskey, data) logger.Debugf("%s handlePutValue %v", dht.self, dskey) return pmes, err }
[ "func", "(", "dht", "*", "IpfsDHT", ")", "handlePutValue", "(", "ctx", "context", ".", "Context", ",", "p", "peer", ".", "ID", ",", "pmes", "*", "pb", ".", "Message", ")", "(", "_", "*", "pb", ".", "Message", ",", "err", "error", ")", "{", "ctx",...
// Store a value in this peer local storage
[ "Store", "a", "value", "in", "this", "peer", "local", "storage" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/handlers.go#L148-L205
train
libp2p/go-libp2p-kad-dht
opts/options.go
Apply
func (o *Options) Apply(opts ...Option) error { for i, opt := range opts { if err := opt(o); err != nil { return fmt.Errorf("dht option %d failed: %s", i, err) } } return nil }
go
func (o *Options) Apply(opts ...Option) error { for i, opt := range opts { if err := opt(o); err != nil { return fmt.Errorf("dht option %d failed: %s", i, err) } } return nil }
[ "func", "(", "o", "*", "Options", ")", "Apply", "(", "opts", "...", "Option", ")", "error", "{", "for", "i", ",", "opt", ":=", "range", "opts", "{", "if", "err", ":=", "opt", "(", "o", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", ...
// Apply applies the given options to this Option
[ "Apply", "applies", "the", "given", "options", "to", "this", "Option" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/opts/options.go#L30-L37
train
libp2p/go-libp2p-kad-dht
opts/options.go
Client
func Client(only bool) Option { return func(o *Options) error { o.Client = only return nil } }
go
func Client(only bool) Option { return func(o *Options) error { o.Client = only return nil } }
[ "func", "Client", "(", "only", "bool", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "Client", "=", "only", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Client configures whether or not the DHT operates in client-only mode. // // Defaults to false.
[ "Client", "configures", "whether", "or", "not", "the", "DHT", "operates", "in", "client", "-", "only", "mode", ".", "Defaults", "to", "false", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/opts/options.go#L66-L71
train
libp2p/go-libp2p-kad-dht
opts/options.go
Validator
func Validator(v record.Validator) Option { return func(o *Options) error { o.Validator = v return nil } }
go
func Validator(v record.Validator) Option { return func(o *Options) error { o.Validator = v return nil } }
[ "func", "Validator", "(", "v", "record", ".", "Validator", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "Validator", "=", "v", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Validator configures the DHT to use the specified validator. // // Defaults to a namespaced validator that can only validate public keys.
[ "Validator", "configures", "the", "DHT", "to", "use", "the", "specified", "validator", ".", "Defaults", "to", "a", "namespaced", "validator", "that", "can", "only", "validate", "public", "keys", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/opts/options.go#L76-L81
train
libp2p/go-libp2p-kad-dht
opts/options.go
Protocols
func Protocols(protocols ...protocol.ID) Option { return func(o *Options) error { o.Protocols = protocols return nil } }
go
func Protocols(protocols ...protocol.ID) Option { return func(o *Options) error { o.Protocols = protocols return nil } }
[ "func", "Protocols", "(", "protocols", "...", "protocol", ".", "ID", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "Protocols", "=", "protocols", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Protocols sets the protocols for the DHT // // Defaults to dht.DefaultProtocols
[ "Protocols", "sets", "the", "protocols", "for", "the", "DHT", "Defaults", "to", "dht", ".", "DefaultProtocols" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/opts/options.go#L104-L109
train
libp2p/go-libp2p-kad-dht
metrics/metrics.go
UpsertMessageType
func UpsertMessageType(m *pb.Message) tag.Mutator { return tag.Upsert(KeyMessageType, m.Type.String()) }
go
func UpsertMessageType(m *pb.Message) tag.Mutator { return tag.Upsert(KeyMessageType, m.Type.String()) }
[ "func", "UpsertMessageType", "(", "m", "*", "pb", ".", "Message", ")", "tag", ".", "Mutator", "{", "return", "tag", ".", "Upsert", "(", "KeyMessageType", ",", "m", ".", "Type", ".", "String", "(", ")", ")", "\n", "}" ]
// UpsertMessageType is a convenience upserts the message type // of a pb.Message into the KeyMessageType.
[ "UpsertMessageType", "is", "a", "convenience", "upserts", "the", "message", "type", "of", "a", "pb", ".", "Message", "into", "the", "KeyMessageType", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/metrics/metrics.go#L26-L28
train
libp2p/go-libp2p-kad-dht
pb/message.go
NewMessage
func NewMessage(typ Message_MessageType, key []byte, level int) *Message { m := &Message{ Type: typ, Key: key, } m.SetClusterLevel(level) return m }
go
func NewMessage(typ Message_MessageType, key []byte, level int) *Message { m := &Message{ Type: typ, Key: key, } m.SetClusterLevel(level) return m }
[ "func", "NewMessage", "(", "typ", "Message_MessageType", ",", "key", "[", "]", "byte", ",", "level", "int", ")", "*", "Message", "{", "m", ":=", "&", "Message", "{", "Type", ":", "typ", ",", "Key", ":", "key", ",", "}", "\n", "m", ".", "SetClusterL...
// NewMessage constructs a new dht message with given type, key, and level
[ "NewMessage", "constructs", "a", "new", "dht", "message", "with", "given", "type", "key", "and", "level" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/pb/message.go#L20-L27
train
libp2p/go-libp2p-kad-dht
pb/message.go
Addresses
func (m *Message_Peer) Addresses() []ma.Multiaddr { if m == nil { return nil } maddrs := make([]ma.Multiaddr, 0, len(m.Addrs)) for _, addr := range m.Addrs { maddr, err := ma.NewMultiaddrBytes(addr) if err != nil { log.Warningf("error decoding Multiaddr for peer: %s", m.GetId()) continue } maddrs = append(maddrs, maddr) } return maddrs }
go
func (m *Message_Peer) Addresses() []ma.Multiaddr { if m == nil { return nil } maddrs := make([]ma.Multiaddr, 0, len(m.Addrs)) for _, addr := range m.Addrs { maddr, err := ma.NewMultiaddrBytes(addr) if err != nil { log.Warningf("error decoding Multiaddr for peer: %s", m.GetId()) continue } maddrs = append(maddrs, maddr) } return maddrs }
[ "func", "(", "m", "*", "Message_Peer", ")", "Addresses", "(", ")", "[", "]", "ma", ".", "Multiaddr", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "maddrs", ":=", "make", "(", "[", "]", "ma", ".", "Multiaddr", ",", "0", ",...
// Addresses returns a multiaddr associated with the Message_Peer entry
[ "Addresses", "returns", "a", "multiaddr", "associated", "with", "the", "Message_Peer", "entry" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/pb/message.go#L104-L120
train
libp2p/go-libp2p-kad-dht
pb/message.go
Loggable
func (m *Message) Loggable() map[string]interface{} { return map[string]interface{}{ "message": map[string]string{ "type": m.Type.String(), "key": b58.Encode([]byte(m.GetKey())), }, } }
go
func (m *Message) Loggable() map[string]interface{} { return map[string]interface{}{ "message": map[string]string{ "type": m.Type.String(), "key": b58.Encode([]byte(m.GetKey())), }, } }
[ "func", "(", "m", "*", "Message", ")", "Loggable", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "return", "map", "[", "string", "]", "interface", "{", "}", "{", "\"message\"", ":", "map", "[", "string", "]", "string", "{", "\"ty...
// Loggable turns a Message into machine-readable log output
[ "Loggable", "turns", "a", "Message", "into", "machine", "-", "readable", "log", "output" ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/pb/message.go#L142-L149
train
libp2p/go-libp2p-kad-dht
pb/message.go
ConnectionType
func ConnectionType(c inet.Connectedness) Message_ConnectionType { switch c { default: return Message_NOT_CONNECTED case inet.NotConnected: return Message_NOT_CONNECTED case inet.Connected: return Message_CONNECTED case inet.CanConnect: return Message_CAN_CONNECT case inet.CannotConnect: return Message_CANNOT_CONNECT } }
go
func ConnectionType(c inet.Connectedness) Message_ConnectionType { switch c { default: return Message_NOT_CONNECTED case inet.NotConnected: return Message_NOT_CONNECTED case inet.Connected: return Message_CONNECTED case inet.CanConnect: return Message_CAN_CONNECT case inet.CannotConnect: return Message_CANNOT_CONNECT } }
[ "func", "ConnectionType", "(", "c", "inet", ".", "Connectedness", ")", "Message_ConnectionType", "{", "switch", "c", "{", "default", ":", "return", "Message_NOT_CONNECTED", "\n", "case", "inet", ".", "NotConnected", ":", "return", "Message_NOT_CONNECTED", "\n", "c...
// ConnectionType returns a Message_ConnectionType associated with the // inet.Connectedness.
[ "ConnectionType", "returns", "a", "Message_ConnectionType", "associated", "with", "the", "inet", ".", "Connectedness", "." ]
fb62272e7ee5e16c07f88c30cb76e0f69e36ab69
https://github.com/libp2p/go-libp2p-kad-dht/blob/fb62272e7ee5e16c07f88c30cb76e0f69e36ab69/pb/message.go#L153-L166
train
algolia/algoliasearch-client-go
algolia/opt/rule_contexts.go
RuleContextsEqual
func RuleContextsEqual(o1, o2 *RuleContextsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func RuleContextsEqual(o1, o2 *RuleContextsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "RuleContextsEqual", "(", "o1", ",", "o2", "*", "RuleContextsOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal",...
// RuleContextsEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "RuleContextsEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "d...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/rule_contexts.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/opt/ignore_plurals.go
MarshalJSON
func (o IgnorePluralsOption) MarshalJSON() ([]byte, error) { if len(o.languages) > 0 { return json.Marshal(o.languages) } return json.Marshal(o.ignorePlurals) }
go
func (o IgnorePluralsOption) MarshalJSON() ([]byte, error) { if len(o.languages) > 0 { return json.Marshal(o.languages) } return json.Marshal(o.ignorePlurals) }
[ "func", "(", "o", "IgnorePluralsOption", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "o", ".", "languages", ")", ">", "0", "{", "return", "json", ".", "Marshal", "(", "o", ".", "languages", ")", ...
// MarshalJSON implements the json.Marshaler interface for // IgnorePluralsOption.
[ "MarshalJSON", "implements", "the", "json", ".", "Marshaler", "interface", "for", "IgnorePluralsOption", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/ignore_plurals.go#L36-L41
train
algolia/algoliasearch-client-go
algolia/opt/ignore_plurals.go
UnmarshalJSON
func (o *IgnorePluralsOption) UnmarshalJSON(data []byte) error { if string(data) == "null" { return nil } if err := json.Unmarshal(data, &o.languages); err == nil { return nil } return json.Unmarshal(data, &o.ignorePlurals) }
go
func (o *IgnorePluralsOption) UnmarshalJSON(data []byte) error { if string(data) == "null" { return nil } if err := json.Unmarshal(data, &o.languages); err == nil { return nil } return json.Unmarshal(data, &o.ignorePlurals) }
[ "func", "(", "o", "*", "IgnorePluralsOption", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "string", "(", "data", ")", "==", "\"null\"", "{", "return", "nil", "\n", "}", "\n", "if", "err", ":=", "json", ".", "Unmarsha...
// UnmarshalJSON implements the json.Unmarshaler interface for // IgnorePluralsOption.
[ "UnmarshalJSON", "implements", "the", "json", ".", "Unmarshaler", "interface", "for", "IgnorePluralsOption", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/ignore_plurals.go#L45-L55
train
algolia/algoliasearch-client-go
algolia/opt/ignore_plurals.go
IgnorePluralsEqual
func IgnorePluralsEqual(o1, o2 *IgnorePluralsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func IgnorePluralsEqual(o1, o2 *IgnorePluralsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "IgnorePluralsEqual", "(", "o1", ",", "o2", "*", "IgnorePluralsOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal...
// IgnorePluralsEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "IgnorePluralsEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/ignore_plurals.go#L70-L78
train
algolia/algoliasearch-client-go
algolia/opt/faceting_after_distinct.go
FacetingAfterDistinctEqual
func FacetingAfterDistinctEqual(o1, o2 *FacetingAfterDistinctOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func FacetingAfterDistinctEqual(o1, o2 *FacetingAfterDistinctOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "FacetingAfterDistinctEqual", "(", "o1", ",", "o2", "*", "FacetingAfterDistinctOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2",...
// FacetingAfterDistinctEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "FacetingAfterDistinctEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "t...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/faceting_after_distinct.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/opt/response_fields.go
ResponseFieldsEqual
func ResponseFieldsEqual(o1, o2 *ResponseFieldsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func ResponseFieldsEqual(o1, o2 *ResponseFieldsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "ResponseFieldsEqual", "(", "o1", ",", "o2", "*", "ResponseFieldsOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equ...
// ResponseFieldsEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "ResponseFieldsEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", ...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/response_fields.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/internal/opt/allow_compression_of_integer_array.go
ExtractAllowCompressionOfIntegerArray
func ExtractAllowCompressionOfIntegerArray(opts ...interface{}) *opt.AllowCompressionOfIntegerArrayOption { for _, o := range opts { if v, ok := o.(*opt.AllowCompressionOfIntegerArrayOption); ok { return v } } return nil }
go
func ExtractAllowCompressionOfIntegerArray(opts ...interface{}) *opt.AllowCompressionOfIntegerArrayOption { for _, o := range opts { if v, ok := o.(*opt.AllowCompressionOfIntegerArrayOption); ok { return v } } return nil }
[ "func", "ExtractAllowCompressionOfIntegerArray", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "AllowCompressionOfIntegerArrayOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*",...
// ExtractAllowCompressionOfIntegerArray returns the first found AllowCompressionOfIntegerArrayOption from the // given variadic arguments or nil otherwise.
[ "ExtractAllowCompressionOfIntegerArray", "returns", "the", "first", "found", "AllowCompressionOfIntegerArrayOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/allow_compression_of_integer_array.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/replicas.go
ReplicasEqual
func ReplicasEqual(o1, o2 *ReplicasOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func ReplicasEqual(o1, o2 *ReplicasOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "ReplicasEqual", "(", "o1", ",", "o2", "*", "ReplicasOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal", "(", ...
// ReplicasEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "ReplicasEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "defau...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/replicas.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/opt/keep_diacritics_on_characters.go
KeepDiacriticsOnCharactersEqual
func KeepDiacriticsOnCharactersEqual(o1, o2 *KeepDiacriticsOnCharactersOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func KeepDiacriticsOnCharactersEqual(o1, o2 *KeepDiacriticsOnCharactersOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "KeepDiacriticsOnCharactersEqual", "(", "o1", ",", "o2", "*", "KeepDiacriticsOnCharactersOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return...
// KeepDiacriticsOnCharactersEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "KeepDiacriticsOnCharactersEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to",...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/keep_diacritics_on_characters.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/rand/time.go
Duration
func Duration(max time.Duration) time.Duration { nbNanoseconds := 1 + int(rand.Int63n(max.Nanoseconds())) return time.Duration(nbNanoseconds) * time.Nanosecond }
go
func Duration(max time.Duration) time.Duration { nbNanoseconds := 1 + int(rand.Int63n(max.Nanoseconds())) return time.Duration(nbNanoseconds) * time.Nanosecond }
[ "func", "Duration", "(", "max", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "nbNanoseconds", ":=", "1", "+", "int", "(", "rand", ".", "Int63n", "(", "max", ".", "Nanoseconds", "(", ")", ")", ")", "\n", "return", "time", ".", "Duration...
// Duration returns a random `time.Duration` limited to the given // `max time.Duration`.
[ "Duration", "returns", "a", "random", "time", ".", "Duration", "limited", "to", "the", "given", "max", "time", ".", "Duration", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/rand/time.go#L14-L17
train
algolia/algoliasearch-client-go
algolia/opt/attributes_to_retrieve.go
AttributesToRetrieveEqual
func AttributesToRetrieveEqual(o1, o2 *AttributesToRetrieveOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func AttributesToRetrieveEqual(o1, o2 *AttributesToRetrieveOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "AttributesToRetrieveEqual", "(", "o1", ",", "o2", "*", "AttributesToRetrieveOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ...
// AttributesToRetrieveEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "AttributesToRetrieveEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "th...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/attributes_to_retrieve.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/internal/opt/around_lat_lng.go
ExtractAroundLatLng
func ExtractAroundLatLng(opts ...interface{}) *opt.AroundLatLngOption { for _, o := range opts { if v, ok := o.(*opt.AroundLatLngOption); ok { return v } } return nil }
go
func ExtractAroundLatLng(opts ...interface{}) *opt.AroundLatLngOption { for _, o := range opts { if v, ok := o.(*opt.AroundLatLngOption); ok { return v } } return nil }
[ "func", "ExtractAroundLatLng", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "AroundLatLngOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "AroundLatLngOpti...
// ExtractAroundLatLng returns the first found AroundLatLngOption from the // given variadic arguments or nil otherwise.
[ "ExtractAroundLatLng", "returns", "the", "first", "found", "AroundLatLngOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/around_lat_lng.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/internal/opt/facets.go
ExtractFacets
func ExtractFacets(opts ...interface{}) *opt.FacetsOption { for _, o := range opts { if v, ok := o.(*opt.FacetsOption); ok { return v } } return nil }
go
func ExtractFacets(opts ...interface{}) *opt.FacetsOption { for _, o := range opts { if v, ok := o.(*opt.FacetsOption); ok { return v } } return nil }
[ "func", "ExtractFacets", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "FacetsOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "FacetsOption", ")", ";",...
// ExtractFacets returns the first found FacetsOption from the // given variadic arguments or nil otherwise.
[ "ExtractFacets", "returns", "the", "first", "found", "FacetsOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/facets.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/enable_rules.go
EnableRulesEqual
func EnableRulesEqual(o1, o2 *EnableRulesOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func EnableRulesEqual(o1, o2 *EnableRulesOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "EnableRulesEqual", "(", "o1", ",", "o2", "*", "EnableRulesOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal", ...
// EnableRulesEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "EnableRulesEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "de...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/enable_rules.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/opt/pagination_limited_to.go
PaginationLimitedToEqual
func PaginationLimitedToEqual(o1, o2 *PaginationLimitedToOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func PaginationLimitedToEqual(o1, o2 *PaginationLimitedToOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "PaginationLimitedToEqual", "(", "o1", ",", "o2", "*", "PaginationLimitedToOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", "...
// PaginationLimitedToEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "PaginationLimitedToEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/pagination_limited_to.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/wait/group.go
Wait
func Wait(waitables ...Waitable) error { g := NewGroup() g.Collect(waitables...) return g.Wait() }
go
func Wait(waitables ...Waitable) error { g := NewGroup() g.Collect(waitables...) return g.Wait() }
[ "func", "Wait", "(", "waitables", "...", "Waitable", ")", "error", "{", "g", ":=", "NewGroup", "(", ")", "\n", "g", ".", "Collect", "(", "waitables", "...", ")", "\n", "return", "g", ".", "Wait", "(", ")", "\n", "}" ]
// Wait blocks until all the given `algolia.Waitable` objects have completed. If // one of the objects returned an error upon `Wait` invocation, this error is // returned. Otherwise, nil is returned.
[ "Wait", "blocks", "until", "all", "the", "given", "algolia", ".", "Waitable", "objects", "have", "completed", ".", "If", "one", "of", "the", "objects", "returned", "an", "error", "upon", "Wait", "invocation", "this", "error", "is", "returned", ".", "Otherwis...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/wait/group.go#L23-L27
train
algolia/algoliasearch-client-go
algolia/wait/group.go
Collect
func (a *Group) Collect(waitables ...Waitable) { a.Lock() a.waitables = append(a.waitables, waitables...) a.Unlock() }
go
func (a *Group) Collect(waitables ...Waitable) { a.Lock() a.waitables = append(a.waitables, waitables...) a.Unlock() }
[ "func", "(", "a", "*", "Group", ")", "Collect", "(", "waitables", "...", "Waitable", ")", "{", "a", ".", "Lock", "(", ")", "\n", "a", ".", "waitables", "=", "append", "(", "a", ".", "waitables", ",", "waitables", "...", ")", "\n", "a", ".", "Unlo...
// Collect holds references to the given `algolia.Waitable` objects in order to // wait for their completion once the `Wait` method will be invoked. Calling // `Collect` from multiple goroutines is safe.
[ "Collect", "holds", "references", "to", "the", "given", "algolia", ".", "Waitable", "objects", "in", "order", "to", "wait", "for", "their", "completion", "once", "the", "Wait", "method", "will", "be", "invoked", ".", "Calling", "Collect", "from", "multiple", ...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/wait/group.go#L32-L36
train
algolia/algoliasearch-client-go
algolia/wait/group.go
Wait
func (a *Group) Wait() error { a.Lock() defer a.Unlock() var wg sync.WaitGroup errs := make(chan error, len(a.waitables)) for _, w := range a.waitables { wg.Add(1) go func(wg *sync.WaitGroup, w Waitable, errs chan<- error) { errs <- w.Wait() wg.Done() }(&wg, w, errs) } wg.Wait() close(errs) a.waitables = nil for err := range errs { if err != nil { return err } } return nil }
go
func (a *Group) Wait() error { a.Lock() defer a.Unlock() var wg sync.WaitGroup errs := make(chan error, len(a.waitables)) for _, w := range a.waitables { wg.Add(1) go func(wg *sync.WaitGroup, w Waitable, errs chan<- error) { errs <- w.Wait() wg.Done() }(&wg, w, errs) } wg.Wait() close(errs) a.waitables = nil for err := range errs { if err != nil { return err } } return nil }
[ "func", "(", "a", "*", "Group", ")", "Wait", "(", ")", "error", "{", "a", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "Unlock", "(", ")", "\n", "var", "wg", "sync", ".", "WaitGroup", "\n", "errs", ":=", "make", "(", "chan", "error", ",", ...
// Wait blocks until all the collected `algolia.Waitable` objects have // completed. If one of the objects returned an error upon `Wait` invocation, // this error is returned. Otherwise, nil is returned. Calling `Wait` from // multiple goroutines is safe. // // Upon successful completion, the `Group` object can be reused directly to // collect other `algolia.Waitable` objects.
[ "Wait", "blocks", "until", "all", "the", "collected", "algolia", ".", "Waitable", "objects", "have", "completed", ".", "If", "one", "of", "the", "objects", "returned", "an", "error", "upon", "Wait", "invocation", "this", "error", "is", "returned", ".", "Othe...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/wait/group.go#L45-L71
train
algolia/algoliasearch-client-go
algolia/opt/sort_facet_values_by.go
SortFacetValuesByEqual
func SortFacetValuesByEqual(o1, o2 *SortFacetValuesByOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func SortFacetValuesByEqual(o1, o2 *SortFacetValuesByOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "SortFacetValuesByEqual", "(", "o1", ",", "o2", "*", "SortFacetValuesByOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", ...
// SortFacetValuesByEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "SortFacetValuesByEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the",...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/sort_facet_values_by.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/internal/opt/separators_to_index.go
ExtractSeparatorsToIndex
func ExtractSeparatorsToIndex(opts ...interface{}) *opt.SeparatorsToIndexOption { for _, o := range opts { if v, ok := o.(*opt.SeparatorsToIndexOption); ok { return v } } return nil }
go
func ExtractSeparatorsToIndex(opts ...interface{}) *opt.SeparatorsToIndexOption { for _, o := range opts { if v, ok := o.(*opt.SeparatorsToIndexOption); ok { return v } } return nil }
[ "func", "ExtractSeparatorsToIndex", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "SeparatorsToIndexOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "Separa...
// ExtractSeparatorsToIndex returns the first found SeparatorsToIndexOption from the // given variadic arguments or nil otherwise.
[ "ExtractSeparatorsToIndex", "returns", "the", "first", "found", "SeparatorsToIndexOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/separators_to_index.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/internal/opt/extra_headers.go
ExtractExtraHeaders
func ExtractExtraHeaders(opts ...interface{}) *opt.ExtraHeadersOption { merged := make(map[string]string) for _, o := range opts { if v, ok := o.(*opt.ExtraHeadersOption); ok { for key, value := range v.Get() { merged[key] = value } } } if len(merged) == 0 { return nil } return opt.ExtraHeaders(merged) }
go
func ExtractExtraHeaders(opts ...interface{}) *opt.ExtraHeadersOption { merged := make(map[string]string) for _, o := range opts { if v, ok := o.(*opt.ExtraHeadersOption); ok { for key, value := range v.Get() { merged[key] = value } } } if len(merged) == 0 { return nil } return opt.ExtraHeaders(merged) }
[ "func", "ExtractExtraHeaders", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "ExtraHeadersOption", "{", "merged", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for", "_", ",", "o", ":=", "range", "opts", "{", ...
// ExtractExtraHeaders returns the first found ExtraHeadersOption from the // given variadic arguments or nil otherwise. If multiple options are found, the // inner maps are merged.
[ "ExtractExtraHeaders", "returns", "the", "first", "found", "ExtraHeadersOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", ".", "If", "multiple", "options", "are", "found", "the", "inner", "maps", "are", "merged", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/extra_headers.go#L12-L28
train
algolia/algoliasearch-client-go
algolia/internal/opt/typo_tolerance.go
ExtractTypoTolerance
func ExtractTypoTolerance(opts ...interface{}) *opt.TypoToleranceOption { for _, o := range opts { if v, ok := o.(*opt.TypoToleranceOption); ok { return v } } return nil }
go
func ExtractTypoTolerance(opts ...interface{}) *opt.TypoToleranceOption { for _, o := range opts { if v, ok := o.(*opt.TypoToleranceOption); ok { return v } } return nil }
[ "func", "ExtractTypoTolerance", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "TypoToleranceOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "TypoToleranceO...
// ExtractTypoTolerance returns the first found TypoToleranceOption from the // given variadic arguments or nil otherwise.
[ "ExtractTypoTolerance", "returns", "the", "first", "found", "TypoToleranceOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/typo_tolerance.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/attributes_to_highlight.go
AttributesToHighlightEqual
func AttributesToHighlightEqual(o1, o2 *AttributesToHighlightOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func AttributesToHighlightEqual(o1, o2 *AttributesToHighlightOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "AttributesToHighlightEqual", "(", "o1", ",", "o2", "*", "AttributesToHighlightOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2",...
// AttributesToHighlightEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "AttributesToHighlightEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "t...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/attributes_to_highlight.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/search/client_keys.go
GetAPIKey
func (c *Client) GetAPIKey(keyID string, opts ...interface{}) (key Key, err error) { path := c.path("/keys/%s", keyID) err = c.transport.Request(&key, http.MethodGet, path, nil, call.Read, opts...) key.Value = keyID return }
go
func (c *Client) GetAPIKey(keyID string, opts ...interface{}) (key Key, err error) { path := c.path("/keys/%s", keyID) err = c.transport.Request(&key, http.MethodGet, path, nil, call.Read, opts...) key.Value = keyID return }
[ "func", "(", "c", "*", "Client", ")", "GetAPIKey", "(", "keyID", "string", ",", "opts", "...", "interface", "{", "}", ")", "(", "key", "Key", ",", "err", "error", ")", "{", "path", ":=", "c", ".", "path", "(", "\"/keys/%s\"", ",", "keyID", ")", "...
// GetAPIKey retrieves the API key identified by the given keyID.
[ "GetAPIKey", "retrieves", "the", "API", "key", "identified", "by", "the", "given", "keyID", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client_keys.go#L11-L16
train
algolia/algoliasearch-client-go
algolia/search/client_keys.go
AddAPIKey
func (c *Client) AddAPIKey(key Key, opts ...interface{}) (res CreateKeyRes, err error) { path := c.path("/keys") err = c.transport.Request(&res, http.MethodPost, path, key, call.Write, opts...) res.wait = c.waitKeyIsAvailable(res.Key) return }
go
func (c *Client) AddAPIKey(key Key, opts ...interface{}) (res CreateKeyRes, err error) { path := c.path("/keys") err = c.transport.Request(&res, http.MethodPost, path, key, call.Write, opts...) res.wait = c.waitKeyIsAvailable(res.Key) return }
[ "func", "(", "c", "*", "Client", ")", "AddAPIKey", "(", "key", "Key", ",", "opts", "...", "interface", "{", "}", ")", "(", "res", "CreateKeyRes", ",", "err", "error", ")", "{", "path", ":=", "c", ".", "path", "(", "\"/keys\"", ")", "\n", "err", "...
// AddAPIKey creates a new API key. Once created, the key can be referenced by // other methods via the Key field of the response which represents its keyID.
[ "AddAPIKey", "creates", "a", "new", "API", "key", ".", "Once", "created", "the", "key", "can", "be", "referenced", "by", "other", "methods", "via", "the", "Key", "field", "of", "the", "response", "which", "represents", "its", "keyID", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client_keys.go#L20-L25
train
algolia/algoliasearch-client-go
algolia/search/client_keys.go
UpdateAPIKey
func (c *Client) UpdateAPIKey(key Key, opts ...interface{}) (res UpdateKeyRes, err error) { if key.Value == "" { err = errs.ErrMissingKeyID return } path := c.path("/keys/%s", key.Value) err = c.transport.Request(&res, http.MethodPut, path, key, call.Write, opts...) res.wait = c.waitKeyHasChanged(key) return }
go
func (c *Client) UpdateAPIKey(key Key, opts ...interface{}) (res UpdateKeyRes, err error) { if key.Value == "" { err = errs.ErrMissingKeyID return } path := c.path("/keys/%s", key.Value) err = c.transport.Request(&res, http.MethodPut, path, key, call.Write, opts...) res.wait = c.waitKeyHasChanged(key) return }
[ "func", "(", "c", "*", "Client", ")", "UpdateAPIKey", "(", "key", "Key", ",", "opts", "...", "interface", "{", "}", ")", "(", "res", "UpdateKeyRes", ",", "err", "error", ")", "{", "if", "key", ".", "Value", "==", "\"\"", "{", "err", "=", "errs", ...
// UpdateAPIKey updates the API key identified by its Value field and updates // all its non-zero fields.
[ "UpdateAPIKey", "updates", "the", "API", "key", "identified", "by", "its", "Value", "field", "and", "updates", "all", "its", "non", "-", "zero", "fields", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client_keys.go#L29-L38
train
algolia/algoliasearch-client-go
algolia/search/client_keys.go
DeleteAPIKey
func (c *Client) DeleteAPIKey(keyID string, opts ...interface{}) (res DeleteKeyRes, err error) { path := c.path("/keys/%s", keyID) err = c.transport.Request(&res, http.MethodDelete, path, nil, call.Write, opts...) res.wait = c.waitKeyIsNotAvailable(keyID) return }
go
func (c *Client) DeleteAPIKey(keyID string, opts ...interface{}) (res DeleteKeyRes, err error) { path := c.path("/keys/%s", keyID) err = c.transport.Request(&res, http.MethodDelete, path, nil, call.Write, opts...) res.wait = c.waitKeyIsNotAvailable(keyID) return }
[ "func", "(", "c", "*", "Client", ")", "DeleteAPIKey", "(", "keyID", "string", ",", "opts", "...", "interface", "{", "}", ")", "(", "res", "DeleteKeyRes", ",", "err", "error", ")", "{", "path", ":=", "c", ".", "path", "(", "\"/keys/%s\"", ",", "keyID"...
// DeleteAPIKey deletes the API key for the given keyID. // // To restore a deleted key, you can use RestoreAPIKey with the same keyID.
[ "DeleteAPIKey", "deletes", "the", "API", "key", "for", "the", "given", "keyID", ".", "To", "restore", "a", "deleted", "key", "you", "can", "use", "RestoreAPIKey", "with", "the", "same", "keyID", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client_keys.go#L43-L48
train
algolia/algoliasearch-client-go
algolia/search/client_keys.go
RestoreAPIKey
func (c *Client) RestoreAPIKey(keyID string, opts ...interface{}) (res RestoreKeyRes, err error) { path := c.path("/keys/%s/restore", keyID) err = c.transport.Request(&res, http.MethodPost, path, nil, call.Write, opts...) res.wait = c.waitKeyIsAvailable(keyID) return }
go
func (c *Client) RestoreAPIKey(keyID string, opts ...interface{}) (res RestoreKeyRes, err error) { path := c.path("/keys/%s/restore", keyID) err = c.transport.Request(&res, http.MethodPost, path, nil, call.Write, opts...) res.wait = c.waitKeyIsAvailable(keyID) return }
[ "func", "(", "c", "*", "Client", ")", "RestoreAPIKey", "(", "keyID", "string", ",", "opts", "...", "interface", "{", "}", ")", "(", "res", "RestoreKeyRes", ",", "err", "error", ")", "{", "path", ":=", "c", ".", "path", "(", "\"/keys/%s/restore\"", ",",...
// RestoreAPIKey restores the API key for the given keyID if it ever existed.
[ "RestoreAPIKey", "restores", "the", "API", "key", "for", "the", "given", "keyID", "if", "it", "ever", "existed", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client_keys.go#L51-L56
train
algolia/algoliasearch-client-go
algolia/search/client_keys.go
ListAPIKeys
func (c *Client) ListAPIKeys(opts ...interface{}) (res ListAPIKeysRes, err error) { path := c.path("/keys") err = c.transport.Request(&res, http.MethodGet, path, nil, call.Read, opts...) return }
go
func (c *Client) ListAPIKeys(opts ...interface{}) (res ListAPIKeysRes, err error) { path := c.path("/keys") err = c.transport.Request(&res, http.MethodGet, path, nil, call.Read, opts...) return }
[ "func", "(", "c", "*", "Client", ")", "ListAPIKeys", "(", "opts", "...", "interface", "{", "}", ")", "(", "res", "ListAPIKeysRes", ",", "err", "error", ")", "{", "path", ":=", "c", ".", "path", "(", "\"/keys\"", ")", "\n", "err", "=", "c", ".", "...
// ListAPIKeys list all the API keys of the application.
[ "ListAPIKeys", "list", "all", "the", "API", "keys", "of", "the", "application", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client_keys.go#L59-L63
train
algolia/algoliasearch-client-go
algolia/opt/extra_headers.go
ExtraHeadersEqual
func ExtraHeadersEqual(o1, o2 *ExtraHeadersOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func ExtraHeadersEqual(o1, o2 *ExtraHeadersOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "ExtraHeadersEqual", "(", "o1", ",", "o2", "*", "ExtraHeadersOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal",...
// ExtraHeadersEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "ExtraHeadersEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "d...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/extra_headers.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/internal/opt/tag_filters.go
ExtractTagFilters
func ExtractTagFilters(opts ...interface{}) *opt.TagFiltersOption { for _, o := range opts { if v, ok := o.(*opt.TagFiltersOption); ok { return v } } return nil }
go
func ExtractTagFilters(opts ...interface{}) *opt.TagFiltersOption { for _, o := range opts { if v, ok := o.(*opt.TagFiltersOption); ok { return v } } return nil }
[ "func", "ExtractTagFilters", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "TagFiltersOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "TagFiltersOption", ...
// ExtractTagFilters returns the first found TagFiltersOption from the // given variadic arguments or nil otherwise.
[ "ExtractTagFilters", "returns", "the", "first", "found", "TagFiltersOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/tag_filters.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/internal/opt/around_radius.go
ExtractAroundRadius
func ExtractAroundRadius(opts ...interface{}) *opt.AroundRadiusOption { for _, o := range opts { if v, ok := o.(*opt.AroundRadiusOption); ok { return v } } return nil }
go
func ExtractAroundRadius(opts ...interface{}) *opt.AroundRadiusOption { for _, o := range opts { if v, ok := o.(*opt.AroundRadiusOption); ok { return v } } return nil }
[ "func", "ExtractAroundRadius", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "AroundRadiusOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "AroundRadiusOpti...
// ExtractAroundRadius returns the first found AroundRadiusOption from the // given variadic arguments or nil otherwise.
[ "ExtractAroundRadius", "returns", "the", "first", "found", "AroundRadiusOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/around_radius.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/unretrievable_attributes.go
UnretrievableAttributesEqual
func UnretrievableAttributesEqual(o1, o2 *UnretrievableAttributesOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func UnretrievableAttributesEqual(o1, o2 *UnretrievableAttributesOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "UnretrievableAttributesEqual", "(", "o1", ",", "o2", "*", "UnretrievableAttributesOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "...
// UnretrievableAttributesEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "UnretrievableAttributesEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", ...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/unretrievable_attributes.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/search/index_synonyms.go
GetSynonym
func (i *Index) GetSynonym(objectID string, opts ...interface{}) (synonym Synonym, err error) { if objectID == "" { err = errs.ErrMissingObjectID return } var syn rawSynonym path := i.path("/synonyms/%s", url.QueryEscape(objectID)) err = i.transport.Request(&syn, http.MethodGet, path, nil, call.Read, opts...) if err == nil { synonym = syn.impl } return }
go
func (i *Index) GetSynonym(objectID string, opts ...interface{}) (synonym Synonym, err error) { if objectID == "" { err = errs.ErrMissingObjectID return } var syn rawSynonym path := i.path("/synonyms/%s", url.QueryEscape(objectID)) err = i.transport.Request(&syn, http.MethodGet, path, nil, call.Read, opts...) if err == nil { synonym = syn.impl } return }
[ "func", "(", "i", "*", "Index", ")", "GetSynonym", "(", "objectID", "string", ",", "opts", "...", "interface", "{", "}", ")", "(", "synonym", "Synonym", ",", "err", "error", ")", "{", "if", "objectID", "==", "\"\"", "{", "err", "=", "errs", ".", "E...
// GetSynonym retrieves the synonym identified by the given objectID.
[ "GetSynonym", "retrieves", "the", "synonym", "identified", "by", "the", "given", "objectID", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/index_synonyms.go#L15-L28
train
algolia/algoliasearch-client-go
algolia/search/index_synonyms.go
SaveSynonym
func (i *Index) SaveSynonym(synonym Synonym, opts ...interface{}) (res UpdateTaskRes, err error) { if synonym.ObjectID() == "" { err = errs.ErrMissingObjectID res.wait = noWait return } path := i.path("/synonyms/%s", url.QueryEscape(synonym.ObjectID())) err = i.transport.Request(&res, http.MethodPut, path, synonym, call.Write, opts...) res.wait = i.WaitTask return }
go
func (i *Index) SaveSynonym(synonym Synonym, opts ...interface{}) (res UpdateTaskRes, err error) { if synonym.ObjectID() == "" { err = errs.ErrMissingObjectID res.wait = noWait return } path := i.path("/synonyms/%s", url.QueryEscape(synonym.ObjectID())) err = i.transport.Request(&res, http.MethodPut, path, synonym, call.Write, opts...) res.wait = i.WaitTask return }
[ "func", "(", "i", "*", "Index", ")", "SaveSynonym", "(", "synonym", "Synonym", ",", "opts", "...", "interface", "{", "}", ")", "(", "res", "UpdateTaskRes", ",", "err", "error", ")", "{", "if", "synonym", ".", "ObjectID", "(", ")", "==", "\"\"", "{", ...
// SaveSynonym saves the given synonym.
[ "SaveSynonym", "saves", "the", "given", "synonym", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/index_synonyms.go#L31-L42
train
algolia/algoliasearch-client-go
algolia/search/index_synonyms.go
SaveSynonyms
func (i *Index) SaveSynonyms(synonyms []Synonym, opts ...interface{}) (res UpdateTaskRes, err error) { if replaceExistingSynonyms := iopt.ExtractReplaceExistingSynonyms(opts...); replaceExistingSynonyms != nil { opts = opt.InsertExtraURLParam(opts, "replaceExistingSynonyms", replaceExistingSynonyms.Get()) } path := i.path("/synonyms/batch") err = i.transport.Request(&res, http.MethodPost, path, synonyms, call.Write, opts...) res.wait = i.WaitTask return }
go
func (i *Index) SaveSynonyms(synonyms []Synonym, opts ...interface{}) (res UpdateTaskRes, err error) { if replaceExistingSynonyms := iopt.ExtractReplaceExistingSynonyms(opts...); replaceExistingSynonyms != nil { opts = opt.InsertExtraURLParam(opts, "replaceExistingSynonyms", replaceExistingSynonyms.Get()) } path := i.path("/synonyms/batch") err = i.transport.Request(&res, http.MethodPost, path, synonyms, call.Write, opts...) res.wait = i.WaitTask return }
[ "func", "(", "i", "*", "Index", ")", "SaveSynonyms", "(", "synonyms", "[", "]", "Synonym", ",", "opts", "...", "interface", "{", "}", ")", "(", "res", "UpdateTaskRes", ",", "err", "error", ")", "{", "if", "replaceExistingSynonyms", ":=", "iopt", ".", "...
// SaveSynonym saves the given synonyms. // // Unlike SaveObjects, this method does not batch the given synonyms i.e. all synonyms // are sent in a single call.
[ "SaveSynonym", "saves", "the", "given", "synonyms", ".", "Unlike", "SaveObjects", "this", "method", "does", "not", "batch", "the", "given", "synonyms", "i", ".", "e", ".", "all", "synonyms", "are", "sent", "in", "a", "single", "call", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/index_synonyms.go#L48-L56
train
algolia/algoliasearch-client-go
algolia/search/index_synonyms.go
ReplaceAllSynonyms
func (i *Index) ReplaceAllSynonyms(synonyms []Synonym, opts ...interface{}) (UpdateTaskRes, error) { opts = opt.InsertOrReplaceOption(opts, opt.ReplaceExistingSynonyms(true)) return i.SaveSynonyms(synonyms, opts...) }
go
func (i *Index) ReplaceAllSynonyms(synonyms []Synonym, opts ...interface{}) (UpdateTaskRes, error) { opts = opt.InsertOrReplaceOption(opts, opt.ReplaceExistingSynonyms(true)) return i.SaveSynonyms(synonyms, opts...) }
[ "func", "(", "i", "*", "Index", ")", "ReplaceAllSynonyms", "(", "synonyms", "[", "]", "Synonym", ",", "opts", "...", "interface", "{", "}", ")", "(", "UpdateTaskRes", ",", "error", ")", "{", "opts", "=", "opt", ".", "InsertOrReplaceOption", "(", "opts", ...
// ReplaceAllSynonyms replaces any existing synonyms with the given ones.
[ "ReplaceAllSynonyms", "replaces", "any", "existing", "synonyms", "with", "the", "given", "ones", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/index_synonyms.go#L91-L94
train
algolia/algoliasearch-client-go
algolia/search/index_synonyms.go
BrowseSynonyms
func (i *Index) BrowseSynonyms(opts ...interface{}) (*SynonymIterator, error) { opts = opt.InsertOrReplaceOption(opts, opt.HitsPerPage(1000)) res, err := i.SearchSynonyms("", opts...) if err != nil { return nil, fmt.Errorf("cannot browse synonyms: search failed: %v", err) } synonyms, err := res.Synonyms() if err != nil { return nil, fmt.Errorf("cannot browse synonyms: cannot decode synonyms: %v", err) } return newSynonymIterator(synonyms), nil }
go
func (i *Index) BrowseSynonyms(opts ...interface{}) (*SynonymIterator, error) { opts = opt.InsertOrReplaceOption(opts, opt.HitsPerPage(1000)) res, err := i.SearchSynonyms("", opts...) if err != nil { return nil, fmt.Errorf("cannot browse synonyms: search failed: %v", err) } synonyms, err := res.Synonyms() if err != nil { return nil, fmt.Errorf("cannot browse synonyms: cannot decode synonyms: %v", err) } return newSynonymIterator(synonyms), nil }
[ "func", "(", "i", "*", "Index", ")", "BrowseSynonyms", "(", "opts", "...", "interface", "{", "}", ")", "(", "*", "SynonymIterator", ",", "error", ")", "{", "opts", "=", "opt", ".", "InsertOrReplaceOption", "(", "opts", ",", "opt", ".", "HitsPerPage", "...
// BrowseSynonyms returns an iterator which will retrieve synonyms one by one from the // index.
[ "BrowseSynonyms", "returns", "an", "iterator", "which", "will", "retrieve", "synonyms", "one", "by", "one", "from", "the", "index", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/index_synonyms.go#L98-L109
train
algolia/algoliasearch-client-go
algolia/search/client.go
NewClient
func NewClient(appID, apiKey string) *Client { return NewClientWithConfig( Configuration{ AppID: appID, APIKey: apiKey, }, ) }
go
func NewClient(appID, apiKey string) *Client { return NewClientWithConfig( Configuration{ AppID: appID, APIKey: apiKey, }, ) }
[ "func", "NewClient", "(", "appID", ",", "apiKey", "string", ")", "*", "Client", "{", "return", "NewClientWithConfig", "(", "Configuration", "{", "AppID", ":", "appID", ",", "APIKey", ":", "apiKey", ",", "}", ",", ")", "\n", "}" ]
// NewClient instantiates a new client able to interact with the Algolia // Search API on multiple indices which belong to the same Algolia application.
[ "NewClient", "instantiates", "a", "new", "client", "able", "to", "interact", "with", "the", "Algolia", "Search", "API", "on", "multiple", "indices", "which", "belong", "to", "the", "same", "Algolia", "application", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client.go#L29-L36
train
algolia/algoliasearch-client-go
algolia/search/client.go
NewClientWithConfig
func NewClientWithConfig(config Configuration) *Client { var ( hosts []*transport.StatefulHost maxBatchSize int ) if len(config.Hosts) == 0 { hosts = defaultHosts(config.AppID) } else { for _, h := range config.Hosts { hosts = append(hosts, transport.NewStatefulHost(h, call.IsReadWrite)) } } if config.MaxBatchSize == 0 { maxBatchSize = DefaultMaxBatchSize } else { maxBatchSize = config.MaxBatchSize } return &Client{ appID: config.AppID, maxBatchSize: maxBatchSize, transport: transport.New( hosts, config.Requester, config.AppID, config.APIKey, config.ReadTimeout, config.WriteTimeout, config.Headers, config.ExtraUserAgent, ), } }
go
func NewClientWithConfig(config Configuration) *Client { var ( hosts []*transport.StatefulHost maxBatchSize int ) if len(config.Hosts) == 0 { hosts = defaultHosts(config.AppID) } else { for _, h := range config.Hosts { hosts = append(hosts, transport.NewStatefulHost(h, call.IsReadWrite)) } } if config.MaxBatchSize == 0 { maxBatchSize = DefaultMaxBatchSize } else { maxBatchSize = config.MaxBatchSize } return &Client{ appID: config.AppID, maxBatchSize: maxBatchSize, transport: transport.New( hosts, config.Requester, config.AppID, config.APIKey, config.ReadTimeout, config.WriteTimeout, config.Headers, config.ExtraUserAgent, ), } }
[ "func", "NewClientWithConfig", "(", "config", "Configuration", ")", "*", "Client", "{", "var", "(", "hosts", "[", "]", "*", "transport", ".", "StatefulHost", "\n", "maxBatchSize", "int", "\n", ")", "\n", "if", "len", "(", "config", ".", "Hosts", ")", "==...
// NewClientWithConfig instantiates a new client able to interact with the // Algolia Search API on multiple indices which belong to the same Algolia // application.
[ "NewClientWithConfig", "instantiates", "a", "new", "client", "able", "to", "interact", "with", "the", "Algolia", "Search", "API", "on", "multiple", "indices", "which", "belong", "to", "the", "same", "Algolia", "application", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client.go#L41-L75
train
algolia/algoliasearch-client-go
algolia/search/client.go
ListIndexes
func (c *Client) ListIndexes(opts ...interface{}) (res ListIndexesRes, err error) { path := c.path("/indexes") err = c.transport.Request(&res, http.MethodGet, path, nil, call.Read, opts...) return }
go
func (c *Client) ListIndexes(opts ...interface{}) (res ListIndexesRes, err error) { path := c.path("/indexes") err = c.transport.Request(&res, http.MethodGet, path, nil, call.Read, opts...) return }
[ "func", "(", "c", "*", "Client", ")", "ListIndexes", "(", "opts", "...", "interface", "{", "}", ")", "(", "res", "ListIndexesRes", ",", "err", "error", ")", "{", "path", ":=", "c", ".", "path", "(", "\"/indexes\"", ")", "\n", "err", "=", "c", ".", ...
// ListIndexes lists the indices of the Algolia application. The response is // paginated and hence, may not return all indices in a single call. Multiple // calls may be necessary to retrieve all indices.
[ "ListIndexes", "lists", "the", "indices", "of", "the", "Algolia", "application", ".", "The", "response", "is", "paginated", "and", "hence", "may", "not", "return", "all", "indices", "in", "a", "single", "call", ".", "Multiple", "calls", "may", "be", "necessa...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client.go#L90-L94
train
algolia/algoliasearch-client-go
algolia/search/client.go
GetLogs
func (c *Client) GetLogs(opts ...interface{}) (res GetLogsRes, err error) { if offset := iopt.ExtractOffset(opts...); offset != nil { opts = opt.InsertExtraURLParam(opts, "offset", offset.Get()) } if length := iopt.ExtractLength(opts...); length != nil { opts = opt.InsertExtraURLParam(opts, "length", length.Get()) } if t := iopt.ExtractType(opts...); t != nil { opts = opt.InsertExtraURLParam(opts, "type", t.Get()) } if indexName := iopt.ExtractIndexName(opts...); indexName != nil { opts = opt.InsertExtraURLParam(opts, "indexName", indexName.Get()) } path := c.path("/logs") err = c.transport.Request(&res, http.MethodGet, path, nil, call.Read, opts...) return }
go
func (c *Client) GetLogs(opts ...interface{}) (res GetLogsRes, err error) { if offset := iopt.ExtractOffset(opts...); offset != nil { opts = opt.InsertExtraURLParam(opts, "offset", offset.Get()) } if length := iopt.ExtractLength(opts...); length != nil { opts = opt.InsertExtraURLParam(opts, "length", length.Get()) } if t := iopt.ExtractType(opts...); t != nil { opts = opt.InsertExtraURLParam(opts, "type", t.Get()) } if indexName := iopt.ExtractIndexName(opts...); indexName != nil { opts = opt.InsertExtraURLParam(opts, "indexName", indexName.Get()) } path := c.path("/logs") err = c.transport.Request(&res, http.MethodGet, path, nil, call.Read, opts...) return }
[ "func", "(", "c", "*", "Client", ")", "GetLogs", "(", "opts", "...", "interface", "{", "}", ")", "(", "res", "GetLogsRes", ",", "err", "error", ")", "{", "if", "offset", ":=", "iopt", ".", "ExtractOffset", "(", "opts", "...", ")", ";", "offset", "!...
// GetLogs returns the most recent information logs of the Algolia application.
[ "GetLogs", "returns", "the", "most", "recent", "information", "logs", "of", "the", "Algolia", "application", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client.go#L97-L113
train
algolia/algoliasearch-client-go
algolia/search/client.go
CustomRequest
func (c *Client) CustomRequest( res interface{}, method string, path string, body interface{}, k call.Kind, opts ...interface{}, ) error { return c.transport.Request(&res, method, path, body, k, opts...) }
go
func (c *Client) CustomRequest( res interface{}, method string, path string, body interface{}, k call.Kind, opts ...interface{}, ) error { return c.transport.Request(&res, method, path, body, k, opts...) }
[ "func", "(", "c", "*", "Client", ")", "CustomRequest", "(", "res", "interface", "{", "}", ",", "method", "string", ",", "path", "string", ",", "body", "interface", "{", "}", ",", "k", "call", ".", "Kind", ",", "opts", "...", "interface", "{", "}", ...
// CustomRequest is a low-level function which build a request from the given // parameters and send it through the requester, making use of the underlying // retry strategy.
[ "CustomRequest", "is", "a", "low", "-", "level", "function", "which", "build", "a", "request", "from", "the", "given", "parameters", "and", "send", "it", "through", "the", "requester", "making", "use", "of", "the", "underlying", "retry", "strategy", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/search/client.go#L118-L127
train
algolia/algoliasearch-client-go
algolia/internal/opt/numeric_attributes_for_filtering.go
ExtractNumericAttributesForFiltering
func ExtractNumericAttributesForFiltering(opts ...interface{}) *opt.NumericAttributesForFilteringOption { for _, o := range opts { if v, ok := o.(*opt.NumericAttributesForFilteringOption); ok { return v } } return nil }
go
func ExtractNumericAttributesForFiltering(opts ...interface{}) *opt.NumericAttributesForFilteringOption { for _, o := range opts { if v, ok := o.(*opt.NumericAttributesForFilteringOption); ok { return v } } return nil }
[ "func", "ExtractNumericAttributesForFiltering", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "NumericAttributesForFilteringOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", ...
// ExtractNumericAttributesForFiltering returns the first found NumericAttributesForFilteringOption from the // given variadic arguments or nil otherwise.
[ "ExtractNumericAttributesForFiltering", "returns", "the", "first", "found", "NumericAttributesForFilteringOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/numeric_attributes_for_filtering.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/internal/opt/keep_diacritics_on_characters.go
ExtractKeepDiacriticsOnCharacters
func ExtractKeepDiacriticsOnCharacters(opts ...interface{}) *opt.KeepDiacriticsOnCharactersOption { for _, o := range opts { if v, ok := o.(*opt.KeepDiacriticsOnCharactersOption); ok { return v } } return nil }
go
func ExtractKeepDiacriticsOnCharacters(opts ...interface{}) *opt.KeepDiacriticsOnCharactersOption { for _, o := range opts { if v, ok := o.(*opt.KeepDiacriticsOnCharactersOption); ok { return v } } return nil }
[ "func", "ExtractKeepDiacriticsOnCharacters", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "KeepDiacriticsOnCharactersOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt"...
// ExtractKeepDiacriticsOnCharacters returns the first found KeepDiacriticsOnCharactersOption from the // given variadic arguments or nil otherwise.
[ "ExtractKeepDiacriticsOnCharacters", "returns", "the", "first", "found", "KeepDiacriticsOnCharactersOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/keep_diacritics_on_characters.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/disable_typo_tolerance_on_attributes.go
DisableTypoToleranceOnAttributesEqual
func DisableTypoToleranceOnAttributesEqual(o1, o2 *DisableTypoToleranceOnAttributesOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func DisableTypoToleranceOnAttributesEqual(o1, o2 *DisableTypoToleranceOnAttributesOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "DisableTypoToleranceOnAttributesEqual", "(", "o1", ",", "o2", "*", "DisableTypoToleranceOnAttributesOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{...
// DisableTypoToleranceOnAttributesEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "DisableTypoToleranceOnAttributesEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", ...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/disable_typo_tolerance_on_attributes.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/internal/opt/max_facet_hits.go
ExtractMaxFacetHits
func ExtractMaxFacetHits(opts ...interface{}) *opt.MaxFacetHitsOption { for _, o := range opts { if v, ok := o.(*opt.MaxFacetHitsOption); ok { return v } } return nil }
go
func ExtractMaxFacetHits(opts ...interface{}) *opt.MaxFacetHitsOption { for _, o := range opts { if v, ok := o.(*opt.MaxFacetHitsOption); ok { return v } } return nil }
[ "func", "ExtractMaxFacetHits", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "MaxFacetHitsOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "MaxFacetHitsOpti...
// ExtractMaxFacetHits returns the first found MaxFacetHitsOption from the // given variadic arguments or nil otherwise.
[ "ExtractMaxFacetHits", "returns", "the", "first", "found", "MaxFacetHitsOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/max_facet_hits.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/internal/opt/highlight_pre_tag.go
ExtractHighlightPreTag
func ExtractHighlightPreTag(opts ...interface{}) *opt.HighlightPreTagOption { for _, o := range opts { if v, ok := o.(*opt.HighlightPreTagOption); ok { return v } } return nil }
go
func ExtractHighlightPreTag(opts ...interface{}) *opt.HighlightPreTagOption { for _, o := range opts { if v, ok := o.(*opt.HighlightPreTagOption); ok { return v } } return nil }
[ "func", "ExtractHighlightPreTag", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "HighlightPreTagOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "HighlightP...
// ExtractHighlightPreTag returns the first found HighlightPreTagOption from the // given variadic arguments or nil otherwise.
[ "ExtractHighlightPreTag", "returns", "the", "first", "found", "HighlightPreTagOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/highlight_pre_tag.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/internal/opt/restrict_sources.go
ExtractRestrictSources
func ExtractRestrictSources(opts ...interface{}) *opt.RestrictSourcesOption { for _, o := range opts { if v, ok := o.(*opt.RestrictSourcesOption); ok { return v } } return nil }
go
func ExtractRestrictSources(opts ...interface{}) *opt.RestrictSourcesOption { for _, o := range opts { if v, ok := o.(*opt.RestrictSourcesOption); ok { return v } } return nil }
[ "func", "ExtractRestrictSources", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "RestrictSourcesOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "RestrictSo...
// ExtractRestrictSources returns the first found RestrictSourcesOption from the // given variadic arguments or nil otherwise.
[ "ExtractRestrictSources", "returns", "the", "first", "found", "RestrictSourcesOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/restrict_sources.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/separators_to_index.go
SeparatorsToIndexEqual
func SeparatorsToIndexEqual(o1, o2 *SeparatorsToIndexOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func SeparatorsToIndexEqual(o1, o2 *SeparatorsToIndexOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "SeparatorsToIndexEqual", "(", "o1", ",", "o2", "*", "SeparatorsToIndexOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", ...
// SeparatorsToIndexEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "SeparatorsToIndexEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the",...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/separators_to_index.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/internal/opt/anchoring.go
ExtractAnchoring
func ExtractAnchoring(opts ...interface{}) *opt.AnchoringOption { for _, o := range opts { if v, ok := o.(*opt.AnchoringOption); ok { return v } } return nil }
go
func ExtractAnchoring(opts ...interface{}) *opt.AnchoringOption { for _, o := range opts { if v, ok := o.(*opt.AnchoringOption); ok { return v } } return nil }
[ "func", "ExtractAnchoring", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "AnchoringOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "AnchoringOption", ")...
// ExtractAnchoring returns the first found AnchoringOption from the // given variadic arguments or nil otherwise.
[ "ExtractAnchoring", "returns", "the", "first", "found", "AnchoringOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/anchoring.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/restrict_highlight_and_snippet_arrays.go
RestrictHighlightAndSnippetArraysEqual
func RestrictHighlightAndSnippetArraysEqual(o1, o2 *RestrictHighlightAndSnippetArraysOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func RestrictHighlightAndSnippetArraysEqual(o1, o2 *RestrictHighlightAndSnippetArraysOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "RestrictHighlightAndSnippetArraysEqual", "(", "o1", ",", "o2", "*", "RestrictHighlightAndSnippetArraysOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", ...
// RestrictHighlightAndSnippetArraysEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "RestrictHighlightAndSnippetArraysEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", ...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/restrict_highlight_and_snippet_arrays.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/internal/opt/alternatives_as_exact.go
ExtractAlternativesAsExact
func ExtractAlternativesAsExact(opts ...interface{}) *opt.AlternativesAsExactOption { for _, o := range opts { if v, ok := o.(*opt.AlternativesAsExactOption); ok { return v } } return nil }
go
func ExtractAlternativesAsExact(opts ...interface{}) *opt.AlternativesAsExactOption { for _, o := range opts { if v, ok := o.(*opt.AlternativesAsExactOption); ok { return v } } return nil }
[ "func", "ExtractAlternativesAsExact", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "AlternativesAsExactOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "Al...
// ExtractAlternativesAsExact returns the first found AlternativesAsExactOption from the // given variadic arguments or nil otherwise.
[ "ExtractAlternativesAsExact", "returns", "the", "first", "found", "AlternativesAsExactOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/alternatives_as_exact.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/internal/opt/snippet_ellipsis_text.go
ExtractSnippetEllipsisText
func ExtractSnippetEllipsisText(opts ...interface{}) *opt.SnippetEllipsisTextOption { for _, o := range opts { if v, ok := o.(*opt.SnippetEllipsisTextOption); ok { return v } } return nil }
go
func ExtractSnippetEllipsisText(opts ...interface{}) *opt.SnippetEllipsisTextOption { for _, o := range opts { if v, ok := o.(*opt.SnippetEllipsisTextOption); ok { return v } } return nil }
[ "func", "ExtractSnippetEllipsisText", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "SnippetEllipsisTextOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "Sn...
// ExtractSnippetEllipsisText returns the first found SnippetEllipsisTextOption from the // given variadic arguments or nil otherwise.
[ "ExtractSnippetEllipsisText", "returns", "the", "first", "found", "SnippetEllipsisTextOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/snippet_ellipsis_text.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/internal/opt/response_fields.go
ExtractResponseFields
func ExtractResponseFields(opts ...interface{}) *opt.ResponseFieldsOption { for _, o := range opts { if v, ok := o.(*opt.ResponseFieldsOption); ok { return v } } return nil }
go
func ExtractResponseFields(opts ...interface{}) *opt.ResponseFieldsOption { for _, o := range opts { if v, ok := o.(*opt.ResponseFieldsOption); ok { return v } } return nil }
[ "func", "ExtractResponseFields", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "ResponseFieldsOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "ResponseFiel...
// ExtractResponseFields returns the first found ResponseFieldsOption from the // given variadic arguments or nil otherwise.
[ "ExtractResponseFields", "returns", "the", "first", "found", "ResponseFieldsOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/response_fields.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/offset.go
OffsetEqual
func OffsetEqual(o1, o2 *OffsetOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func OffsetEqual(o1, o2 *OffsetOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "OffsetEqual", "(", "o1", ",", "o2", "*", "OffsetOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal", "(", "o...
// OffsetEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "OffsetEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "default...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/offset.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/internal/opt/disable_typo_tolerance_on_attributes.go
ExtractDisableTypoToleranceOnAttributes
func ExtractDisableTypoToleranceOnAttributes(opts ...interface{}) *opt.DisableTypoToleranceOnAttributesOption { for _, o := range opts { if v, ok := o.(*opt.DisableTypoToleranceOnAttributesOption); ok { return v } } return nil }
go
func ExtractDisableTypoToleranceOnAttributes(opts ...interface{}) *opt.DisableTypoToleranceOnAttributesOption { for _, o := range opts { if v, ok := o.(*opt.DisableTypoToleranceOnAttributesOption); ok { return v } } return nil }
[ "func", "ExtractDisableTypoToleranceOnAttributes", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "DisableTypoToleranceOnAttributesOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", ...
// ExtractDisableTypoToleranceOnAttributes returns the first found DisableTypoToleranceOnAttributesOption from the // given variadic arguments or nil otherwise.
[ "ExtractDisableTypoToleranceOnAttributes", "returns", "the", "first", "found", "DisableTypoToleranceOnAttributesOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/disable_typo_tolerance_on_attributes.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/query_type.go
QueryTypeEqual
func QueryTypeEqual(o1, o2 *QueryTypeOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func QueryTypeEqual(o1, o2 *QueryTypeOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "QueryTypeEqual", "(", "o1", ",", "o2", "*", "QueryTypeOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal", "("...
// QueryTypeEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "QueryTypeEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "defa...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/query_type.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/internal/opt/restrict_indices.go
ExtractRestrictIndices
func ExtractRestrictIndices(opts ...interface{}) *opt.RestrictIndicesOption { for _, o := range opts { if v, ok := o.(*opt.RestrictIndicesOption); ok { return v } } return nil }
go
func ExtractRestrictIndices(opts ...interface{}) *opt.RestrictIndicesOption { for _, o := range opts { if v, ok := o.(*opt.RestrictIndicesOption); ok { return v } } return nil }
[ "func", "ExtractRestrictIndices", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "RestrictIndicesOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "RestrictIn...
// ExtractRestrictIndices returns the first found RestrictIndicesOption from the // given variadic arguments or nil otherwise.
[ "ExtractRestrictIndices", "returns", "the", "first", "found", "RestrictIndicesOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/restrict_indices.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/inside_polygon.go
MarshalJSON
func (o InsidePolygonOption) MarshalJSON() ([]byte, error) { if o.coordinates != "" { return json.Marshal(o.coordinates) } return json.Marshal(o.polygons) }
go
func (o InsidePolygonOption) MarshalJSON() ([]byte, error) { if o.coordinates != "" { return json.Marshal(o.coordinates) } return json.Marshal(o.polygons) }
[ "func", "(", "o", "InsidePolygonOption", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "o", ".", "coordinates", "!=", "\"\"", "{", "return", "json", ".", "Marshal", "(", "o", ".", "coordinates", ")", "\n", "}", ...
// MarshalJSON implements the json.Marshaler interface for // InsidePolygonOption.
[ "MarshalJSON", "implements", "the", "json", ".", "Marshaler", "interface", "for", "InsidePolygonOption", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/inside_polygon.go#L39-L44
train
algolia/algoliasearch-client-go
algolia/opt/inside_polygon.go
UnmarshalJSON
func (o *InsidePolygonOption) UnmarshalJSON(data []byte) error { if string(data) == "null" { return nil } var polygons [][]float64 if err := json.Unmarshal(data, &polygons); err == nil { o.polygons = polygons return nil } var coordinates string if err := json.Unmarshal(data, &coordinates); err == nil { o.coordinates = coordinates return nil } return errs.ErrJSONDecode(data, "InsidePolygon") }
go
func (o *InsidePolygonOption) UnmarshalJSON(data []byte) error { if string(data) == "null" { return nil } var polygons [][]float64 if err := json.Unmarshal(data, &polygons); err == nil { o.polygons = polygons return nil } var coordinates string if err := json.Unmarshal(data, &coordinates); err == nil { o.coordinates = coordinates return nil } return errs.ErrJSONDecode(data, "InsidePolygon") }
[ "func", "(", "o", "*", "InsidePolygonOption", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "string", "(", "data", ")", "==", "\"null\"", "{", "return", "nil", "\n", "}", "\n", "var", "polygons", "[", "]", "[", "]", ...
// UnmarshalJSON implements the json.Unmarshaler interface for // InsidePolygonOption.
[ "UnmarshalJSON", "implements", "the", "json", ".", "Unmarshaler", "interface", "for", "InsidePolygonOption", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/inside_polygon.go#L48-L66
train
algolia/algoliasearch-client-go
algolia/opt/inside_polygon.go
InsidePolygonEqual
func InsidePolygonEqual(o1, o2 *InsidePolygonOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func InsidePolygonEqual(o1, o2 *InsidePolygonOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "InsidePolygonEqual", "(", "o1", ",", "o2", "*", "InsidePolygonOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal...
// InsidePolygonEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "InsidePolygonEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/inside_polygon.go#L81-L89
train
algolia/algoliasearch-client-go
algolia/opt/advanced_syntax.go
AdvancedSyntaxEqual
func AdvancedSyntaxEqual(o1, o2 *AdvancedSyntaxOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func AdvancedSyntaxEqual(o1, o2 *AdvancedSyntaxOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "AdvancedSyntaxEqual", "(", "o1", ",", "o2", "*", "AdvancedSyntaxOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equ...
// AdvancedSyntaxEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "AdvancedSyntaxEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", ...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/advanced_syntax.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/internal/opt/pagination_limited_to.go
ExtractPaginationLimitedTo
func ExtractPaginationLimitedTo(opts ...interface{}) *opt.PaginationLimitedToOption { for _, o := range opts { if v, ok := o.(*opt.PaginationLimitedToOption); ok { return v } } return nil }
go
func ExtractPaginationLimitedTo(opts ...interface{}) *opt.PaginationLimitedToOption { for _, o := range opts { if v, ok := o.(*opt.PaginationLimitedToOption); ok { return v } } return nil }
[ "func", "ExtractPaginationLimitedTo", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "PaginationLimitedToOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "Pa...
// ExtractPaginationLimitedTo returns the first found PaginationLimitedToOption from the // given variadic arguments or nil otherwise.
[ "ExtractPaginationLimitedTo", "returns", "the", "first", "found", "PaginationLimitedToOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/pagination_limited_to.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/internal/opt/min_word_sizefor2_typos.go
ExtractMinWordSizefor2Typos
func ExtractMinWordSizefor2Typos(opts ...interface{}) *opt.MinWordSizefor2TyposOption { for _, o := range opts { if v, ok := o.(*opt.MinWordSizefor2TyposOption); ok { return v } } return nil }
go
func ExtractMinWordSizefor2Typos(opts ...interface{}) *opt.MinWordSizefor2TyposOption { for _, o := range opts { if v, ok := o.(*opt.MinWordSizefor2TyposOption); ok { return v } } return nil }
[ "func", "ExtractMinWordSizefor2Typos", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "MinWordSizefor2TyposOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "...
// ExtractMinWordSizefor2Typos returns the first found MinWordSizefor2TyposOption from the // given variadic arguments or nil otherwise.
[ "ExtractMinWordSizefor2Typos", "returns", "the", "first", "found", "MinWordSizefor2TyposOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/min_word_sizefor2_typos.go#L11-L18
train
algolia/algoliasearch-client-go
algolia/opt/highlight_pre_tag.go
HighlightPreTagEqual
func HighlightPreTagEqual(o1, o2 *HighlightPreTagOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func HighlightPreTagEqual(o1, o2 *HighlightPreTagOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "HighlightPreTagEqual", "(", "o1", ",", "o2", "*", "HighlightPreTagOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "E...
// HighlightPreTagEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "HighlightPreTagEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", ...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/highlight_pre_tag.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/opt/min_word_sizefor2_typos.go
MinWordSizefor2TyposEqual
func MinWordSizefor2TyposEqual(o1, o2 *MinWordSizefor2TyposOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func MinWordSizefor2TyposEqual(o1, o2 *MinWordSizefor2TyposOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "MinWordSizefor2TyposEqual", "(", "o1", ",", "o2", "*", "MinWordSizefor2TyposOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ...
// MinWordSizefor2TyposEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "MinWordSizefor2TyposEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "th...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/min_word_sizefor2_typos.go#L55-L63
train
algolia/algoliasearch-client-go
algolia/opt/analytics_tags.go
AnalyticsTagsEqual
func AnalyticsTagsEqual(o1, o2 *AnalyticsTagsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func AnalyticsTagsEqual(o1, o2 *AnalyticsTagsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "AnalyticsTagsEqual", "(", "o1", ",", "o2", "*", "AnalyticsTagsOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "return", "o2", ".", "Equal...
// AnalyticsTagsEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "AnalyticsTagsEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to", "the", "...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/analytics_tags.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/opt/disable_typo_tolerance_on_words.go
DisableTypoToleranceOnWordsEqual
func DisableTypoToleranceOnWordsEqual(o1, o2 *DisableTypoToleranceOnWordsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
go
func DisableTypoToleranceOnWordsEqual(o1, o2 *DisableTypoToleranceOnWordsOption) bool { if o1 != nil { return o1.Equal(o2) } if o2 != nil { return o2.Equal(o1) } return true }
[ "func", "DisableTypoToleranceOnWordsEqual", "(", "o1", ",", "o2", "*", "DisableTypoToleranceOnWordsOption", ")", "bool", "{", "if", "o1", "!=", "nil", "{", "return", "o1", ".", "Equal", "(", "o2", ")", "\n", "}", "\n", "if", "o2", "!=", "nil", "{", "retu...
// DisableTypoToleranceOnWordsEqual returns true if the two options are equal. // In case of one option being nil, the value of the other must be nil as well // or be set to the default value of this option.
[ "DisableTypoToleranceOnWordsEqual", "returns", "true", "if", "the", "two", "options", "are", "equal", ".", "In", "case", "of", "one", "option", "being", "nil", "the", "value", "of", "the", "other", "must", "be", "nil", "as", "well", "or", "be", "set", "to"...
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/opt/disable_typo_tolerance_on_words.go#L58-L66
train
algolia/algoliasearch-client-go
algolia/internal/opt/query_type.go
ExtractQueryType
func ExtractQueryType(opts ...interface{}) *opt.QueryTypeOption { for _, o := range opts { if v, ok := o.(*opt.QueryTypeOption); ok { return v } } return nil }
go
func ExtractQueryType(opts ...interface{}) *opt.QueryTypeOption { for _, o := range opts { if v, ok := o.(*opt.QueryTypeOption); ok { return v } } return nil }
[ "func", "ExtractQueryType", "(", "opts", "...", "interface", "{", "}", ")", "*", "opt", ".", "QueryTypeOption", "{", "for", "_", ",", "o", ":=", "range", "opts", "{", "if", "v", ",", "ok", ":=", "o", ".", "(", "*", "opt", ".", "QueryTypeOption", ")...
// ExtractQueryType returns the first found QueryTypeOption from the // given variadic arguments or nil otherwise.
[ "ExtractQueryType", "returns", "the", "first", "found", "QueryTypeOption", "from", "the", "given", "variadic", "arguments", "or", "nil", "otherwise", "." ]
dc059c0414d8c06e2b2bb47412b2130799bfcc9f
https://github.com/algolia/algoliasearch-client-go/blob/dc059c0414d8c06e2b2bb47412b2130799bfcc9f/algolia/internal/opt/query_type.go#L11-L18
train