ref
9.0
top
← prev up next →

HiveπŸ”— i

Roman Klochkov <kalimehtar@mail.ru>

Hive is the framework for a client-server application with persistent object storage on server side.

This package provides functions, that will be used both on client and server sides of the hive application.

1Network read and writeπŸ”— i

This library provides read and write for network streams. The connection is unreliable. I know, that TCP is considered reliable, but in fact, when network infrastucture drops part of packets, it may recover too slow. So, Hive uses keepalive packets and tools to control read timeout.

procedure

( write/flush dataout)void?

data:any/c
Sends data to out and flushes out.

procedure

( read/timeout [intimeout])any

timeout : (or/c#f(and/creal? (not/cnegative? ))(->any))
= 30
Reads from in like read . If read is not completed in timeout, returns eof . timeout is treated like in sync/timeout

2Serializable objectsπŸ”— i

This library provide serializable objects. It differs from racket/serialize in that it doesn’t deep copy of the object. It rather replaces all field values, that references to other object s to special ref structure. This way the library may be used to send object by network or save to file without saving all linked objects.

struct

(struct object (id)
#:extra-constructor-namemake-object)
A structure type for objects, that may be used in serializable structure. Object types are expected to inherit this structure.

struct

(struct ref (typenameid)
#:extra-constructor-namemake-ref)
typename:symbol?
A structure type for references to objects. When object is serialize, all object s in its fields are replaced to ref s.

procedure

( find-by-ref idobjects)(or/c#fobject? )

objects:(listofobject? )
Returns an object with id equals to id from objects. If there is no such object, then returns #f.

Examples:
> (find-by-ref 2(list (object 5)(object 6)))

#f

> (find-by-ref 5(list (object 5)(object 6)))

#<object>

syntax

( struct/serialize namerest...)

Constracts new serializable structure. Has same subforms as struct

procedure

( serializable? obj)boolean?

obj:any/c
Is a predicate for serializable objects.

procedure

( serialize obj[prepare])list?

Returns serialization of the obj’s content. This serialization is for use with write and read . NB: it doesn’t contains type of obj. Type is expected to be known from other sources.

Examples:
> (struct/serialize test(ab)#:transparent)
> (define data(test(object 3)5))
> (serialize data)

'(#s(ref object 3) 5)

procedure

( deserialize dataderef)any/c

data:any/c
deref:(ref? . -> .any/c)
Returns deserialized content of the serializable object. Result is expected be used to constract new object with same fields.

Examples:
> data

(test #<object> 5)

> (apply test(deserialize (serialize data)
(λ (r)(object (ref-id r)))))

(test #<object> 5)

3UsersπŸ”— i

struct

(struct usersobject (namepasswordroleonline)
#:extra-constructor-namemake-users
#:mutable)
name:string?
password:string?
role:symbol?
online:#f
Represent user of Hive.
  • name - user name, any unicode characters allowed;

  • password - user password;

  • role - user role. Hive accepts 'admin and 'user, but application may invent it’s own;

  • online - #t, iff user is logged on and sending keepalive packets.

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /