How to participate in a top-level open source project

Foreword

Recently more personal things (moving, changing jobs, short break) so they have no occasion blog updated, just recently received an e-mail alert me.

It is time to write an article to talk about the things involved in open source projects (indeed recently entered a pen shortage period).

ps: for the first time to receive such a gift Mid-Autumn Festival, plus the Dubboimportance of active and Ali community, still doing PRCor micro technology selection of services can be considered a friend Dubbo.

Participate in open source

Now to talk about specific things involved in open source;

Almost all of the daily developers will enjoy the convenience brought open source project even earnings, subject to the environment than a decade ago or even a few years ago the open source movement has always been the leading foreign developers.

But a few years domestic Internet companies gradually expand the international influence is also greatly improved our level of development, to BATled many excellent open source project.

Now even participate in open source projects but also another way to get the manufacturers offer, in fact, so many of my friends want to participate, might this thing gives the first impression is not easy, so it's stuck in the first step.

Specific steps

The following is a major step summary of my personal experience:

  • Identify problems or to introduce ourselves feature.
  • fork source.
  • Local development, self-test.
  • Launched pull request.
  • Wait community Code Review.
  • Follow up on community input adjustment code.
  • Approval, merge into the masterbranch, the completion of this contribution.

Now I will combine the latest participate in Dubbothe process to talk about specific.

Identify problems or to introduce ourselves feature

The first step naturally have to figure out what this contribution is your own? Usually solve a problem or to submit a new one feature; the former is relatively them more easily.

Of course, this problem can be found in the course of their own, it can also be a list of Issues to be solved.

To this problem, for example, in the course of what I found, also submitted the relevant Issue and wrote an article record and resolve the issue: the What? Dubbo start a service to two hours!

It is noteworthy that the best is first in the list is already Issue related issues through under the keyword search before submitting Issue, to avoid duplication.

After submitting the same time maybe the community will conduct follow-up, was marked with invalidthe label is not considered a problem, or position does not use is also possible.

fork source, local development

This is a problem when it is determined to be repaired when you can start working on it.

The first step is naturally to copy the source code to their own warehouse.

Then just need to clone their own source code repository to local development.

First review under the problem I encountered.

It is simply start the Dubboservice very slow, after positioning mainthread is blocked ip in the acquisition at the machine.

So I proposed program are: plus timeout when access to the local ip, once the timeout will throw an exception or retry again, but at least have to have logs user location problem.

The problem is that the main thread will remain blocked here InetAddress.getLocalHost().getHostAddress(), but need to know how long it blocked determine whether we go out.

You can only open a thread and then additional, timed to detect mainwhether the thread has completed the task, the following is the content of my first pr.

The focus here is not to discuss the technical details, it is simply the next step:

  • Amounted to declare the size of the thread pool 1.
  • Then declares a volatileflag is used to determine whether there is the main thread to complete the task.
  • It declares a condition to wait for the new thread to do.
  • Finally, only need to run this thread can be used to determine this flag.

How self-test

After the completion of the next step is to develop self-test, since these items are dependent on the package as a basis for other projects in order to run, so we usually have to create a new project to do with the whole process of testing (except single measurement).

Here I think there are a few tips worth noting.

The first is the version number; because the local test, so it is necessary to use mvn clean installthe installation package to rely on locally to go in other projects for testing.

But since we pulled out of the official version of the code have been published to the maven central repository (either release or snapshot), so we must have a local warehouse in the presence of several versions of the jar package.

Once we execute mvn clean installwhen the modified code to install their own local high probability is likely to go wrong (possibly my position does not), this will lead to new projects can not rely on their new code.

So I usually practice is modified version, this version has never been released officially to the central warehouse, you can make sure you add the code to a local installation to a new version, so that we no longer rely on this version of the test that is can.

But be careful not to get any submitted this version number when submitting.

Initiating pull request

After completion of the self-test can be initiated pull request, and not the effect, there had to have a place to note that the code newline problem.

Once the line breaks are inconsistent with the source repository, gityou will think this amendment is to delete the post again, so will code reviewbring great trouble.

Like this, obviously I change the number of rows is not much, but gitis recognized as you are overturned again, leading to audit them do not know what you changed places.

The easiest way is to set up its own gitglobal configuration, you can refer here .

# 提交时转换为LF,检出时转换为CRLF
git config --global core.autocrlf true

# 提交时转换为LF,检出时不转换
git config --global core.autocrlf input

# 提交检出均不转换
git config --global core.autocrlf false
复制代码

No problem can be confirmed Click here to initiate a pull request, in accordance with the back to guide the implementation.

Of course, there will be a contribution to their own custom processes between the various projects, the best is to look at the contribution of official guidelines.

dubbo.apache.org/en-us/docs/…

Code Review

pr After initiating community can wait reviewed.

To communicate fully and communities in this process, it is possible to program and your community idea is not consistent.

For example, I like this:

The final communication by adding your own thinking behind the community think it's a reasonable number of programs more portable, after the agreement put the community in pr incorporated into the master.

In fact, the whole process I think the most interesting is the code reviewprocess, everyone can participate in brainstorming, which also lack technical Daniel, unknowingly will be able to learn a lot.

Similar cases

Although I have not been adopted before the program, but similar usage (one thread monitor other threads) or a lot, just Dubbohave to be useful in.

The core of the service is invoked, by default it looks for the user is a synchronous call, that consumer will wait until after the implementation of the follow-up logic PRC finished.

But the underlying fact this is a TCPprocess of sending network packets, itself is asynchronous .

Just Dubbodo in case you do not know the asynchronous transfer synchronization, so it looks like a synchronous method.

Red frame section in the figure, Dubbocalls itself a get()method for synchronization acquisition of the service provider returns the result.

The logic is actually quite simple, and I plan similar to the above, but here the isDone()function returns whether to get a return value of the service provider only.

to sum up

This summarizes the specific steps involved in open source, is actually quite simple; just as one official said even mention Issue, modify a spelling are considered to participate, so do not think too hard.

Finally, a simple analysis of asynchronous transfer process is called synchronization process in Dubbo, to master these operations on their usual development is also helpful.

Share your thumbs and is the biggest support for me

Guess you like

Origin juejin.im/post/5d59efaff265da03e1687650