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
Conversation
Looks good. Could you add it to the docs in |
Changed it such that you can use an |
There was a problem hiding this 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 = |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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]
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
@ennru is there more work needed for this, or does it look ok to merge? |
Ferdy and I have done it like this to try and avoid breaking backward
compatibility
…On Thu, Apr 19, 2018 at 11:32 AM, Enno ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In ftp/src/main/scala/akka/stream/alpakka/ftp/javadsl/FtpApi.scala
<#875 (comment)>:
> @@ -238,4 +238,16 @@ 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
+object Sftp extends FtpApi[SSHClient] with SftpSourceParams {
+
+ /**
+ * Java API: creates a [[akka.stream.alpakka.ftp.javadsl.FtpApi]] of [[net.schmizz.sshj.SSHClient]] with [[akka.stream.alpakka.ftp.impl.SftpSourceParams]]
+ *
+ * @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 =
Could you make it return a Sftp instance instead of FtpApi[SSHClient]?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#875 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AQ8bMRhKYfyDMpqJOjkiDTCdF9iA-oeFks5tqGewgaJpZM4THE2l>
.
|
Hi @ennru , is there more work to be done before this can be merged? |
We were hoping to achieve the same return type when using a custom ssh
client as the default one. The proposed solution does not allow this in conjunction with keeping the backward compatibility.
Update, sounds like a good idea actually
…On Tue, Apr 24, 2018 at 10:34 AM, Enno ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In ftp/src/main/scala/akka/stream/alpakka/ftp/javadsl/FtpApi.scala
<#875 (comment)>:
> @@ -238,4 +238,16 @@ 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
+object Sftp extends FtpApi[SSHClient] with SftpSourceParams {
+
+ /**
+ * Java API: creates a [[akka.stream.alpakka.ftp.javadsl.FtpApi]] of [[net.schmizz.sshj.SSHClient]] with [[akka.stream.alpakka.ftp.impl.SftpSourceParams]]
+ *
+ * @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 =
What about introducing
class SftpApi extends FtpApi[SSHClient] with SftpSourceParams
and extending and returning that?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#875 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AQ8bMQx-li6-fd-i_1MABl5TOkWTLHaYks5trvGogaJpZM4THE2l>
.
|
There was a problem hiding this 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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you for getting this in place! |
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