Skip to content

Commit fd79844

Browse files
committedOct 4, 2010
write_a_connector doc
1 parent 1c26da0 commit fd79844

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
 

‎doc/write_a_connector

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
we need connectors to connect outside bug trackers and SD.
2+
currently we have a few of them in lib/App/SD/Replica/
3+
4+
If you want to write another one, here is a simple introduction to the
5+
skeleton of what a connector looks like.
6+
You can also refer to those existed ones to get the example code.
7+
8+
Let's call the outside bug tracker( also named "Foreign Replica" in SD ) Foo here,
9+
then the module is named App::SD::Replica::foo.
10+
Assuming the client library of Foo is Net::Foo, by which we can communicate
11+
with Foo.
12+
13+
App::SD::Replica::foo: some important attributes/methods:
14+
15+
scheme: the scheme to indicate the url is a foo replica
16+
normally, it's the same as the package name's last part: 'foo'
17+
18+
pull_encoder:
19+
class name for pulling(importing data from outside)
20+
normally, it's App::SD::Replica::foo::PullEncoder
21+
22+
push_encoder:
23+
class name for pushing(exporting data to outside)
24+
normally, it's App::SD::Replica::foo::PushEncoder
25+
26+
query: query string parsed from url
27+
28+
foo: instance of Net::Foo if you want
29+
30+
uuid(): uuid of the replica, may be calculated from the url
31+
32+
database_settings(): you can customize database settings here
33+
34+
get_txn_list_by_date($ticket):
35+
returns transactions(ordered from latest to earliest) of the $ticket.
36+
it's used to record transactions we pushed from SD.
37+
38+
When creating an object of App::SD::Replica::foo, we need to parse the url(
39+
e.g. foo:/project/ticket/list/query, which is read from user's input ) and init
40+
things, e.g. init foo attribute with Net::Foo.
41+
We suggest use Any::Moose and do this job in BUILD method
42+
43+
App::SD::Replica::foo::PullEncoder: some important attributes/methods:
44+
45+
sync_source: the object of App::SD::Replica::foo
46+
47+
ticket_id( $ticket ): returns the ticket's remote id
48+
49+
find_matching_tickets( query => $query ):
50+
returns an arrayref of tickets we want to traverse
51+
52+
find_matching_transactions( ticket => $id, starting_transaction => $num )
53+
returns an arrayref of all transactions (as hashes) on ticket $id after transaction $num.
54+
55+
translate_ticket_state( $ticket, $transactions ):
56+
returns a list with 2 elements, first is initial state, last is final state
57+
58+
transcode_one_txn( $txn, $initial_state, $final_state ):
59+
returns an object of Prophet::ChangeSet
60+
61+
App::SD::Replica::foo::PushEncoder:
62+
63+
sync_source: the object of App::SD::Replica::foo
64+
65+
integrate_change( $change, $changeset ):
66+
pushes to remote Foo
67+

0 commit comments

Comments
 (0)
Please sign in to comment.