[go-nuts] How should I avoid - literal copies lock value from

2018-08-07 Thread Kasun Vithanage
I'm implementing some thread safe data structures type Set struct { m map[string]int mux sync.Mutex } func New() *Set { return &Set{m: make(map[string]int)} } In my Diff function i need to pass an array of sets to do a diff on another set func (set *Set) DiffS(sets []Set) *Set {

[go-nuts] Re: How should I avoid - literal copies lock value from

2018-08-07 Thread Kasun Vithanage
Error is gone when used mux *sync.Mutex On Tuesday, August 7, 2018 at 6:12:26 PM UTC+5:30, Kasun Vithanage wrote: > > I'm implementing some thread safe data structures > > type Set struct { >m map[string]int >mux sync.Mutex > } > > > func New()

[go-nuts] Re: How should I avoid - literal copies lock value from

2018-08-10 Thread Kasun Vithanage
I want an slice of sets On Tuesday, August 7, 2018 at 6:32:25 PM UTC+5:30, Dave Cheney wrote: > > Pass a pointer, *Set into your Diff method. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emai

[go-nuts] What is the proper way to delete a key which holding a pointer in a map

2018-08-27 Thread Kasun Vithanage
I've a map which has set of keys and pointing to some structs like this. In here i allocate lot of entries and trying to delete them. But the memory usage is not shrinking. According to this issue it seems how go behave at this point. In there its sug

Re: [go-nuts] What is the proper way to delete a key which holding a pointer in a map

2018-08-27 Thread Kasun Vithanage
; > Vào Th 2, 27 thg 8, 2018 vào lúc 16:00 Kasun Vithanage < > alan...@gmail.com > đã viết: > >> I've a map which has set of keys and pointing to some structs like this. >> In here i allocate lot of entries and trying to delete them. But the memory >> u

Re: [go-nuts] What is the proper way to delete a key which holding a pointer in a map

2018-08-27 Thread Kasun Vithanage
Yeah saw that, but what about a map with around 10 entries. this will add a lot of overhead i guess. On Monday, August 27, 2018 at 3:13:39 PM UTC+5:30, Jan Mercl wrote: > > On Mon, Aug 27, 2018 at 11:38 AM Kasun Vithanage > wrote: > > > I simply want to delete the m

[go-nuts] Re: What is the proper way to delete a key which holding a pointer in a map

2018-08-27 Thread Kasun Vithanage
d. See https://play.golang.org/p/fWOIbvjFjyB. > In that test, the "internal" memory that is not freed is about 14 bytes per > entry. > > Of course, keep in mind that nothing is freed until a GC is done. > > On Monday, August 27, 2018 at 5:00:14 AM UTC-4, Kasun Vithana

[go-nuts] Snapshot data with Go

2018-09-15 Thread Kasun Vithanage
I'm developing a *redis **like *server with Go. You can see the code repo here . I need to dump my *Mutex Protected map* to a *file*. Simply *snapshot data to a file*. In redis, it take snapshots of data using a fork as described in here

[go-nuts] Re: Snapshot data with Go

2018-09-16 Thread Kasun Vithanage
plicated child process > is created with only one thread - the thread that called fork. This > basically means your child process no longer has a working Go > runtime/environment. > > > > Cheers, > > Lei > > On Sunday, September 16, 2018 at 11:44:18 AM UTC+8, Kasun

[go-nuts] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
I'm doing a simple load test with Apache JMeter. My ambition was to benchmark a go server. Here is the code I've been using, its a simple web server package main import ( "fmt" "log" "net/http" "runtime" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "welcome")

Re: [go-nuts] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
recommend running your load generator > on a host separate from the system under test. There are situations in > which your load generator takes enough resources to mess with the SUT. > > On Mon, Jan 14, 2019 at 12:48 PM Kasun Vithanage > wrote: > >> I'm doing a simple l

Re: [go-nuts] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
akes enough resources to mess with the SUT. > > On Mon, Jan 14, 2019 at 12:48 PM Kasun Vithanage > wrote: > >> I'm doing a simple load test with Apache JMeter. My ambition was to >> benchmark a go server. Here is the code I've been using, its a simple web >>

