[go-nuts] Best way to buffer upstream responses in reverse proxy

2020-01-17 Thread Tamás Gulácsi
Start simple: use a *bytes.Buffer, and help the GC with using a sync.Pool for 
those buffers.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/aea5ff9b-db0f-4bb5-abfb-82a2f54f7ae1%40googlegroups.com.


[go-nuts] Best way to buffer upstream responses in reverse proxy

2020-01-17 Thread Prabhu Chawandi
Hello,
 For a single request from a client, I have to make multiple upstream
requests and send a single response back to the client.

I am looking for best way to buffer in the proxy and write all at once,
where GC is not hurting the performance, seamlessly work for multiple
client request simultaneously.

Regards,
pc

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAP3P0bxVKVoxRpSSbcK%2BsG7rdH0rZrqLpqVT5HqmJgYmWRrarw%40mail.gmail.com.


[go-nuts] Go TLS OCSP stapling

2020-01-17 Thread 'Divjot Arora' via golang-nuts
If a server does not support the OCSP must staple extension and the 
certificate returned by the server has an OCSP responder endpoint, will the 
Go TLS library automatically connect to the responder to figure out if the 
certificate is valid?

I did some initial testing for this using a mock responder and it did not 
seem like the TLS library connected to the responder at all, but I wanted 
to verify that this is the case. Also, does anything change if the server 
does support the must staple extension?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/18a2f6c9-c2f2-4781-b805-dcdc09e8c198%40googlegroups.com.


Re: [go-nuts] [Proposal] database/sql: add interface that unite DB and Tx

2020-01-17 Thread 'Eric Johnson' via golang-nuts
Indeed. The strength of Go's interfaces is precisely that a library 
provider does not need to create interfaces, unless they are critical to 
the implementation of the library. You should create these types of 
interfaces when you need them.

There's a subtle versioning problem here. If Go adds a method that applies 
to both the DB and Tx objects, the proposed interface could not add the 
method in question without breaking the compatibility promise. So that 
would mean an interface with a similar purpose but a new name, in order to 
maintain compatibility.

There are differences in meaning between performing operations on the DB 
object vs. performing them on the Tx. Only in your code own do you know if 
it is safe to hide these distinctions behind an interface.

In a transaction, it isn't necessary to close a statement after it is used, 
because it will be closed when the transaction ends 
, whereas with the DB 
connection, explicit close is necessary 
.

The sql package has really good reasons for forcing the clients to think 
about what they really need, rather than providing the proposed interface.

Eric.

On Thursday, January 16, 2020 at 9:36:50 AM UTC-8, Marcin Romaszewicz wrote:
>
> I have that exact interface in all of my DB code, and I never use sql.Tx 
> or sql.DB directly. You don't need Go's libraries to adopt this at all, 
> just use your own.
>
> On Wed, Jan 15, 2020 at 11:20 PM Mhd Shulhan  > wrote:
>
>> ## Problem
>>
>> At some point we have a function that receive an instance of database 
>> connection to query rows in specific table.
>>
>> Let's say that function F() accept DB that query table T.
>>
>> If function F() called with DB instance, it will query only rows that has 
>> been committed into database.
>>
>> IF function F() called with Tx instance, it will query all rows including 
>> the one that has not been committed yet into database.
>>
>> Since DB and Tx are different types, we will have two functions that 
>> almost have identical code,
>>
>> func F(db *sql.DB) (output int) {
>>   q := `SELECT … FROM T WHERE …`
>>   err := db.QueryRow(q).Scan()
>>   …
>>   return output
>> }
>>
>> func FWithTx(tx *sql.Tx)(output int) {
>>   q := `SELECT … FROM T WHERE …`
>>   err := tx.QueryRow(q).Scan()
>>   …
>>   return output
>> }
>>
>>
>> ## Proposed solution
>>
>> Add an interface Session (the name is not fixed yet) to package sql with 
>> the following signature,
>>
>> type Session interface {
>> func Exec(query string, args ...interface{}) (Result, error)
>> func ExecContext(ctx context.Context, query string, args 
>> ...interface{}) (Result, error)
>> func Prepare(query string) (*Stmt, error)
>> func PrepareContext(ctx context.Context, query string) (*Stmt, error)
>> func Query(query string, args ...interface{}) (*Rows, error)
>> func QueryContext(ctx context.Context, query string, args 
>> ...interface{}) (*Rows, error)
>> func QueryRow(query string, args ...interface{}) *Row
>> func QueryRowContext(ctx context.Context, query string, args 
>> ...interface{}) *Row
>> }
>>
>> Session interface is combination of DB and Tx that contains all identical 
>> methods.
>>
>>
>> ## Rationale
>>
>> Without Session, user will have two functions that have the same code,
>>
>> By using Session, we can minimise duplicate code in the user level. for 
>> example using the previous problems definition the function F() become one,
>>
>> func F(session sql.Session)(output int) {
>>   q := `SELECT … FROM T WHERE …`
>>   err := session.QueryRow().Scan()
>>   …
>>   return output
>> }
>>
>>
>> ## Discussion
>>
>> Any thought about this proposal?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golan...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/C8AB29FF-7A85-445A-B09E-A0E7CB322A4C%40gmail.com
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9f4cab90-67e0-4f85-83d9-8e4f4e8c0ff7%40googlegroups.com.


Re: [go-nuts] How to query mongodb

2020-01-17 Thread burak serdar
On Fri, Jan 17, 2020 at 2:11 AM  wrote:
>
> Hi I have in my collection this JSON
>
> {
> "allowedSnssaiList": [
> {
> "allowedSnssai": {
> "sst": 1,
> "sd": "1"
> },
> "allowedSnssai": {
> "sst": 2,
> "sd": "3"
>  }
>}
>]
>  }
> how can query using the key sst and sd to return a documents matching the two 
> exact values? Example when i query using sst:1, sd :1 it should return the 
> documents but sst:1 and sd:3 should not. The problem am having is that when i 
> query using "find" using sst:1, sd:3 it still return this JSON.

This is a mongodb question, it is not related to Go language. I
suggest you read the mongodb query manuals. What you're looking for
can be found under $elemMatch query.

>
> br
> Abraham
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/32eb3edb-d9c0-4c17-a4d0-2df0014b47cc%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqqEN0NPvhJrBG7K0hyMyGpwjaadSC3U1Gc1Mrxv6tvLhw%40mail.gmail.com.


[go-nuts] GOlang Quiz - https://www.udemy.com/course/the-ultimate-go-golang-programming-challenge/?referralCode=615971CFB56748AB95F5

2020-01-17 Thread KD Notes
A collection of Golang quiz question


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/fd3f8fab-bf82-417b-8f39-910d08274617%40googlegroups.com.


Re: [go-nuts] go under rtems on arm?

2020-01-17 Thread Ian Lance Taylor
On Fri, Jan 17, 2020 at 5:41 AM Steve Simon  wrote:
>
> There was an RTEMS port as a GSOC project about 10 years ago, this was a port 
> of gccgo to x86.
>
> I would like to be able to run go apps under RTEMS on Arm, but have no real 
> understanding of the effort required
> to do so. Would anyone be able to summerize in a few sentences?
>
> I could use an external linux box to run my app and access RTEMS over the 
> wire but it would be cleaner and easier
> to maintain if I could run my go app hosted on RTEMS itself.

This would be a port to a new, entirely different, operating system.
If you look at the runtime package, it would require writing entirely
new versions of os_linux.go and sys_linux_arm.  You would likely need
something to replace netpoll_epoll.go; I forget how RTEMS handles
select/poll.  You would need a new implementation of the syscall
package, appropriate for RTEMS.  More broadly, anywhere you see a
*_linux.go or *_unix.go file in the standard library, you would likely
need a new implementation.

So: a fair amount of work, but certainly doable.  As you say, it was
done once before, although porting gccgo was likely easier than
porting the gc toolchain.

Hope this helps.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVF3w2znkHGxPNJTJUXP7YgZYXkiaMKa_x9UZuzL%2B9Row%40mail.gmail.com.


[go-nuts] go under rtems on arm?

2020-01-17 Thread Steve Simon

Hi all,

There was an RTEMS port as a GSOC project about 10 years ago, this was a 
port of gccgo to x86.

I would like to be able to run go apps under RTEMS on Arm, but have no real 
understanding of the effort required
to do so. Would anyone be able to summerize in a few sentences?

I could use an external linux box to run my app and access RTEMS over the 
wire but it would be cleaner and easier
to maintain if I could run my go app hosted on RTEMS itself.

Thanks for any/all help,

-Steve

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9933b57d-2abd-4887-8de9-0b87d1bbb0fb%40googlegroups.com.


Re: [go-nuts] Reusing tcp connections on tunnels

2020-01-17 Thread Kevin Chadwick
If you look at OpenSSH they have tcp keepalives as an option to inform routers 
to not drop the state and encrypted keep alives that aren't spoofable. There 
will also be timeout settings that people will want to modify. All of this is 
app specific DDOS/efficiency/up time/ease of use/timely informed connection 
loss etc.

For example net/http has ease of use defaults not suitable for production but 
behind app engine they do not matter much. When people deploy golang on an OS 
or compute engine then they need to consider the timeouts etc.

Perhaps you understand all this but maybe not?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/76BB3199-2AC8-483E-9225-7FD75D90EE11%40gmail.com.


[go-nuts] How to query mongodb

2020-01-17 Thread afriyie . abraham
Hi I have in my collection this JSON 

{
"allowedSnssaiList": [
{
"allowedSnssai": {
"sst": 1,
"sd": "1"
},
"allowedSnssai": {
"sst": 2,
"sd": "3"
 }
   }
   ]
 } 
how can query using the key sst and sd to return a documents matching the 
two exact values? Example when i query using sst:1, sd :1 it should return 
the documents but sst:1 and sd:3 should not. The problem am having is that 
when i query using "find" using sst:1, sd:3 it still return this JSON.

br
Abraham

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/32eb3edb-d9c0-4c17-a4d0-2df0014b47cc%40googlegroups.com.


[go-nuts] Re: How to query mongodb dynamically using Go interface

2020-01-17 Thread afriyie . abraham
Hi,
The problem wa about the index, i solved it by using the right index
bson.M{"amfInfo.taiList.tac": args[2]} since the fuction is called 

Da.FindIp(targetNfType, sst, sd, tac)

Thanks!

On Thursday, January 16, 2020 at 5:04:40 PM UTC+2, Afriyie Abraham Kwabena 
wrote:
>
> Hi,
>
> I have been trying to create a dynamic mongodb query using golang 
> interface but the logical $or does not work.
> It only return a documents when the input matches the 
> bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": args[1].(string)}.
> other matches like bson.M{"amfInfo.taiList.tac": args}, etc does not work 
> even though a document in mongodb collection exist that matches the input 
> value.
> Any idea as how to do this? The function is as below
>
> func (m *NfInstanceDataAccess) FindIp(preferredNfInstances string, args 
> ...interface{}) ([]model.NfProfile, bool) {
> var ip []model.NfProfile
> pipeline := bson.M{
> "nfType": preferredNfInstances,
> "$or": []interface{}{
> bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": 
> args[1].(string)},
> bson.M{"amfInfo.taiList.tac": args},
> bson.M{"smfInfo.taiList.tac": args},
> bson.M{"upfInfo.taiList.tac": args},
> },
> }
> filter := bson.M{"ipv4Addresses": true}
> err := db.C(COLLECTION).Find(pipeline).Select(filter).All()
> if err != nil {
> return ip, false
> }
> return ip, true
> }
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1ee05646-077e-4e21-b9ee-3ac59cdd4e45%40googlegroups.com.