I should add: using channels often means the mutex is not required.
Imagine, for example, that you want a concurrency-safe counter (that
multiple goroutines can read, increment and decrement). You can put the
counter value into a buffered channel:
counter := make(chan int, 1)
counter <- 0
The
Hi,
THanks!!
BR
Abraham
On Friday, November 27, 2020 at 11:12:53 AM UTC+2 b.ca...@pobox.com wrote:
> On Friday, 27 November 2020 at 06:14:48 UTC Afriyie Abraham Kwabena wrote:
>
>> What I would like to ask is, using mutex OK and if not the best way of
>> solving it, how can i use
>> channels i
On Friday, 27 November 2020 at 06:14:48 UTC Afriyie Abraham Kwabena wrote:
> What I would like to ask is, using mutex OK and if not the best way of
> solving it, how can i use
> channels in this case.
>
There's nothing wrong with mutex, but you can use channels for a more
native-Go experience.
Hi,
I just produce the warning for clarity. sorry for the huge message
==
WARNING: DATA RACE
Write at 0x00c0002d6480 by goroutine 48:
runtime.mapdelete_faststr()
/usr/local/go/src/runtime/map_faststr.go:297 +0x0
nfnrfapi/services/manag.UpdateNFInstance()
/home/x
Hi,
Yes from the warning it prints the handler function below and after google
searching what i did was to mutex.Lock and Unlock the handler function and
no warning again.
However, my google search people mention of using channels instead of
mutex. What I would like to ask is, using mutex OK an
> On 27 Nov 2020, at 07.06, Afriyie Abraham Kwabena
> wrote:
>
> Hi,
>
> Am experiencing data race warning with my pollingworker function below even
> though when i build with the -race flag i do not get any error. Any help?
>
Usually when you got data race warning it will print the line
Hi,
Am experiancing data race warning with my pollingworker function below even
though when i build with the -race flag i do not get any error. Any help?
func PollingWorker() {
tiker := time.NewTicker(60 * time.Second)
for _ = range tiker.C {
mu.Lock()
for keyid := range
Hi Sulhan, Anderson,
Thanks for your guidance. It works now using time.Ticker
func worker() {
tiker := time.NewTicker(30 * time.Second)
for _ = range tiker.C {
mu.Lock()
for keyid := range idtime {
d := time.Now().Unix() - idtime[keyid]
if d >= 60
> On 18 Nov 2020, at 01.06, Afriyie Abraham Kwabena
> wrote:
>
> Hi,
>
> The UpdateData function is the HTTP handler for the route which matches the
> URL and is called after the mux.Router after receiving an incoming request
> matches the incoming request
> against the registered route.
Hi,
The UpdateData function is the HTTP handler for the route which matches the
URL and is called after the mux.Router after receiving an incoming request
matches the incoming request
against the registered route.
BR
Afriyie
On Tuesday, November 17, 2020 at 7:33:50 PM UTC+2 Afriyie Abraham
Hi,
I have made changes according to the comments and also simply the main
function but am not sure if the worker go routine works.
This what i did:
type Route struct {
Namestring
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
var idtime = make(map
Hi Afriyie,
Looks like you almost there ;)
> On 17 Nov 2020, at 20.11, Afriyie Abraham Kwabena
> wrote:
>
> HI,
>
> This is what I have tried so far but am not able to get the time difference
> in seconds. I mean the time differences between the time stored in the
> map[string]time.Time and
HI,
This is what I have tried so far but am not able to get the time difference
in seconds. I mean the time differences between the time stored in the
map[string]time.Time and
the current time in seconds.
code:
type Server struct {
idtime map[string]time.Time
}
var my = Server{}
func mai
Just one thing to keep in mind. Likely you have more than one serve
instance running to process the requests. Thus it might happen the client
will poll a different server on every request. Just imagine you have
servers A, B, C behind a load balance and the domain example.com. As the
client is p
> On 16 Nov 2020, at 16.24, Afriyie Abraham Kwabena
> wrote:
>
> Hi ,
>
> You are right but am new to programming and currently this what i have done.
> I have an http server handler that receives the PATCH request and stores the
> id and the current time stamp of the request.
> But my prob
Hi ,
You are right but am new to programming and currently this what i have done.
I have an http server handler that receives the PATCH request and stores
the id and the current time stamp of the request.
But my problem is how to write the worker function to do the clean up every
X seconds.
Cod
> On 14 Nov 2020, at 20.06, Afriyie Abraham Kwabena
> wrote:
>
> Hi,
>
> My question is about multiple HTTP client polling an HTTP server randomly
> with a PATCH request to update a resource at the server running in front of
> MongoDB. The clients poll with their different ids and a valid
Hi,
My question is about multiple HTTP client polling an HTTP server randomly
with a PATCH request to update a resource at the server running in front of
MongoDB. The clients poll with their different ids and a valid time in
their request. At the server, I can keep their ids and their differe
18 matches
Mail list logo