Setting the default instance according to best response times and API availability.
This commit is contained in:
parent
9337c46863
commit
4b6ad35ed6
@ -10,12 +10,20 @@ Class {
|
|||||||
'api',
|
'api',
|
||||||
'monitor'
|
'monitor'
|
||||||
],
|
],
|
||||||
|
#classInstVars : [
|
||||||
|
'default'
|
||||||
|
],
|
||||||
#category : #VideoWeb
|
#category : #VideoWeb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Invidious class >> default: anObject [
|
||||||
|
default := anObject
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
Invidious class >> defaultInstance [
|
Invidious class >> defaultInstance [
|
||||||
^ self instances select: [ :instance | instance api = true ]
|
^ default ifNil: [ default := self responseTimes first key ]
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
@ -27,6 +35,11 @@ Invidious class >> instances [
|
|||||||
Invidious new fromDictionary: instanceDict ]
|
Invidious new fromDictionary: instanceDict ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Invidious class >> instancesWithAPIEnabled [
|
||||||
|
^ self instances select: [ :instance | instance api = true ]
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
Invidious class >> rawInstances [
|
Invidious class >> rawInstances [
|
||||||
^ STON
|
^ STON
|
||||||
@ -34,6 +47,22 @@ Invidious class >> rawInstances [
|
|||||||
retrieveContents
|
retrieveContents
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Invidious class >> responseTimes [
|
||||||
|
| responses |
|
||||||
|
responses := Dictionary new.
|
||||||
|
self instancesWithAPIEnabled do: [ :instance | | runTime|
|
||||||
|
runTime := [ ZnClient new
|
||||||
|
beOneShot;
|
||||||
|
url: instance uri;
|
||||||
|
get;
|
||||||
|
response ] timeToRun.
|
||||||
|
responses at: instance put: runTime.
|
||||||
|
].
|
||||||
|
^ (responses associations asSortedCollection: [ :x :y| x value < y value ])
|
||||||
|
collect: [:assoc | assoc ]
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
Invidious >> api [
|
Invidious >> api [
|
||||||
^ api
|
^ api
|
||||||
|
Loading…
Reference in New Issue
Block a user