[jira] [Created] (THRIFT-4553) are there any plans for add middle-ware support for thrift Go implementation?

2018-04-11 Thread gansteed (JIRA)
gansteed created THRIFT-4553:


 Summary: are there any plans for add middle-ware support for 
thrift Go implementation?
 Key: THRIFT-4553
 URL: https://issues.apache.org/jira/browse/THRIFT-4553
 Project: Thrift
  Issue Type: New Feature
Affects Versions: 0.11.0
Reporter: gansteed


version1:

provide a function to register middleware, and chain processors all. each 
function can call `Next` to skip to next function. something like middle-ware 
implementation in gin[1]. 

version2:

provide two function in TSimpleServer, one for preProcess, one for 
afterProcess. and call them

before and after `ok, err := processor.Process(defaultCtx, inputProtocol, 
outputProtocol)`, so they can use defaultCtx to do something.

 

middle-ware is useful for something like monitoring micro service, count 
execution time...etc.

 

[1]: https://github.com/gin-gonic/gin/blob/master/context.go#L104



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (THRIFT-4552) why acquire a lock in TSimpleServer implementation for Go?

2018-04-11 Thread gansteed (JIRA)
gansteed created THRIFT-4552:


 Summary: why acquire a lock in TSimpleServer implementation for Go?
 Key: THRIFT-4552
 URL: https://issues.apache.org/jira/browse/THRIFT-4552
 Project: Thrift
  Issue Type: Improvement
Affects Versions: 0.11.0
Reporter: gansteed


I've sent a email to groups, but I think maybe here will be better?
 
I'm using Thrift and I'm reading thrift implementation for Go, I found code in 
`TSimpleServer.AcceptLoop` like this:
 
```go
func (p *TSimpleServer) AcceptLoop() error {
        for {
                client, err := p.serverTransport.Accept()
                p.mu.Lock()
                if atomic.LoadInt32() != 0 {
                        return nil
                }
                if err != nil {
                        return err
                }
                if client != nil {
                        p.wg.Add(1)
                        go func() {
                                defer p.wg.Done()
                                if err := p.processRequests(client); err != nil 
{
                                        log.Println("error processing 
request:", err)
                                }
                        }()
                }
                p.mu.Unlock()
        }
}
```
 
every time it accept a request,it:
 
1. read if protocol had been closed, this step is atomic, it does not need a 
lock.
2. p.wg.Add(1) to accumulate a goroutine? this step is atomic, too, it does not 
need a lock
3. after processor processed the request, it do p.wg.Done(), it's atomic, too, 
and it does not need a lock.
 
by the way, it seems that `p.wg.Done()` do not need to put in defer? just put 
it after p.processRequests(client)?
 
so is there any particular to do it in this way?if not, I would like to submit 
a PR to reduce unneccessary performance overhead in TSimpleServer 
implementation.
 
 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


why acquire a lock in TSimpleServer implementation for Go?

2018-04-11 Thread gansteed
hi, all:
I'm using Thrift and I'm reading thrift implementation for Go, I found
code in `TSimpleServer.AcceptLoop` like this:

```go
func (p *TSimpleServer) AcceptLoop() error {
for {
client, err := p.serverTransport.Accept()
p.mu.Lock()
if atomic.LoadInt32() != 0 {
return nil
}
if err != nil {
return err
}
if client != nil {
p.wg.Add(1)
go func() {
defer p.wg.Done()
if err := p.processRequests(client); err !=
nil {
log.Println("error processing
request:", err)
}
}()
}
p.mu.Unlock()
}
}
```

every time it accept a request,it:

1. read if protocol had been closed, this step is atomic, it does not need
a lock.
2. p.wg.Add(1) to accumulate a goroutine? this step is atomic, too, it does
not need a lock
3. after processor processed the request, it do p.wg.Done(), it's atomic,
too, and it does not need a lock.

by the way, it seems that `p.wg.Done()` do not need to put in defer? just
put it after p.processRequests(client)?

so is there any particular to do it in this way?if not, I would like to
submit a PR to reduce unneccessary performance overhead in TSimpleServer
implementation.


[jira] [Commented] (THRIFT-4551) Add prettier for consistent JS code formatting

2018-04-11 Thread James E. King, III (JIRA)

[ 
https://issues.apache.org/jira/browse/THRIFT-4551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16434241#comment-16434241
 ] 

James E. King, III commented on THRIFT-4551:


Thanks for opening a ticket and the PRs.

> Add prettier for consistent JS code formatting
> --
>
> Key: THRIFT-4551
> URL: https://issues.apache.org/jira/browse/THRIFT-4551
> Project: Thrift
>  Issue Type: Improvement
>Reporter: Filip Spiridonov
>Priority: Minor
>
> [Prettier|https://prettier.io/] is awesome. See 
> [why|https://prettier.io/docs/en/why-prettier.html] you should use it.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (THRIFT-4551) Add prettier for consistent JS code formatting

2018-04-11 Thread Filip Spiridonov (JIRA)
Filip Spiridonov created THRIFT-4551:


 Summary: Add prettier for consistent JS code formatting
 Key: THRIFT-4551
 URL: https://issues.apache.org/jira/browse/THRIFT-4551
 Project: Thrift
  Issue Type: Improvement
Reporter: Filip Spiridonov


[Prettier|https://prettier.io/] is awesome. See 
[why|https://prettier.io/docs/en/why-prettier.html] you should use it.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (THRIFT-4532) Avoid updating Thrift compiler generated code if the output has not changed

2018-04-11 Thread JIRA

[ 
https://issues.apache.org/jira/browse/THRIFT-4532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16433893#comment-16433893
 ] 

Mustafa Şenol Coşar commented on THRIFT-4532:
-

[~jking3] I implemented the feature and wrote a test, But I can't make the test 
work on either appveyor or travis-ci.

I need to invoke the compiler from a Python script but the test cannot find the 
executable there, even though its there after I run "make" on my local.

You can look at the diff here: 
[https://github.com/apache/thrift/compare/master...mustafa-cosar:THRIFT-4532]

Test-related changes are in
 * 
https://github.com/apache/thrift/compare/master...mustafa-cosar:THRIFT-4532#diff-69bfe4b7a34a3480a6f449d4186b0ddc
 * 
https://github.com/apache/thrift/compare/master...mustafa-cosar:THRIFT-4532#diff-bec97bbaec40a37941cac3481d5fe596

 

> Avoid updating Thrift compiler generated code if the output has not changed
> ---
>
> Key: THRIFT-4532
> URL: https://issues.apache.org/jira/browse/THRIFT-4532
> Project: Thrift
>  Issue Type: Improvement
>  Components: Compiler (General)
>Affects Versions: 0.11.0
>Reporter: Buğra Gedik
>Priority: Minor
> Fix For: 0.12.0
>
>
> We would like to contribute an improvement to the Thrift compiler that would 
> avoid regenerating target file(s) if they are going to be exactly the same as 
> the ones already present in the same place. This will help when running the 
> Thrift compiler in our build, especially in recursive mode.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)