mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-14 15:04:14 +03:00
initial work on eyre heartbeat
This commit is contained in:
parent
9ec4de8d6b
commit
d20aee378b
@ -1,4 +1,4 @@
|
|||||||
:: :: %eyre, http servant
|
!: :: %eyre, http servant
|
||||||
!? 164
|
!? 164
|
||||||
::::
|
::::
|
||||||
|= pit=vase
|
|= pit=vase
|
||||||
@ -47,7 +47,7 @@
|
|||||||
== == ::
|
== == ::
|
||||||
$: %g :: to %gall
|
$: %g :: to %gall
|
||||||
$% [%mess p=hasp q=ship r=cage] ::
|
$% [%mess p=hasp q=ship r=cage] ::
|
||||||
[%nuke p=hasp] ::
|
[%nuke p=hasp q=ship] ::
|
||||||
[%show p=hasp q=ship r=path] ::
|
[%show p=hasp q=ship r=path] ::
|
||||||
== == == ::
|
== == == ::
|
||||||
++ rave :: see %clay
|
++ rave :: see %clay
|
||||||
@ -145,6 +145,7 @@
|
|||||||
== ::
|
== ::
|
||||||
++ seam :: logical request
|
++ seam :: logical request
|
||||||
$% [%ape p=term q=ship r=@ud s=@ud t=@ud] :: subscribe pull
|
$% [%ape p=term q=ship r=@ud s=@ud t=@ud] :: subscribe pull
|
||||||
|
[%aph p=term q=ship r=@ud s=@ud t=json] :: app heartbeat
|
||||||
[%apg p=term q=ship r=logo s=path] :: app get/start
|
[%apg p=term q=ship r=logo s=path] :: app get/start
|
||||||
[%apm p=term q=ship r=@ud s=@ud t=json] :: message send
|
[%apm p=term q=ship r=@ud s=@ud t=json] :: message send
|
||||||
[%aps p=term q=ship r=@ud s=@ud t=path] :: subscribe
|
[%aps p=term q=ship r=@ud s=@ud t=path] :: subscribe
|
||||||
@ -164,7 +165,8 @@
|
|||||||
cah=(map cash vase) :: compilation cache
|
cah=(map cash vase) :: compilation cache
|
||||||
== ::
|
== ::
|
||||||
++ sink :: page push system
|
++ sink :: page push system
|
||||||
$: meg=@ud :: message counter
|
$: bet=[num=@ud tim=@da] :: heartbeat
|
||||||
|
meg=@ud :: message counter
|
||||||
haw=(map ,@ud swig) :: subscriptions
|
haw=(map ,@ud swig) :: subscriptions
|
||||||
== ::
|
== ::
|
||||||
++ swig :: update channel
|
++ swig :: update channel
|
||||||
@ -329,6 +331,9 @@
|
|||||||
(slav %ud i.t.t.t.tea)
|
(slav %ud i.t.t.t.tea)
|
||||||
?~ ouy
|
?~ ouy
|
||||||
+>.$
|
+>.$
|
||||||
|
~& [%axon-fun `@dr`(sub now tim.bet.siq:beat:u.ouy)]
|
||||||
|
?: (lth ~m2 (sub now tim.bet.siq:beat:u.ouy))
|
||||||
|
abet:work:amok:u.ouy
|
||||||
=+ woy=(yule:u.ouy (slav %ud i.t.t.t.t.tea))
|
=+ woy=(yule:u.ouy (slav %ud i.t.t.t.t.tea))
|
||||||
=< abet =< work =< abet
|
=< abet =< work =< abet
|
||||||
?- -.+.sih
|
?- -.+.sih
|
||||||
@ -1029,6 +1034,40 @@
|
|||||||
?> ?=(%way pez.u.pup)
|
?> ?=(%way pez.u.pup)
|
||||||
$(yov t.yov, q.rey (~(put by q.rey) i.yov u.pup(pez noz)))
|
$(yov t.yov, q.rey (~(put by q.rey) i.yov u.pup(pez noz)))
|
||||||
::
|
::
|
||||||
|
++ duti :: heartbeat script
|
||||||
|
;script:'''
|
||||||
|
var heart = {
|
||||||
|
seqn: 0,
|
||||||
|
trys: 0,
|
||||||
|
dely: 10000,
|
||||||
|
|
||||||
|
beat: function() {
|
||||||
|
var method, perm, url, $this
|
||||||
|
|
||||||
|
method = "put"
|
||||||
|
perm = "tih"
|
||||||
|
url = [perm,user,appl,port,this.seqn]
|
||||||
|
url = "/"+url.join("/")
|
||||||
|
|
||||||
|
$this = this
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest()
|
||||||
|
xhr.open(method.toUpperCase(), url)
|
||||||
|
xhr.setRequestHeader("content-type", "text/json")
|
||||||
|
xhr.send(JSON.stringify({oryx:oryx, xyro: {heart:"beat"}}))
|
||||||
|
xhr.onload = function () {
|
||||||
|
$this.seqn++
|
||||||
|
$this.trys = 0
|
||||||
|
setTimeout($this.beat,$this.dely)
|
||||||
|
}
|
||||||
|
xhr.onerror = function() {
|
||||||
|
$this.trys++
|
||||||
|
setTimeout($this.beat,$this.dely*$this.trys)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
heart.beat()
|
||||||
|
'''
|
||||||
++ duty :: reload script
|
++ duty :: reload script
|
||||||
;script
|
;script
|
||||||
; var tries = 0;
|
; var tries = 0;
|
||||||
@ -1085,6 +1124,20 @@
|
|||||||
(turn t.paw |=(a=@ `@ta`(need ((sand %ta) a))))
|
(turn t.paw |=(a=@ `@ta`(need ((sand %ta) a))))
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
|
++ faph :: dispatch %aph
|
||||||
|
|= [fur=(unit term) you=@p paw=path moh=moth]
|
||||||
|
^- (unit seam)
|
||||||
|
?> ?=(~ fur)
|
||||||
|
?> ?=([@ @ @ ~] paw)
|
||||||
|
:- ~
|
||||||
|
:* %aph
|
||||||
|
(need ((sand %tas) i.paw))
|
||||||
|
you
|
||||||
|
(slav %ui (cat 3 '0i' i.t.paw))
|
||||||
|
(slav %ui (cat 3 '0i' i.t.t.paw))
|
||||||
|
(need (ecci orx.ced moh))
|
||||||
|
==
|
||||||
|
::
|
||||||
++ fapm :: dispatch %apm
|
++ fapm :: dispatch %apm
|
||||||
|= [fur=(unit term) you=@p paw=path moh=moth]
|
|= [fur=(unit term) you=@p paw=path moh=moth]
|
||||||
^- (unit seam)
|
^- (unit seam)
|
||||||
@ -1343,6 +1396,7 @@
|
|||||||
%m :: app message
|
%m :: app message
|
||||||
%r :: app response
|
%r :: app response
|
||||||
%s :: app subscribe
|
%s :: app subscribe
|
||||||
|
%h :: app heartbeat
|
||||||
%n :: now
|
%n :: now
|
||||||
%u :: app unsubscribe
|
%u :: app unsubscribe
|
||||||
%z :: app version
|
%z :: app version
|
||||||
@ -1386,6 +1440,7 @@
|
|||||||
%t
|
%t
|
||||||
?+ tri ~
|
?+ tri ~
|
||||||
%c (flub paw [~ moh])
|
%c (flub paw [~ moh])
|
||||||
|
%h (faph p.q.pul yun paw moh)
|
||||||
%m (fapm p.q.pul yun paw moh)
|
%m (fapm p.q.pul yun paw moh)
|
||||||
%s (faps p.q.pul yun paw moh)
|
%s (faps p.q.pul yun paw moh)
|
||||||
%u (fapu p.q.pul yun paw)
|
%u (fapu p.q.pul yun paw)
|
||||||
@ -1520,6 +1575,11 @@
|
|||||||
:: ==
|
:: ==
|
||||||
:- [~ pip(pez %way)]
|
:- [~ pip(pez %way)]
|
||||||
(yokg num p.som.pip q.som.pip s.som.pip)
|
(yokg num p.som.pip q.som.pip s.som.pip)
|
||||||
|
::
|
||||||
|
%aph :: heartbeat
|
||||||
|
~& [%wink-aph +.som.pip]
|
||||||
|
:- [~ pip(pez %way)]
|
||||||
|
(yokh num +.som.pip)
|
||||||
::
|
::
|
||||||
%apm :: message
|
%apm :: message
|
||||||
:: ~& [%wink-apm +.som.pip]
|
:: ~& [%wink-apm +.som.pip]
|
||||||
@ -1929,7 +1989,16 @@
|
|||||||
|= [num=@ud app=term you=ship pax=path]
|
|= [num=@ud app=term you=ship pax=path]
|
||||||
^+ +>
|
^+ +>
|
||||||
?< (~(has by sok) num)
|
?< (~(has by sok) num)
|
||||||
abet:(~(self yo num app you *sink) pax)
|
abet:(~(self yo num app you [[*@ud now] *[@ud (map ,@ud swig)]]) pax)
|
||||||
|
::
|
||||||
|
++ yokh :: heartbeat
|
||||||
|
|= [num=@ud app=term you=ship nap=@ud cnt=@ud jon=json]
|
||||||
|
^+ +>
|
||||||
|
=+ yon=(yolk nap)
|
||||||
|
~& [%yokh-1 cnt]
|
||||||
|
?~ yon (bust 204 num)
|
||||||
|
~& [%yokh-2 cnt]
|
||||||
|
abet:(beat:u.yon cnt num jon)
|
||||||
::
|
::
|
||||||
++ yokm :: message
|
++ yokm :: message
|
||||||
|= [num=@ud app=term you=ship nap=@ud cnt=@ud jon=json]
|
|= [num=@ud app=term you=ship nap=@ud cnt=@ud jon=json]
|
||||||
@ -1967,13 +2036,23 @@
|
|||||||
::
|
::
|
||||||
++ amok :: demolish
|
++ amok :: demolish
|
||||||
^+ ..yo
|
^+ ..yo
|
||||||
|
~& %amok-time
|
||||||
=+ wuh=(~(tap by haw.siq) ~)
|
=+ wuh=(~(tap by haw.siq) ~)
|
||||||
|- ^+ ..yo
|
|- ^+ ..yo
|
||||||
?~ wuh
|
?~ wuh
|
||||||
%= ..yo
|
%= ..yo
|
||||||
sok (~(del by sok) nap)
|
sok (~(del by sok) nap)
|
||||||
==
|
==
|
||||||
$(wuh t.wuh, ..amok (pass p.i.wuh `note`[%g %nuke our app]))
|
$(wuh t.wuh, ..amok (pass p.i.wuh `note`[%g %nuke [our app] you]))
|
||||||
|
::
|
||||||
|
++ beat
|
||||||
|
|= [cnt=@ud num=@ud jon=json]
|
||||||
|
^+ +>
|
||||||
|
?. =(cnt num.bet.siq)
|
||||||
|
+>.$(..yo (bust 204 num))
|
||||||
|
=. bet.siq [+(num.bet.siq) now]
|
||||||
|
~& [%beat jon]
|
||||||
|
(hear:(yule:(hire:(yule 2) cnt num) 2) ~ %& %json !>((joba %ok %b %&)))
|
||||||
::
|
::
|
||||||
++ hoop :: request path
|
++ hoop :: request path
|
||||||
|= suq=@ud
|
|= suq=@ud
|
||||||
@ -2046,7 +2125,7 @@
|
|||||||
=+ pip=u.pup
|
=+ pip=u.pup
|
||||||
=+ ^= sip
|
=+ ^= sip
|
||||||
?. =(%apg -.som.pip) sip.pip
|
?. =(%apg -.som.pip) sip.pip
|
||||||
[duty sip.pip]
|
[duti duty sip.pip]
|
||||||
?~ huq +>.$(..yo (bust 404 num))
|
?~ huq +>.$(..yo (bust 404 num))
|
||||||
%= +>.$
|
%= +>.$
|
||||||
q.rey
|
q.rey
|
||||||
@ -2088,6 +2167,7 @@
|
|||||||
=< abet
|
=< abet
|
||||||
=+ cnt=cnt.wig
|
=+ cnt=cnt.wig
|
||||||
=+ dul=(~(get by wan.wig) cnt)
|
=+ dul=(~(get by wan.wig) cnt)
|
||||||
|
~& [%hear-dul cnt dul]
|
||||||
:: ~& :~ %yu-hear
|
:: ~& :~ %yu-hear
|
||||||
:: [%instance nap]
|
:: [%instance nap]
|
||||||
:: [%produced cnt]
|
:: [%produced cnt]
|
||||||
@ -2113,13 +2193,15 @@
|
|||||||
?: |((lth +(cnt) toy.wig) (gth cnt toy.wig))
|
?: |((lth +(cnt) toy.wig) (gth cnt toy.wig))
|
||||||
~& [%hire-improper [%request cnt] [%dispatched toy.wig]]
|
~& [%hire-improper [%request cnt] [%dispatched toy.wig]]
|
||||||
+>.$(..yo (bust 204 num))
|
+>.$(..yo (bust 204 num))
|
||||||
|
~& [%hire-1 cnt cnt.wig]
|
||||||
?: (gte cnt cnt.wig)
|
?: (gte cnt cnt.wig)
|
||||||
:: ~& %hire-wait
|
:: ~& %hire-wait
|
||||||
=+ old=(~(get by wan.wig) cnt)
|
=+ old=(~(get by wan.wig) cnt)
|
||||||
=. wan.wig (~(put by wan.wig) cnt num)
|
=. wan.wig (~(put by wan.wig) cnt num)
|
||||||
+>.$(..yo ?~(old ..yo (bust 204 u.old)))
|
+>.$(..yo ?~(old ..yo (bust 204 u.old)))
|
||||||
=+ rud=(~(get by red.wig) cnt)
|
=+ rud=(~(get by red.wig) cnt)
|
||||||
?~ rud
|
~& [%hire-2 cnt ?=(~ rud)]
|
||||||
|
?~ rud
|
||||||
:: ~& %hire-bust
|
:: ~& %hire-bust
|
||||||
+>.$(..yo (bust 204 num))
|
+>.$(..yo (bust 204 num))
|
||||||
:: ~& %hire-send
|
:: ~& %hire-send
|
||||||
|
@ -7,7 +7,7 @@ window.urb = {
|
|||||||
appl: appl,
|
appl: appl,
|
||||||
seqn: 0,
|
seqn: 0,
|
||||||
seqp: 1,
|
seqp: 1,
|
||||||
seqs: 2,
|
seqs: 3,
|
||||||
dely: 0,
|
dely: 0,
|
||||||
|
|
||||||
req: function(method,url,data,json,cb) {
|
req: function(method,url,data,json,cb) {
|
||||||
|
Loading…
Reference in New Issue
Block a user