func NewFeedAgent(conn *grpc.ClientConn) *FeedAgent { c := pb.NewApiClient(conn) worker := &pb.Worker{ Id: randhash(), } return &FeedAgent{ client: c, worker: worker, } }
func NewServer(conn *grpc.ClientConn, secretKey string, debug bool) *Server { c := pb.NewApiClient(conn) worker := &pb.Worker{ Id: randhash(), } httpclient := &http.Client{ Timeout: 30 * time.Second, } cacheStore := cache.NewInMemoryStore(time.Second) rc, _ := react.NewReact() jsx, _ := react.NewJSX() // TODO: caching if we have more components if debug { component, err := jsx.TransformFile("./templates/_feed.jsx", map[string]interface{}{ "harmony": true, "strip_types": true, }) if err != nil { panic(err) } err = rc.Load(component) if err != nil { panic(err) } } else { component, err := Asset("static/js/bundle.min.js") if err != nil { panic(err) } err = rc.Load(component) if err != nil { panic(err) } } return &Server{ debug: debug, client: c, worker: worker, secretKey: secretKey, httpclient: httpclient, cache: cacheStore, jsx: jsx, rc: rc, } }