Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
cloogle.org
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cloogle
cloogle.org
Commits
476a2613
Commit
476a2613
authored
Oct 19, 2016
by
Mart Lubbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add rudimentary caching support
parent
7d5eeece
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
6 deletions
+35
-6
.gitignore
.gitignore
+1
-0
README.md
README.md
+1
-0
backend/CleanTypeUnifier
backend/CleanTypeUnifier
+1
-1
backend/CloogleServer.icl
backend/CloogleServer.icl
+29
-4
backend/Dockerfile
backend/Dockerfile
+1
-0
docker-compose.yml
docker-compose.yml
+1
-0
frontend/api.js
frontend/api.js
+1
-1
No files found.
.gitignore
View file @
476a2613
...
...
@@ -7,3 +7,4 @@ cloogle.log
node_modules/
backend/clean-compiler/
db/storage/
cache
README.md
View file @
476a2613
...
...
@@ -71,6 +71,7 @@ fields:
Return code:
* `0`: success
* `1`: cache hit, thus success
* `127`: no results
* `128`: ununderstandable input (usually shouldn't happen)
* `129`: invalid name field
...
...
CleanTypeUnifier
@
1903c2f8
Compare
ca2fa7bb
...
1903c2f8
Subproject commit
ca2fa7bbc9a999ed472f2edbd598296f31104afa
Subproject commit
1903c2f88adb1c47d33644b21ebf9c2c157b03dd
backend/CloogleServer.icl
View file @
476a2613
...
...
@@ -8,22 +8,31 @@ from TCPIP import :: IPAddress, :: Port, instance toString IPAddress
from
Data
.
Func
import
$
import
Data
.
List
import
StdDebug
import
Data
.
List
import
Data
.
Tuple
import
Data
.
Maybe
import
System
.
CommandLine
import
Text
.
JSON
import
Data
.
Functor
import
Control
.
Applicative
import
Control
.
Monad
from
Data
.
Error
import
::
MaybeError
(
Ok
,
Error
)
from
Text
import
class
Text
(
concat
,
trim
,
indexOf
,
toLowerCase
),
instance
Text
String
,
instance
+
String
import
System
.
Time
import
System
.
FilePath
import
System
.
File
import
Crypto
.
Hash
.
MD5
from
SimpleTCPServer
import
::
LogMessage
{..},
serve
,
::
Logger
import
qualified
SimpleTCPServer
import
TypeDB
import
Type
CACHEPATH
:==
"./cache"
::
Request
=
{
unify
::
Maybe
String
,
name
::
Maybe
String
,
className
::
Maybe
String
...
...
@@ -80,7 +89,7 @@ import Type
::
StrUnifier
:==
([(
String
,
String
)],
[(
String
,
String
)])
::
ErrorResult
=
Error
Int
String
::
ErrorResult
=
Maybe
Error
Int
String
::
ShortClassResult
=
{
cls_name
::
String
,
cls_vars
::
[
String
]
}
...
...
@@ -151,6 +160,9 @@ where
handle
::
!
TypeDB
!(
Maybe
Request
)
!*
World
->
*(!
Response
,
!*
World
)
handle
_
Nothing
w
=
(
err
E_INVALIDINPUT
"Couldn't parse input"
,
w
)
handle
db
(
Just
request
=:{
unify
,
name
,
page
})
w
#
cachefile
=
CACHEPATH
</>
(
md5
$
toString
request
)
#
(
mr
,
w
)
=
readCache
cachefile
w
|
isJust
mr
=
(
fromJust
mr
,
w
)
|
isJust
name
&&
size
(
fromJust
name
)
>
40
=
(
err
E_INVALIDNAME
"function name too long"
,
w
)
|
isJust
name
&&
any
isSpace
(
fromString
$
fromJust
name
)
...
...
@@ -170,13 +182,26 @@ where
#
results
=
take
MAX_RESULTS
results
// Response
|
isEmpty
results
=
(
err
E_NORESULTS
"No results"
,
w
)
=
(
{
return
=
0
// Save cache file if it didn't exist
=
writeCache
cachefile
{
return
=
0
,
msg
=
"Success"
,
data
=
results
,
more_available
=
Just
more
,
suggestions
=
suggestions
}
,
w
)
}
w
readCache
::
!
String
!*
World
->
(
Maybe
Response
,
!*
World
)
readCache
fp
w
=
case
readFile
fp
w
of
(
Error
_,
w
)
=
(
Nothing
,
w
)
// Probably doesn't exist
(
Ok
s
,
w
)
=
case
fromJSON
$
fromString
s
of
Nothing
=
appFst
(
const
Nothing
)
$
deleteFile
fp
w
(
Just
r
)
=
(
Just
{
r
&
return
=
1
},
w
)
writeCache
::
!
String
!
Response
!*
World
->
(!
Response
,
!*
World
)
writeCache
fp
r
w
=
case
writeFile
fp
(
toString
$
toJSON
r
)
w
of
(
Error
e
,
w
)
=
abort
$
"Error writing file...: "
+++
toString
e
(
Ok
_,
w
)
=
(
r
,
w
)
suggs
::
!(
Maybe
String
)
!
Type
!
TypeDB
->
Maybe
[(
Request
,
Int
)]
suggs
n
(
Func
is
r
cc
)
db
...
...
backend/Dockerfile
View file @
476a2613
...
...
@@ -19,6 +19,7 @@ COPY . /usr/src/cloogle
WORKDIR
/usr/src/cloogle
RUN
make distclean
&&
make
RUN
mkdir
-p
./cache
EXPOSE
31215
...
...
docker-compose.yml
View file @
476a2613
...
...
@@ -6,6 +6,7 @@ services:
-
"
31215:31215"
volumes
:
-
"
./cloogle.log:/usr/src/cloogle/cloogle.log"
-
"
./cache:/usr/src/cloogle/cache"
restart
:
always
frontend
:
...
...
frontend/api.js
View file @
476a2613
...
...
@@ -243,7 +243,7 @@ function getResults(str, libs, page) {
if
(
xmlHttp
.
readyState
==
4
&&
xmlHttp
.
status
==
200
){
document
.
getElementById
(
'
loading
'
).
remove
();
var
responsedata
=
JSON
.
parse
(
xmlHttp
.
responseText
);
if
(
responsedata
[
'
return
'
]
===
0
){
if
(
responsedata
[
'
return
'
]
>=
0
&&
responsedata
[
'
return
'
]
<=
64
){
for
(
var
i
=
0
;
i
<
responsedata
[
'
data
'
].
length
;
i
++
){
var
c
=
responsedata
[
'
data
'
][
i
];
elem
.
innerHTML
+=
makeResultHTML
(
c
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment