Reference valyala/fasthttp#1014
Don't forget about collisions problem.
Reference valyala/fasthttp#1014
Don't forget about collisions problem.
// | |
// Copyright (c) 2018 Konstanin Ivanov <kostyarin.ivanov@gmail.com>. | |
// All rights reserved. This program is free software. It comes without | |
// any warranty, to the extent permitted by applicable law. You can | |
// redistribute it and/or modify it under the terms of the Do What | |
// The Fuck You Want To Public License, Version 2, as published by | |
// Sam Hocevar. See below for more details. | |
// |
type MessengerFactory struct { | |
factory.MessengerFactory | |
isInitialized bool | |
} | |
func (m *MessengerFactory) IsInitialized() bool { return m.isInitialized } | |
func (m *MessengerFactory) Connect(address string) (conn *Connection, err error) { | |
return m.ConnectWithConfig(address, nil) | |
} |
Len(pack Pack) (ln int, err error) | |
// presence check | |
HasHash(pack Pack, hash cipher.SHA256) (ok bool, err error) | |
// short hand for HasHash + pack.Get(hash) + encoder.DeserializeRaw | |
ValueByHash(pack Pack, hash cipher.SHA256, obj interface{}) (err error) | |
// the IndexByHash is useful only if the Refs contains only unique | |
// elements |
Functional options: https://gist.github.com/travisjeffery/8265ca411735f638db80e2e34bdbd3ae
In real world we need to validate input. This functional options kills global namespace. Take a look my average config:
import (
"domain.tld/user/log"
)
// default configs
// in this example the Event is an event, that requires updates in our Root | |
func startHandlingSomePack(events <-chan Event, pack *skyobject.Pack, | |
n *node.Node, wg *sync.WaitGroup) { | |
go handleSomePack(n, pack, events, n.Quiting(), wg) | |
} | |
func handleSomePack(n *node.Node, pack *cxo.Pack, events <-chan Event, | |
quit <-chan struct{}, wg *sync.WaitGroup) { |
package main | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"strings" | |
"time" | |
"github.com/peterh/liner" |
package main | |
import ( | |
"image" | |
"image/png" | |
"log" | |
"os" | |
"time" | |
"golang.org/x/image/draw" |
%YAML 1.2 | |
--- | |
# See http://www.sublimetext.com/docs/3/syntax.html | |
file_extensions: | |
- S | |
scope: source.S | |
contexts: | |
main: | |
# comment multiline |
package pool | |
import ( | |
"sync" | |
"testing" | |
"time" | |
) | |
// perform: | |
// go test -bench syncPool |