Re: [go-nuts] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
te from the system under test. There are situations in > which your load generator takes enough resources to mess with the SUT. > > On Mon, Jan 14, 2019 at 12:48 PM Kasun Vithanage > wrote: > >> I'm doing a simple load test with Apache JMeter. My ambition was to >> b

Re: [go-nuts] How to increase concurrent users in net/http

2019-01-14 Thread Kasun Vithanage
fo Azevedo > > Em seg, 14 de jan de 2019 às 10:16, Kasun Vithanage > escreveu: > >> I've deleted original post because it seems a problem with my code, will >> try to use a WorkerPool and see the result :) >> Thanks for support >> >> On Monday, Janu

[go-nuts] Implementing an EventBus in Go

2019-03-10 Thread Kasun Vithanage
Hi all, I've experience implementing event buses in Java. In Java, I used a singleton where I can register callbacks to methods and fire event from a publisher(maybe from another thread) and propagate it to subscribers. In Go what would be the best pattern to implement a pub/sub event bus? Ar

Re: [go-nuts] Implementing an EventBus in Go

2019-03-10 Thread Kasun Vithanage
Yes, when a publisher publish for a topic it should be routed to all subscribers to that topic :) On Monday, March 11, 2019 at 10:28:17 AM UTC+5:30, Burak Serdar wrote: > > On Sun, Mar 10, 2019 at 10:41 PM Kasun Vithanage > wrote: > > > > Hi all, > > > > I

Re: [go-nuts] Implementing an EventBus in Go

2019-03-10 Thread Kasun Vithanage
you're within a single > process, though. > > -- Marcin > > > On Sun, Mar 10, 2019 at 9:41 PM Kasun Vithanage > wrote: > >> Hi all, >> >> I've experience implementing event buses in Java. >> In Java, I used a singleton where I can regis

Re: [go-nuts] Implementing an EventBus in Go

2019-03-10 Thread Kasun Vithanage
tyle subscribe > / publish model in Go, just using a map of receivers and their receiver > callback functions: > https://github.com/goki/ki/blob/master/ki/signal.go > > - Randy > > > On Mar 10, 2019, at 11:07 PM, Kasun Vithanage > wrote: > > > > Yes, when a

Re: [go-nuts] Implementing an EventBus in Go

2019-03-10 Thread Kasun Vithanage
for Zeromq > <http://zeromq.org/bindings:go>, which supports pub-sub in exactly the > way you mention. I've used this thing in production to route > 200,000 > pub/sub messages per second. It may be overkill if you're within a single > process, though. > > --

[go-nuts] Re: Implementing an EventBus in Go

2019-03-12 Thread Kasun Vithanage
I wrote an article about the topic. Feel free to visit it https://medium.com/@kasvith/lets-write-a-simple-event-bus-in-go-79b9480d8997 On Monday, March 11, 2019 at 10:11:25 AM UTC+5:30, Kasun Vithanage wrote: > > Hi all, > > I've experience implementing event buses in Java. &g

[go-nuts] Re: Migrating to modules

2019-06-26 Thread Kasun Vithanage
Yes you can easily migrate. Go will automatically generate mod files based on your projects. Just go into the project and run GO111MODULE=on go mod init and everything will be ok. If you are storing your projects in a VCS like Github just make sure you put repo name as the PROJECT NAME Ex:

[go-nuts] Re: Migrating to modules

2019-06-27 Thread Kasun Vithanage
According to this it will try to create an equivalent build. It will not break your code On Thursday, June 27, 2019 at 12:59:25 PM UTC+5:30, les...@gmail.com wrote: > > Thanks Kasun, > > One thing th

[go-nuts] What is the correct way to access/modify slice elements concurrently

2019-11-07 Thread Kasun Vithanage
Assume we have a type like follows type Foo struct { Alive bool } type Bar struct { Foos []*Foo } In two goroutines we are supposed to read and write the Alive variable. For example func (b *Bar) CheckFoosAlive() { for i := 0; i < len(b.Foos); i++ { if b.Foos[i].Alive { fmt.Println("Alive")