Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Update Pathy and URI #100

Merged
merged 36 commits into from
Mar 20, 2018
Merged

Update Pathy and URI #100

merged 36 commits into from
Mar 20, 2018

Conversation

safareli
Copy link
Contributor

It compiles but tests are failing, I guess I missed something in *Path print parse functions.

@safareli safareli requested a review from garyb February 16, 2018 15:53
@@ -2,7 +2,7 @@
Copyright 2017 SlamData, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file_ except in compliance with the License.
Copy link
Member

Choose a reason for hiding this comment

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

oops_ 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

find and replace :d

garyb
garyb previously requested changes Feb 27, 2018
Copy link
Member

@garyb garyb left a comment

Choose a reason for hiding this comment

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

☝️, plus it looks like there is a compilation failure in the build now.


parseGroup ∷ String → Either String GroupPath
parseGroup string =
Str.stripPrefix (Str.Pattern "group:") string
# maybe (Left "Incorrect group") pure
# note "Incorrect group"
Copy link
Member

Choose a reason for hiding this comment

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

Let's change these "Incorrect " messages to "Could not parse " instead, while we're in here. We don't want a user to end up seeing these messages as they are, as it sounds like they're doing something wrong, when it's not at all something they have control over.

type QURIRefOptions = URI.URIRefOptions URI.UserPassInfo QURIHost AbsPath AbsPath AnyPath QQuery URI.Fragment

type QURI = URI.URI URI.UserPassInfo QURIHost AbsPath AbsPath QQuery URI.Fragment
type QURIOptions = URI.URIOptions URI.UserPassInfo QURIHost AbsPath AbsPath QQuery URI.Fragment
Copy link
Member

Choose a reason for hiding this comment

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

Please don't align things with whitespace 😄

@@ -54,59 +49,52 @@ instance showAuth ∷ Show Auth where
"(Auth { path: " <> show path <> ", credentials: " <> show credentials <> " })"

type Config =
{ hosts ∷ NonEmpty Array Host
{ hosts ∷ URI.QURIHost
Copy link
Member

Choose a reason for hiding this comment

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

This is incorrect now; mongo URIs will need a separate options setup / type configuration, since they're allowed to have multiple hosts. The Data.URI.Extra.MultiHostPortPair is for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's. QURIHost
type QURIHost = URI.MultiHostPortPair URI.Host URI.Port

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see, it's the opposite problem then - every other URI should not support multiple hosts 😄 (it only did that before because we couldn't express otherwise with the types).

URI.HierarchicalPartAuth
authority'
(Just (bimap (path </> _) (path </> _) relPath))
)
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit hard to read, maybe we could extract it out into another where function and use it like toHierPart authority (Just (bimap (path </> _) (path </> _) relPath))


type AnyPath = AbsPath
type DirPath = Path Abs Dir
type FilePath = Path Abs File
Copy link
Member

Choose a reason for hiding this comment

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

Did we add these to pathy in the end?

printScheme = Scheme.print

unsafeSchemaFromString :: String -> URI.Scheme
unsafeSchemaFromString = Scheme.unsafeFromString
Copy link
Member

Choose a reason for hiding this comment

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

This should be "Scheme" not "Schema" 😄

qRelativeRef ∷ PrintParse QRelativeRef
qRelativeRef = { print: RelativeRef.print opts.relativeRef, parser: RelativeRef.parser opts.relativeRef }
qURIRef ∷ PrintParse QURIRef
qURIRef = { print: URIRef.print opts.uriRef, parser: URIRef.parser opts.uriRef }
Copy link
Member

Choose a reason for hiding this comment

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

Maybe could define these as purescript-codec definitions instead?

fromJSON parent json
= Mount <$> Mount.fromJSON parent json
<|> do
obj ← decodeJson json
name ← obj .? "name"
name'note "empty name" <<< fromString =<< (obj .? "name")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this, since there can be a mount at / (which will have no name, understandably). I'll try and concoct a test case.

Copy link
Member

Choose a reason for hiding this comment

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

This is fine actually, it's just for file listings, so everything must indeed have a name.

Copy link
Member

@garyb garyb left a comment

Choose a reason for hiding this comment

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

Generally looks 👍, just a few comments/ideas. I can help do those if you'd like to continue on updating SD.

Just a, Just b -> Just $ Both a b
Just a, Nothing -> Just $ This a
Nothing, Just b -> Just $ That b
Nothing, Nothing -> Nothing
Copy link
Member

Choose a reason for hiding this comment

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

Couple'a unicode bits here and in the type, and in some other places in the PR.

] <> maybe [] (pure <<< Tuple "queryTimeoutSeconds" <<< Just <<< show <<< un Seconds) queryTimeout

fromURI ∷ URI.QAbsoluteURI → Either String Config
fromURI (URI.AbsoluteURI scheme (URI.HierarchicalPartNoAuth path) query) =
Copy link
Member

Choose a reason for hiding this comment

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

Could switch this (and any other like it) to a case _ of while we're here perhaps?

= maybe (Left "Couldn't sandbox") Right
<<< parseDirPath
= note "Couldn't parse absolute dir path"
<<< parseQDirPath
<=< (_ .? "connectionUri")
<=< (_ .? "mimir")
<=< decodeJson
Copy link
Member

Choose a reason for hiding this comment

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

Most of these could be changed to just purescript-codec-argonaut JsonCodecs now we have the dependency too, actually.

@safareli
Copy link
Contributor Author

There are quite a good amount of things which need to be update in SD, so let's do
JsonCodec changes in different pr :D

@garyb garyb dismissed their stale review February 28, 2018 16:34

Out of date

@garyb garyb changed the title WIP update Pathy and URI Update Pathy and URI Feb 28, 2018
Copy link
Member

@garyb garyb left a comment

Choose a reason for hiding this comment

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

The build is failing at the moment, but looks like it's probably just a test that needs updating.

genAlphaNumericNEString = cons <$> genAlphaNumericChar <*> SG.genString genAlphaNumericChar

genAlphaNumericChar ∷ ∀ m. MonadGen m ⇒ MonadRec m ⇒ m Char
genAlphaNumericChar = Gen.oneOf $ CG.genDigitChar :| [CG.genAlpha]

genHostURI ∷ ∀ m. MonadGen m ⇒ MonadRec m ⇒ m URI.Host
genHostURI = Gen.oneOf $ genIPv4 :| [genName]
Copy link
Member

Choose a reason for hiding this comment

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

There's a URI.Host.Gen.genHost we can use for this now.

(case NES.fromString bucketName of
Nothing → Just $ Left P.rootDir
Just n → Just $ Right $ P.rootDir </> P.file' (Name n)
)
Copy link
Member

Choose a reason for hiding this comment

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

Don't need parens around the case here I think.

Just a, Just b → Just $ Both a b
Just a, Nothing → Just $ This a
Nothing, Just b → Just $ That b
Nothing, Nothing → Nothing
Copy link
Member

Choose a reason for hiding this comment

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

We can use the one of these I just added to purescript-these now 😄 (sorry)

garyb
garyb previously approved these changes Mar 16, 2018
Copy link
Member

@garyb garyb left a comment

Choose a reason for hiding this comment

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

But please hold off on merging until #103 is sorted out

@garyb
Copy link
Member

garyb commented Mar 16, 2018

Oh, I guess we need to merge/release the dependencies too.

@safareli
Copy link
Contributor Author

We should wait until pr in SD passes

@safareli safareli merged commit 13d03a3 into slamdata:master Mar 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants