Joes-MBP:admin-backend-api joecwu$ docker push {host}:{port}/xxx/admin-backend-api:0.1.17
The push refers to a repository [{host}:{port}/xxx/admin-backend-api] (len: 1)
Sending image list
Put http://{host}:{port}/v1/repositories/xxx/admin-backend-api/: dial tcp: lookup {host} on 192.168.70.254:53: read udp 192.168.70.254:53: i/o timeout
[error] unable to ping registry endpoint https://192.168.1.2:6000/v0/
[error] v2 ping attempt failed with error: Get https://192.168.1.2:6000/v2/: EOF
[error] v1 ping attempt failed with error: Get https://192.168.1.2:6000/v1/_ping: EOF
[trace] Stack trace suppressed: run last docker:publish for the full output.
[error] (docker:publish) Nonzero exit value: 1
[error] Total time: 9 s, completed Nov 6, 20157:59:57 PM
Joes-MBP:admin-backend-api joecwu$ docker-machine stop default
Joes-MBP:admin-backend-api joecwu$ docker-machine start default
Starting VM...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
Result
Run docker:publish
> docker:publish
[info] Wrote ........./admin-backend-api_2.11-0.1.0.pom
[info] Sending build context to Docker daemon 557.1 kB
[info] Sending build context to Docker daemon 1.114 MB
[info] Step 7 : CMD
[info] ---> Using cache
[info] ---> 48923d750c11
[info] Successfully built 48923d750c11
[info] Built image 192.168.1.2:6000/kiri/admin-backend-api:0.1.0
[info] The push refers to a repository [192.168.1.2:6000/kiri/admin-backend-api] (len: 1)
[info] Sending image list
[info] Pushing repository 192.168.1.2:6000/kiri/admin-backend-api (1 tags)
...
[info] 48923d750c11: Pushing
[info] 48923d750c11: Image successfully pushed
[info] Pushing tag for rev [48923d750c11] on {http://192.168.1.2:6000/v1/repositories/kiri/admin-backend-api/tags/0.1.0}
[info] Published image 192.168.1.2:6000/kiri/admin-backend-api:0.1.0
scala> val joe2 = User("TW","123","Joe")
joe2: User = User(TW,123,Joe)
scala> joe == joe2
res: Boolean = true
scala> val joe3 = User("TW","124","Joe")
joe3: User = User(TW,124,Joe)
scala> joe == joe3
res54: Boolean = false
要複製的時候,可以使用copy,若有要修改的屬性,再copy當中宣告即可
scala> joe.copy(region="US")
res: User = User(US,123,Joe)
有實作unapply,所以在pattern matching可以直接使用。
scala> val User(region,id,name) = joe
region: String = TW
id: String = 123name: String = Joe
scala> joe match {
| case User(_,id,_) => println(s"id:[$id]")
| }
id:[123]
如果在宣告case class的時候,並沒有要給任何的參數,就像是定義ADT(Algebraic Data Type)的時候,我們有可能會宣告到一個沒有任何參數的class,這時候可以用case object來宣告。
sealedtraitLife[+T]caseclassAlive[T](value: T)extendsLife[T]caseobjectDeadextendsLife[Nothing]
scala> def check(life:Life[User]) = life match {
| case Alive(user) => println(user.name)
| case Dead => println("dead")
| }
check: (life: Life[User])Unit
scala> check(Alive(joe))
Joe
scala> check(Dead)
dead
scala> j.name
<console>:24: error: value nameisnot a member of Person
j.name
^
所以我們必須自己加上val的宣告
scala> caseclassPerson(fingerPrint: Long)(val name: String, val dress: String)
defined classPerson
scala> val j = Person(123123l)("Joe","Suit")
j: Person = Person(123123)
scala> j.name
res: String = Joe
當然用copy的時候,也就知道後面curried的部份也沒有實作copy,所以你必需帶所有的參數。
scala> j.copy()(name = "David")
<console>:25: error: not enough arguments for method copy: (name: String, dress: String)Person.
Unspecified value parameter dress.
j.copy()(name = "David")
^
scala> j.copy()(name = "David", dress = "Dirty")
res80: Person = Person(123123)
// define the process logic for wye.dynamic, here is always change to the other side.
val w = wye.dynamic( (_:Any) => wye.Request.R, (_:Any) => wye.Request.L)scala> p1.wye(p2)(w).runLog.runres: IndexedSeq[scalaz.stream.ReceiveY[Any,Any]] = Vector(ReceiveL(1), ReceiveR(a), ReceiveL(2), ReceiveR(b), ReceiveL(3), ReceiveR(c), ReceiveL(4), ReceiveR(
d))p1.wye(p2)(w).runLog.run.filter( _.isR )res: IndexedSeq[scalaz.stream.ReceiveY[Any,Any]] = Vector(ReceiveR(a), ReceiveR(b), ReceiveR(c), ReceiveR(d))scala> p1.wye(p2)(w).runLog.run.map(_ match {
| case ReceiveY.ReceiveR(x) => "R:"+x
| case ReceiveY.ReceiveL(x) => "L:"+x
| }).map(x=>println(s"got $x"))gotL:1
gotR:agotL:2
gotR:bgotL:3
gotR:cgotL:4
gotR:d