memcache/request.h
author Tero Marttila <terom@fixme.fi>
Thu, 28 Aug 2008 01:34:14 +0300
changeset 44 03a7e064f833
parent 43 e5b714190dee
child 48 1c67f512779b
permissions -rw-r--r--
stub functions and documentation
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
#ifndef MEMCACHE_REQ_H
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
#define MEMCACHE_REQ_H
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
#include <sys/queue.h>
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
#include "../memcache.h"
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
#include "connection.h"
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
struct memcache_req {
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    10
    // the memcache context that we belong to
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    11
    struct memcache *mc;
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    12
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    13
    // the command to execute
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    14
    enum memcache_command cmd_type;
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    15
42
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    16
    // the reply we have received, or MEMCACHE_REPLY_INVALID
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    17
    enum memcache_reply reply_type;
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    18
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    19
    // our key/obj
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    20
    struct memcache_key key;
41
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    21
    struct memcache_obj obj;
540737bf6bac sending requests, and partial support for receiving -- incomplete, not tested
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    22
    struct memcache_buf buf;
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    23
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    24
    // flags to indicate if we have valid obj/buf data
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    25
    char have_obj, have_buf;
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    26
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    27
    // our state
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    28
    enum memcache_req_state state;
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    29
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    30
    // our user callback argument
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    31
    void *cb_arg;
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    32
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    33
    // the conn 
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    34
    struct memcache_connection *conn;
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
    
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
    // we are a member of struct memcache_server.req_queue
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
    TAILQ_ENTRY(memcache_req) reqqueue_node;
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
};
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    40
/*
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    41
 * Allocate and return a new req, or NULL if unsuccesfull.
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    42
 */
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    43
struct memcache_req *memcache_req_alloc (struct memcache *mc, enum memcache_command cmd_type, const struct memcache_key *key, const struct memcache_obj *obj, const struct memcache_buf *buf, void *cb_arg);
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    44
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    45
/*
42
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    46
 * The request has been queued.
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    47
 */
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    48
void memcache_req_queued (struct memcache_req *req);
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    49
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    50
/*
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    51
 * The request is being sent.
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    52
 */
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    53
void memcache_req_send (struct memcache_req *req);
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    54
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    55
/*
43
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    56
 * The reply has been received, although if the respones also contains data, that will be notified separately.
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    57
 *
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    58
 * If the response doesn't contain any data, req_done will be called after this is. Otherwise, this will be called
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    59
 * first, followed by zero or more calls to req_data, followed by req_reply/RPL_END + req_done.
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    60
 *
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    61
 * Note that no req data will not be available when this is first called, only once req_data/req_done is called.
42
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    62
 */
44
03a7e064f833 stub functions and documentation
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    63
void memcache_req_recv (struct memcache_req *req, enum memcache_reply reply_type);
42
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    64
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    65
/*
43
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    66
 * Some amount of reply data has been received. This may be called between the req_reply/MEMCACHE_RPL_VALUE and
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    67
 * req_reply/MEMCACHE_RPL_END + req_done notifications.
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    68
 *
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    69
 * Note that this is not always called, it is possible that one might have:
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    70
 *      memcache_req_reply(req, MEMCACHE_RPL_VALUE)
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    71
 *      memcache_req_reply(req, MEMCACHE_RPL_END)
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    72
 *      memcache_req_done(req)
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    73
 *
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    74
 * This will happen if both the value and the end replies are received in the same chunk.
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    75
 *
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    76
 * Note also that replies may have zero-length entries, in which case req_data will never be called either.
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    77
 */
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    78
void memcache_req_data (struct memcache_req *req);
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    79
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    80
/*
42
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    81
 * The request was sent and is now done, and is not associated with the connection anymore.
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    82
 *
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    83
 * This will be called before req_reply/req_data, but not before/after req_error.
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    84
 */
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    85
void memcache_req_done (struct memcache_req *req);
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    86
0e503189af2f more reply-receiving code, but still incomplete
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    87
/*
43
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    88
 * An error occurred, and the request must be abandoned. This will assume that the req is not active or enqueued
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    89
 * anymore, and the req should not be accessed by memcache_* code after this.
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    90
 */
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    91
void memcache_req_error (struct memcache_req *req);
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    92
e5b714190dee the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    93
/*
39
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    94
 * Free an unused req. Should always be called by the user, not via internal means.
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    95
 */
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    96
void memcache_req_free (struct memcache_req *req);
0e21a65074a6 memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents: 38
diff changeset
    97
38
9894df13b779 added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    98
#endif /* MEMCACHE_REQ_H */