Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTP: Support custom SSH configuration #875

Merged
merged 8 commits into from Apr 25, 2018
Merged

FTP: Support custom SSH configuration #875

merged 8 commits into from Apr 25, 2018

Conversation

fmsbeekmans
Copy link
Contributor

Made it possible to use a custom SSH configuration.

An alternative would be the possibility to inject an SSHClient instance.

This should help with #874.
Worked together with @HarrisonBaxter

@ennru ennru added the p:ftp label Apr 4, 2018
@ennru ennru changed the title Made it possible to use custom SSH configuration. FTP: Support custom SSH configuration Apr 4, 2018
@ennru
Copy link
Member

ennru commented Apr 4, 2018

Looks good. Could you add it to the docs in ftp.md as well, please?

@fmsbeekmans
Copy link
Contributor Author

Changed it such that you can use an SSHClient instead. This also allows reuse of an existing SSHClient instance. The method name in the scalaDsl is apply but in the javaDsl is withSshClient, is that considered idiomatic or should they be the same?

Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compilation on Travis is broken as Java has issues with your changes.

* @param customSshClient custom ssh client
* @return A [[akka.stream.alpakka.ftp.javadsl.Sftp]]
*/
def withSshClient(customSshClient: SSHClient): Sftp =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The withXyz methods are used have something to replace Scala's copy methods on case classes.
As constructor I'd recommend create where apply is used in Scala.

* @param customSshClient custom ssh client
* @return A [[akka.stream.alpakka.ftp.javadsl.FtpApi]] of [[net.schmizz.sshj.SSHClient]] with [[akka.stream.alpakka.ftp.impl.SftpSourceParams]]
*/
def withSshClient(customSshClient: SSHClient): FtpApi[SSHClient] with SftpSourceParams =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help the Java API to create a class Sftp and base the object on it?
I'd still like to call it create or createWithSshClient as a dual to Scala's apply.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make it return a Sftp instance instead of FtpApi[SSHClient]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 013f9c9 we tried to create an SFTP class that the current SFTP object inherited from. This way all existing code using the SFTP object would still work.

Sadly Java doesn't play well with this, it is not able to resolve the methods inherited from the traits on companion object as static methods.

We could make a separate type for instead but it would look a bit awkward.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about introducing
class SftpApi extends FtpApi[SSHClient] with SftpSourceParams
and extending and returning that?

@HarrisonBaxter
Copy link

@ennru is there more work needed for this, or does it look ok to merge?

@HarrisonBaxter
Copy link

HarrisonBaxter commented Apr 19, 2018 via email

@fmsbeekmans
Copy link
Contributor Author

Hi @ennru , is there more work to be done before this can be merged?

@HarrisonBaxter
Copy link

HarrisonBaxter commented Apr 24, 2018 via email

Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is much better than the generic type.


public ConfigureCustomSSHClient() {
SSHClient sshClient = new SSHClient(new DefaultConfig());
FtpApi<SSHClient> sftp = Sftp.create(sshClient);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should change this to SftpApi as well.

@@ -169,4 +169,18 @@ sealed trait FtpApi[FtpClient] { _: FtpSourceFactory[FtpClient] =>

object Ftp extends FtpApi[FTPClient] with FtpSourceParams
object Ftps extends FtpApi[FTPClient] with FtpsSourceParams
object Sftp extends FtpApi[SSHClient] with SftpSourceParams
class Sftp extends FtpApi[SSHClient] with SftpSourceParams
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would make sense to give it the same structure in the Scala API, WDYT?

Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ennru ennru merged commit bd2c8e7 into akka:master Apr 25, 2018
@ennru
Copy link
Member

ennru commented Apr 25, 2018

Thank you for getting this in place!

@ennru ennru added this to the 0.19 milestone Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants