[ARVADOS] updated: b9f0177e6a477a518fd5a89156fafde57f2dddf8

Git user git at public.curoverse.com
Sun Dec 11 01:47:51 EST 2016


Summary of changes:
 sdk/go/arvados/client.go  | 30 +++++++++++++++++++++++++-----
 services/ws/router.go     |  5 +----
 services/ws/session.go    |  8 ++++++++
 services/ws/session_v0.go |  7 ++++++-
 services/ws/session_v1.go |  4 +++-
 5 files changed, 43 insertions(+), 11 deletions(-)

       via  b9f0177e6a477a518fd5a89156fafde57f2dddf8 (commit)
      from  bdb92619b5f6d920119b8c32c3027cf4b751ed16 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit b9f0177e6a477a518fd5a89156fafde57f2dddf8
Author: Tom Clegg <tom at curoverse.com>
Date:   Sun Dec 11 01:41:28 2016 -0500

    8460: Add object_kind field.

diff --git a/sdk/go/arvados/client.go b/sdk/go/arvados/client.go
index 0c18d38..a7d8c4a 100644
--- a/sdk/go/arvados/client.go
+++ b/sdk/go/arvados/client.go
@@ -241,14 +241,10 @@ func (c *Client) DiscoveryDocument() (*DiscoveryDocument, error) {
 	return c.dd, nil
 }
 
-func (c *Client) PathForUUID(method, uuid string) (string, error) {
+func (c *Client) modelForUUID(dd *DiscoveryDocument, uuid string) (string, error) {
 	if len(uuid) != 27 {
 		return "", fmt.Errorf("invalid UUID: %q", uuid)
 	}
-	dd, err := c.DiscoveryDocument()
-	if err != nil {
-		return "", err
-	}
 	infix := uuid[6:11]
 	var model string
 	for m, s := range dd.Schemas {
@@ -260,6 +256,30 @@ func (c *Client) PathForUUID(method, uuid string) (string, error) {
 	if model == "" {
 		return "", fmt.Errorf("unrecognized UUID infix: %q", infix)
 	}
+	return model, nil
+}
+
+func (c *Client) KindForUUID(uuid string) (string, error) {
+	dd, err := c.DiscoveryDocument()
+	if err != nil {
+		return "", err
+	}
+	model, err := c.modelForUUID(dd, uuid)
+	if err != nil {
+		return "", err
+	}
+	return "arvados#" + strings.ToLower(model[:1]) + model[1:], nil
+}
+
+func (c *Client) PathForUUID(method, uuid string) (string, error) {
+	dd, err := c.DiscoveryDocument()
+	if err != nil {
+		return "", err
+	}
+	model, err := c.modelForUUID(dd, uuid)
+	if err != nil {
+		return "", err
+	}
 	var resource string
 	for r, rsc := range dd.Resources {
 		if rsc.Methods["get"].Response.Ref == model {
diff --git a/services/ws/router.go b/services/ws/router.go
index 0ad8d7c..0420745 100644
--- a/services/ws/router.go
+++ b/services/ws/router.go
@@ -1,7 +1,6 @@
 package main
 
 import (
-	"database/sql"
 	"encoding/json"
 	"io"
 	"net/http"
@@ -45,8 +44,6 @@ type debugStatuser interface {
 	DebugStatus() interface{}
 }
 
-type sessionFactory func(wsConn, chan<- interface{}, *sql.DB, permChecker) (session, error)
-
 func (rtr *router) setup() {
 	rtr.handler = &handler{
 		PingTimeout: rtr.Config.PingTimeout.Duration(),
@@ -71,7 +68,7 @@ func (rtr *router) makeServer(newSession sessionFactory) *websocket.Server {
 
 			stats := rtr.handler.Handle(ws, rtr.eventSource,
 				func(ws wsConn, sendq chan<- interface{}) (session, error) {
-					return newSession(ws, sendq, rtr.eventSource.DB(), rtr.newPermChecker())
+					return newSession(ws, sendq, rtr.eventSource.DB(), rtr.newPermChecker(), &rtr.Config.Client)
 				})
 
 			log.WithFields(logrus.Fields{
diff --git a/services/ws/session.go b/services/ws/session.go
index d469737..67f4608 100644
--- a/services/ws/session.go
+++ b/services/ws/session.go
@@ -1,5 +1,11 @@
 package main
 
+import (
+	"database/sql"
+
+	"git.curoverse.com/arvados.git/sdk/go/arvados"
+)
+
 type session interface {
 	// Receive processes a message received from the client. If a
 	// non-nil error is returned, the connection will be
@@ -23,3 +29,5 @@ type session interface {
 	// up, the connection will be dropped.
 	EventMessage(*event) ([]byte, error)
 }
+
+type sessionFactory func(wsConn, chan<- interface{}, *sql.DB, permChecker, *arvados.Client) (session, error)
diff --git a/services/ws/session_v0.go b/services/ws/session_v0.go
index 1cb3021..2b108a2 100644
--- a/services/ws/session_v0.go
+++ b/services/ws/session_v0.go
@@ -8,6 +8,7 @@ import (
 	"sync/atomic"
 	"time"
 
+	"git.curoverse.com/arvados.git/sdk/go/arvados"
 	"github.com/Sirupsen/logrus"
 )
 
@@ -22,6 +23,7 @@ var (
 )
 
 type v0session struct {
+	ac            *arvados.Client
 	ws            wsConn
 	sendq         chan<- interface{}
 	db            *sql.DB
@@ -33,11 +35,12 @@ type v0session struct {
 	setupOnce     sync.Once
 }
 
-func newSessionV0(ws wsConn, sendq chan<- interface{}, db *sql.DB, pc permChecker) (session, error) {
+func newSessionV0(ws wsConn, sendq chan<- interface{}, db *sql.DB, pc permChecker, ac *arvados.Client) (session, error) {
 	sess := &v0session{
 		sendq:       sendq,
 		ws:          ws,
 		db:          db,
+		ac:          ac,
 		permChecker: pc,
 		log:         logger(ws.Request().Context()),
 	}
@@ -85,12 +88,14 @@ func (sess *v0session) EventMessage(e *event) ([]byte, error) {
 		return nil, err
 	}
 
+	kind, _ := sess.ac.KindForUUID(detail.ObjectUUID)
 	msg := map[string]interface{}{
 		"msgID":             atomic.AddUint64(&sess.lastMsgID, 1),
 		"id":                detail.ID,
 		"uuid":              detail.UUID,
 		"object_uuid":       detail.ObjectUUID,
 		"object_owner_uuid": detail.ObjectOwnerUUID,
+		"object_kind":       kind,
 		"event_type":        detail.EventType,
 	}
 	if detail.Properties != nil && detail.Properties["text"] != nil {
diff --git a/services/ws/session_v1.go b/services/ws/session_v1.go
index 701dce0..f773f18 100644
--- a/services/ws/session_v1.go
+++ b/services/ws/session_v1.go
@@ -3,8 +3,10 @@ package main
 import (
 	"database/sql"
 	"errors"
+
+	"git.curoverse.com/arvados.git/sdk/go/arvados"
 )
 
-func newSessionV1(ws wsConn, sendq chan<- interface{}, db *sql.DB, pc permChecker) (session, error) {
+func newSessionV1(ws wsConn, sendq chan<- interface{}, db *sql.DB, pc permChecker, ac *arvados.Client) (session, error) {
 	return nil, errors.New("Not implemented")
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list